Last active
September 30, 2019 07:51
-
-
Save mevlanaayas/a76d3969b637a47cfdc87d35455d9a4e to your computer and use it in GitHub Desktop.
Apple shortcuts main screen implementation with Flutter. Flutter: 1.9.1+hotfix.2, Dart: 2.50, Cupertino icons: 0.1.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/cupertino.dart'; | |
import 'package:flutter/material.dart'; | |
class ShortcutsClone extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
final bottomNavigationBar = CupertinoTabBar( | |
items: const <BottomNavigationBarItem>[ | |
BottomNavigationBarItem( | |
icon: Icon(CupertinoIcons.collections), | |
title: Text('Archive'), | |
), | |
BottomNavigationBarItem( | |
icon: Icon(CupertinoIcons.tag), | |
title: Text('Gallery'), | |
), | |
], | |
); | |
return CupertinoApp( | |
debugShowCheckedModeBanner: false, | |
home: CupertinoTabScaffold( | |
tabBar: bottomNavigationBar, | |
tabBuilder: (context, i) => CupertinoTabView( | |
builder: (context) => CupertinoPageScaffold( | |
child: ShortcutsGridView(), | |
), | |
), | |
), | |
); | |
} | |
} | |
class ShortcutsGridView extends StatelessWidget { | |
final List<String> _shortcuts = ['One', 'Two', 'Three']; | |
@override | |
Widget build(BuildContext context) => CustomScrollView( | |
slivers: <Widget>[ | |
CupertinoSliverNavigationBar( | |
border: null, | |
backgroundColor: CupertinoColors.white, | |
leading: Text( | |
'Edit', | |
style: TextStyle( | |
fontSize: 20, | |
fontWeight: FontWeight.w400, | |
color: CupertinoColors.activeBlue, | |
), | |
), | |
trailing: Icon(CupertinoIcons.add), | |
largeTitle: Text('Archive'), | |
), | |
SliverList( | |
delegate: SliverChildListDelegate( | |
[ | |
Padding( | |
padding: const EdgeInsets.all(16.0), | |
child: CupertinoTextField( | |
placeholder: 'Search', | |
placeholderStyle: TextStyle( | |
fontWeight: FontWeight.w400, | |
color: CupertinoColors.inactiveGray), | |
cursorColor: CupertinoColors.inactiveGray, | |
prefix: Padding( | |
padding: const EdgeInsets.only(left: 8.0), | |
child: Icon( | |
CupertinoIcons.search, | |
color: CupertinoColors.inactiveGray, | |
), | |
), | |
decoration: BoxDecoration( | |
color: CupertinoColors.lightBackgroundGray, | |
borderRadius: BorderRadius.circular(10.0), | |
), | |
), | |
), | |
], | |
), | |
), | |
SliverGrid( | |
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( | |
crossAxisCount: 2, | |
childAspectRatio: 1.5, | |
), | |
delegate: SliverChildBuilderDelegate( | |
(BuildContext context, int index) => ShortcutsGridItem( | |
name: _shortcuts[index], | |
), | |
childCount: _shortcuts.length, | |
), | |
) | |
], | |
); | |
} | |
class ShortcutsGridItem extends StatelessWidget { | |
final String name; | |
const ShortcutsGridItem({this.name}); | |
@override | |
Widget build(BuildContext context) => Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: Container( | |
decoration: BoxDecoration( | |
borderRadius: BorderRadius.all( | |
Radius.circular(20), | |
), | |
gradient: LinearGradient( | |
begin: Alignment.centerLeft, | |
end: Alignment.centerRight, | |
stops: [0.1, 0.3, 0.6, 0.9], | |
colors: [ | |
Colors.pink[400], | |
Colors.pink[500], | |
Colors.pink[600], | |
Colors.pink[700], | |
], | |
), | |
), | |
child: Padding( | |
padding: EdgeInsets.all(10.0), | |
child: Column( | |
children: <Widget>[ | |
Container( | |
height: 30, | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
Icon( | |
CupertinoIcons.pen, | |
color: CupertinoColors.white, | |
), | |
Container( | |
decoration: BoxDecoration( | |
color: CupertinoColors.black.withOpacity(0.2), | |
borderRadius: BorderRadius.circular(20.0), | |
), | |
child: Padding( | |
padding: const EdgeInsets.all(2.0), | |
child: Icon( | |
CupertinoIcons.ellipsis, | |
color: CupertinoColors.white, | |
), | |
), | |
), | |
], | |
), | |
), | |
SizedBox( | |
height: 10, | |
), | |
Container( | |
height: 30, | |
child: Row( | |
children: <Widget>[ | |
Text( | |
name, | |
style: TextStyle( | |
color: CupertinoColors.white, fontSize: 24), | |
), | |
], | |
), | |
) | |
], | |
), | |
), | |
), | |
); | |
} |
Author
mevlanaayas
commented
Sep 28, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment