Skip to content

Commit cc515aa

Browse files
committed
flutter uikit homepage revamped for ios
1 parent 18f4ddc commit cc515aa

File tree

4 files changed

+160
-4
lines changed

4 files changed

+160
-4
lines changed

lib/logic/viewmodel/menu_view_model.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ class MenuViewModel {
1111
return menuItems = <Menu>[
1212
Menu(
1313
title: "Profile",
14+
menuColor: Color(0xff050505),
1415
icon: Icons.person,
1516
image: UIData.profileImage,
1617
items: ["View Profile", "Profile 2", "Profile 3", "Profile 4"]),
1718
Menu(
1819
title: "Shopping",
20+
menuColor: Color(0xffc8c4bd),
1921
icon: Icons.shopping_cart,
2022
image: UIData.shoppingImage,
2123
items: [
@@ -26,31 +28,37 @@ class MenuViewModel {
2628
]),
2729
Menu(
2830
title: "Login",
31+
menuColor: Color(0xffc7d8f4),
2932
icon: Icons.send,
3033
image: UIData.loginImage,
3134
items: ["Login With OTP", "Login 2", "Sign Up", "Login 4"]),
3235
Menu(
3336
title: "Timeline",
37+
menuColor: Color(0xff7f5741),
3438
icon: Icons.timeline,
3539
image: UIData.timelineImage,
3640
items: ["Feed", "Tweets", "Timeline 3", "Timeline 4"]),
3741
Menu(
3842
title: "Dashboard",
43+
menuColor: Color(0xff261d33),
3944
icon: Icons.dashboard,
4045
image: UIData.dashboardImage,
4146
items: ["Dashboard 1", "Dashboard 2", "Dashboard 3", "Dashboard 4"]),
4247
Menu(
4348
title: "Settings",
49+
menuColor: Color(0xff2a8ccf),
4450
icon: Icons.settings,
4551
image: UIData.settingsImage,
4652
items: ["Device Settings", "Settings 2", "Settings 3", "Settings 4"]),
4753
Menu(
4854
title: "No Item",
55+
menuColor: Color(0xffe19b6b),
4956
icon: Icons.not_interested,
5057
image: UIData.blankImage,
5158
items: ["No Search Result", "No Internet", "No Item 3", "No Item 4"]),
5259
Menu(
5360
title: "Payment",
61+
menuColor: Color(0xffddcec2),
5462
icon: Icons.payment,
5563
image: UIData.paymentImage,
5664
items: ["Credit Card", "Payment Success", "Payment 3", "Payment 4"]),

lib/main.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter/services.dart';
32
import 'package:flutter_uikit/di/dependency_injection.dart';
43
import 'package:flutter_uikit/myapp.dart';
54

65
void main() {
76
// SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
8-
MaterialPageRoute.debugEnableFadingRoutes = true;
97
Injector.configure(Flavor.MOCK);
108
runApp(MyApp());
119
}

lib/model/menu.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ class Menu {
66
String image;
77
List<String> items;
88
BuildContext context;
9+
Color menuColor;
910

10-
Menu({this.title, this.icon, this.image, this.items, this.context});
11+
Menu(
12+
{this.title,
13+
this.icon,
14+
this.image,
15+
this.items,
16+
this.context,
17+
this.menuColor = Colors.black});
1118
}

lib/ui/page/home_page.dart

Lines changed: 144 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
import 'package:flutter/cupertino.dart';
12
import 'package:flutter/material.dart';
23
import 'package:flutter_uikit/logic/bloc/menu_bloc.dart';
34
import 'package:flutter_uikit/model/menu.dart';
45
import 'package:flutter_uikit/ui/widgets/about_tile.dart';
56
import 'package:flutter_uikit/ui/widgets/profile_tile.dart';
67
import 'package:flutter_uikit/utils/uidata.dart';
8+
import 'package:flutter/foundation.dart';
79

810
class HomePage extends StatelessWidget {
911
final _scaffoldState = GlobalKey<ScaffoldState>();
12+
Size deviceSize;
1013
//menuStack
1114
Widget menuStack(BuildContext context, Menu menu) => InkWell(
1215
onTap: () => _showModalBottomSheet(context, menu),
@@ -186,8 +189,148 @@ class HomePage extends StatelessWidget {
186189
)));
187190
}
188191

192+
Widget iosCardBottom(Menu menu, BuildContext context) => Padding(
193+
padding: const EdgeInsets.all(12.0),
194+
child: Row(
195+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
196+
children: <Widget>[
197+
Container(
198+
width: 40.0,
199+
decoration: BoxDecoration(
200+
color: Colors.white,
201+
borderRadius: BorderRadius.circular(10.0),
202+
border: Border.all(width: 3.0, color: Colors.white),
203+
image: DecorationImage(
204+
fit: BoxFit.cover,
205+
image: AssetImage(
206+
menu.image,
207+
))),
208+
),
209+
SizedBox(
210+
width: 20.0,
211+
),
212+
Text(
213+
menu.title,
214+
textAlign: TextAlign.start,
215+
style: TextStyle(color: Colors.white),
216+
),
217+
SizedBox(
218+
width: 20.0,
219+
),
220+
FittedBox(
221+
child: CupertinoButton(
222+
onPressed: () => _showModalBottomSheet(context, menu),
223+
borderRadius: BorderRadius.circular(50.0),
224+
child: Text(
225+
"Go",
226+
textAlign: TextAlign.left,
227+
style: TextStyle(color: CupertinoColors.activeBlue),
228+
),
229+
color: Colors.white,
230+
),
231+
)
232+
],
233+
),
234+
);
235+
236+
Widget menuIOS(Menu menu, BuildContext context) {
237+
return Container(
238+
height: deviceSize.height / 2,
239+
child: Card(
240+
elevation: 0.0,
241+
shape:
242+
RoundedRectangleBorder(borderRadius: BorderRadius.circular(14.0)),
243+
margin: EdgeInsets.all(16.0),
244+
child: Stack(
245+
fit: StackFit.expand,
246+
children: <Widget>[
247+
menuImage(menu),
248+
Padding(
249+
padding: const EdgeInsets.all(16.0),
250+
child: Text(
251+
menu.title,
252+
style: TextStyle(
253+
color: Colors.white,
254+
fontSize: 28.0,
255+
fontWeight: FontWeight.bold,
256+
),
257+
),
258+
),
259+
Positioned(
260+
bottom: 0.0,
261+
left: 0.0,
262+
right: 0.0,
263+
height: 60.0,
264+
child: Container(
265+
width: double.infinity,
266+
color: menu.menuColor,
267+
child: iosCardBottom(menu, context),
268+
),
269+
)
270+
],
271+
),
272+
),
273+
);
274+
}
275+
276+
Widget bodyDataIOS(List<Menu> data, BuildContext context) => SliverList(
277+
delegate: SliverChildListDelegate(
278+
data.map((menu) => menuIOS(menu, context)).toList()),
279+
);
280+
281+
Widget homeBodyIOS(BuildContext context) {
282+
MenuBloc menuBloc = MenuBloc();
283+
return StreamBuilder<List<Menu>>(
284+
stream: menuBloc.menuItems,
285+
initialData: List(),
286+
builder: (context, snapshot) {
287+
return snapshot.hasData
288+
? bodyDataIOS(snapshot.data, context)
289+
: Center(
290+
child: CircularProgressIndicator(),
291+
);
292+
});
293+
}
294+
295+
Widget homeIOS(BuildContext context) => Theme(
296+
data: ThemeData(
297+
fontFamily: '.SF Pro Text',
298+
).copyWith(canvasColor: Colors.transparent),
299+
child: CupertinoPageScaffold(
300+
child: CustomScrollView(
301+
slivers: <Widget>[
302+
CupertinoSliverNavigationBar(
303+
border: Border(bottom: BorderSide.none),
304+
backgroundColor: CupertinoColors.white,
305+
largeTitle: Row(
306+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
307+
children: <Widget>[
308+
Text(UIData.appName),
309+
Padding(
310+
padding: const EdgeInsets.only(right: 16.0),
311+
child: CircleAvatar(
312+
radius: 15.0,
313+
backgroundColor: CupertinoColors.black,
314+
child: FlutterLogo(
315+
size: 15.0,
316+
colors: Colors.yellow,
317+
),
318+
),
319+
)
320+
],
321+
),
322+
),
323+
homeBodyIOS(context)
324+
],
325+
),
326+
),
327+
);
328+
189329
@override
190330
Widget build(BuildContext context) {
191-
return homeScaffold(context);
331+
deviceSize = MediaQuery.of(context).size;
332+
return defaultTargetPlatform == TargetPlatform.iOS
333+
? homeIOS(context)
334+
: homeScaffold(context);
192335
}
193336
}

0 commit comments

Comments
 (0)