list.dart 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. import 'package:flutter/material.dart';
  2. import 'package:go_router/go_router.dart';
  3. import 'package:namer_app/data.dart';
  4. import 'package:date_format/date_format.dart';
  5. var date = formatDate(DateTime.now(), [HH, ':', nn]);
  6. class ListPage extends StatelessWidget {
  7. const ListPage({Key? key}) : super(key: key);
  8. @override
  9. Widget build(BuildContext context) {
  10. return Scaffold(
  11. appBar: AppBar(
  12. backgroundColor: Color(0xff078C84),
  13. automaticallyImplyLeading: false,
  14. elevation: 0,
  15. toolbarHeight: 44,
  16. title: Text(
  17. date,
  18. style: TextStyle(color: Colors.white, fontSize: 15),
  19. ),
  20. actions: [
  21. Icon(
  22. Icons.signal_cellular_alt,
  23. color: Colors.white,
  24. ),
  25. Icon(
  26. Icons.wifi,
  27. color: Colors.white,
  28. ),
  29. RotatedBox(
  30. quarterTurns: -3,
  31. child: Icon(
  32. Icons.battery_std,
  33. color: Colors.white,
  34. ),
  35. )
  36. ],
  37. ),
  38. body: Stack(children: [
  39. Container(
  40. decoration: BoxDecoration(color: Color(0xff078C84)),
  41. ),
  42. SingleChildScrollView(
  43. child: Container(
  44. decoration: BoxDecoration(
  45. color: Colors.white,
  46. borderRadius: BorderRadius.only(
  47. topLeft: Radius.circular(16),
  48. topRight: Radius.circular(16)),
  49. border: Border.all(color: Color(0xff078C84))),
  50. child: Column(
  51. children: [
  52. Container(
  53. margin: EdgeInsets.symmetric(vertical: 5),
  54. color: Color(0xff292D32).withOpacity(0.15),
  55. height: 1,
  56. width: 24,
  57. ),
  58. TopMenu(),
  59. Column(
  60. children: List.generate(
  61. 7,
  62. (i) => SizedBox(
  63. child: ListTile(
  64. leading: SizedBox(
  65. width: 60,
  66. height: 60,
  67. child: gambar(items[i]),
  68. ),
  69. title: Text(items[i]['type']),
  70. subtitle: Text(
  71. 'Description of ${items[i]['type'].toLowerCase()}'),
  72. trailing: IconDelete(
  73. items: items[i],
  74. ),
  75. ),
  76. )),
  77. ),
  78. Divider(
  79. thickness: 8,
  80. ),
  81. AvailableMenu(),
  82. Column(
  83. children: List.generate(
  84. items.length,
  85. (i) => SizedBox(
  86. child: ListTile(
  87. leading: SizedBox(
  88. width: 60,
  89. height: 60,
  90. child: gambar(items[i]),
  91. ),
  92. title: Text(items[i]['type']),
  93. subtitle: Text(
  94. 'Description of ${items[i]['type'].toLowerCase()}'),
  95. trailing: IconAdd(),
  96. ),
  97. )),
  98. )
  99. ],
  100. ),
  101. ),
  102. ),
  103. ]));
  104. }
  105. Container gambar(items) {
  106. return Container(
  107. decoration: BoxDecoration(
  108. border: Border.all(color: items['color']),
  109. borderRadius: BorderRadius.all(Radius.circular(20)),
  110. color: items['color'].withOpacity(0.4)),
  111. padding: const EdgeInsets.all(5.0),
  112. child: Image.asset(
  113. items['image'],
  114. fit: BoxFit.cover,
  115. ),
  116. );
  117. }
  118. }
  119. class AvailableMenu extends StatelessWidget {
  120. const AvailableMenu({
  121. Key? key,
  122. }) : super(key: key);
  123. @override
  124. Widget build(BuildContext context) {
  125. return Container(
  126. padding: const EdgeInsets.all(5.0),
  127. child: Row(
  128. children: [
  129. Text(
  130. 'Available Menu',
  131. textAlign: TextAlign.left,
  132. style: TextStyle(
  133. fontWeight: FontWeight.bold, color: Color(0xff292D32)),
  134. ),
  135. ],
  136. ),
  137. );
  138. }
  139. }
  140. class TopMenu extends StatelessWidget {
  141. const TopMenu({
  142. Key? key,
  143. }) : super(key: key);
  144. @override
  145. Widget build(BuildContext context) {
  146. return Container(
  147. padding: const EdgeInsets.all(5.0),
  148. child: Row(
  149. children: [
  150. Text(
  151. 'Top Menu',
  152. textAlign: TextAlign.left,
  153. style: TextStyle(
  154. fontWeight: FontWeight.bold, color: Color(0xff292D32)),
  155. ),
  156. Spacer(),
  157. ElevatedButton(
  158. style: ElevatedButton.styleFrom(
  159. backgroundColor: Color(0xff078C84).withOpacity(0.1)),
  160. onPressed: () => context.go('/list/listblock'),
  161. child: Text(
  162. 'Done',
  163. style: TextStyle(
  164. color: Color(0xff078C84), fontWeight: FontWeight.w300),
  165. ))
  166. ],
  167. ),
  168. );
  169. }
  170. }
  171. class IconAdd extends StatelessWidget {
  172. const IconAdd({
  173. Key? key,
  174. }) : super(key: key);
  175. @override
  176. Widget build(BuildContext context) {
  177. return IconButton(
  178. color: Colors.red,
  179. onPressed: () {},
  180. icon: Icon(Icons.add_circle),
  181. );
  182. }
  183. }
  184. class IconDelete extends StatelessWidget {
  185. final Map<String, dynamic> items;
  186. IconDelete({
  187. required this.items,
  188. Key? key,
  189. }) : super(key: key);
  190. @override
  191. Widget build(BuildContext context) {
  192. return Row(
  193. mainAxisSize: MainAxisSize.min,
  194. children: [
  195. IconButton(
  196. icon: Icon(Icons.remove_circle),
  197. color: Colors.red,
  198. onPressed: () {
  199. print(items);
  200. },
  201. ),
  202. SizedBox(width: 10),
  203. IconButton(
  204. onPressed: () => context.go("/list/detail/${items['type']}"),
  205. icon: Icon(Icons.menu),
  206. )
  207. ],
  208. );
  209. }
  210. }