Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.32 KB | None | 0 0
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3.  
  4. class ShortcutsClone extends StatelessWidget {
  5. @override
  6. Widget build(BuildContext context) {
  7. final bottomNavigationBar = CupertinoTabBar(
  8. items: const <BottomNavigationBarItem>[
  9. BottomNavigationBarItem(
  10. icon: Icon(CupertinoIcons.collections),
  11. title: Text('Archive'),
  12. ),
  13. BottomNavigationBarItem(
  14. icon: Icon(CupertinoIcons.tag),
  15. title: Text('Gallery'),
  16. ),
  17. ],
  18. );
  19.  
  20. return CupertinoApp(
  21. debugShowCheckedModeBanner: false,
  22. home: CupertinoTabScaffold(
  23. tabBar: bottomNavigationBar,
  24. tabBuilder: (context, i) => CupertinoTabView(
  25. builder: (context) => CupertinoPageScaffold(
  26. child: ShortcutsGridView(),
  27. ),
  28. ),
  29. ),
  30. );
  31. }
  32. }
  33.  
  34. class ShortcutsGridView extends StatelessWidget {
  35. final List<String> _shortcuts = ['One', 'Two', 'Three'];
  36.  
  37. @override
  38. Widget build(BuildContext context) => CustomScrollView(
  39. slivers: <Widget>[
  40. CupertinoSliverNavigationBar(
  41. border: null,
  42. backgroundColor: CupertinoColors.white,
  43. leading: Text(
  44. 'Edit',
  45. style: TextStyle(
  46. fontSize: 20,
  47. fontWeight: FontWeight.w400,
  48. color: CupertinoColors.activeBlue,
  49. ),
  50. ),
  51. trailing: Icon(CupertinoIcons.add),
  52. largeTitle: Text('Archive'),
  53. ),
  54. SliverList(
  55. delegate: SliverChildListDelegate(
  56. [
  57. Padding(
  58. padding: const EdgeInsets.all(16.0),
  59. child: CupertinoTextField(
  60. placeholder: 'Search',
  61. placeholderStyle: TextStyle(
  62. fontWeight: FontWeight.w400,
  63. color: CupertinoColors.inactiveGray),
  64. cursorColor: CupertinoColors.inactiveGray,
  65. prefix: Padding(
  66. padding: const EdgeInsets.only(left: 8.0),
  67. child: Icon(
  68. CupertinoIcons.search,
  69. color: CupertinoColors.inactiveGray,
  70. ),
  71. ),
  72. decoration: BoxDecoration(
  73. color: CupertinoColors.lightBackgroundGray,
  74. borderRadius: BorderRadius.circular(10.0),
  75. ),
  76. ),
  77. ),
  78. ],
  79. ),
  80. ),
  81. SliverGrid(
  82. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  83. crossAxisCount: 2,
  84. childAspectRatio: 1.5,
  85. ),
  86. delegate: SliverChildBuilderDelegate(
  87. (BuildContext context, int index) => ShortcutsGridItem(
  88. name: _shortcuts[index],
  89. ),
  90. childCount: _shortcuts.length,
  91. ),
  92. )
  93. ],
  94. );
  95. }
  96.  
  97. class ShortcutsGridItem extends StatelessWidget {
  98. final String name;
  99.  
  100. const ShortcutsGridItem({this.name});
  101.  
  102. @override
  103. Widget build(BuildContext context) => Padding(
  104. padding: const EdgeInsets.all(8.0),
  105. child: Container(
  106. decoration: BoxDecoration(
  107. borderRadius: BorderRadius.all(
  108. Radius.circular(20),
  109. ),
  110. gradient: LinearGradient(
  111. begin: Alignment.centerLeft,
  112. end: Alignment.centerRight,
  113. stops: [0.1, 0.3, 0.6, 0.9],
  114. colors: [
  115. Colors.pink[400],
  116. Colors.pink[500],
  117. Colors.pink[600],
  118. Colors.pink[700],
  119. ],
  120. ),
  121. ),
  122. child: Padding(
  123. padding: EdgeInsets.all(10.0),
  124. child: Column(
  125. children: <Widget>[
  126. Container(
  127. height: 30,
  128. child: Row(
  129. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  130. children: <Widget>[
  131. Icon(
  132. CupertinoIcons.pen,
  133. color: CupertinoColors.white,
  134. ),
  135. Container(
  136. decoration: BoxDecoration(
  137. color: CupertinoColors.black.withOpacity(0.2),
  138. borderRadius: BorderRadius.circular(20.0),
  139. ),
  140. child: Padding(
  141. padding: const EdgeInsets.all(2.0),
  142. child: Icon(
  143. CupertinoIcons.ellipsis,
  144. color: CupertinoColors.white,
  145. ),
  146. ),
  147. ),
  148. ],
  149. ),
  150. ),
  151. SizedBox(
  152. height: 10,
  153. ),
  154. Container(
  155. height: 30,
  156. child: Row(
  157. children: <Widget>[
  158. Text(
  159. name,
  160. style: TextStyle(
  161. color: CupertinoColors.white, fontSize: 24),
  162. ),
  163. ],
  164. ),
  165. )
  166. ],
  167. ),
  168. ),
  169. ),
  170. );
  171. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement