list.dart 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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: gambar(items[i]),
  65. title: Text(items[i]['type']),
  66. subtitle: Text(
  67. 'Description of ${items[i]['type'].toLowerCase()}'),
  68. trailing: IconDelete(
  69. items: items[i],
  70. ),
  71. ),
  72. )),
  73. ),
  74. Divider(
  75. thickness: 8,
  76. ),
  77. AvailableMenu(),
  78. Column(
  79. children: List.generate(
  80. items.length,
  81. (i) => SizedBox(
  82. child: ListTile(
  83. leading: gambar(items[i]),
  84. title: Text(items[i]['type']),
  85. subtitle: Text(
  86. 'Description of ${items[i]['type'].toLowerCase()}'),
  87. trailing: IconAdd(),
  88. ),
  89. )),
  90. )
  91. ],
  92. ),
  93. ),
  94. ),
  95. ]));
  96. }
  97. Container gambar(items) {
  98. return Container(
  99. decoration: BoxDecoration(
  100. border: Border.all(color: items['color']),
  101. borderRadius: BorderRadius.all(Radius.circular(20)),
  102. color: items['color'].withOpacity(0.4)),
  103. padding: const EdgeInsets.all(5.0),
  104. child: Image.asset(
  105. items['image'],
  106. width: 36,
  107. height: 36,
  108. fit: BoxFit.cover,
  109. ),
  110. );
  111. }
  112. }
  113. class AvailableMenu extends StatelessWidget {
  114. const AvailableMenu({
  115. Key? key,
  116. }) : super(key: key);
  117. @override
  118. Widget build(BuildContext context) {
  119. return Container(
  120. padding: const EdgeInsets.all(5.0),
  121. child: Row(
  122. children: [
  123. Text(
  124. 'Available Menu',
  125. textAlign: TextAlign.left,
  126. style: TextStyle(
  127. fontWeight: FontWeight.bold, color: Color(0xff292D32)),
  128. ),
  129. ],
  130. ),
  131. );
  132. }
  133. }
  134. class TopMenu extends StatelessWidget {
  135. const TopMenu({
  136. Key? key,
  137. }) : super(key: key);
  138. @override
  139. Widget build(BuildContext context) {
  140. return Container(
  141. padding: const EdgeInsets.all(5.0),
  142. child: Row(
  143. children: [
  144. Text(
  145. 'Top Menu',
  146. textAlign: TextAlign.left,
  147. style: TextStyle(
  148. fontWeight: FontWeight.bold, color: Color(0xff292D32)),
  149. ),
  150. Spacer(),
  151. ElevatedButton(
  152. style: ElevatedButton.styleFrom(
  153. backgroundColor: Color(0xff078C84).withOpacity(0.1)),
  154. onPressed: () => context.go('/list/listblock'),
  155. child: Text(
  156. 'Done',
  157. style: TextStyle(
  158. color: Color(0xff078C84), fontWeight: FontWeight.w300),
  159. ))
  160. ],
  161. ),
  162. );
  163. }
  164. }
  165. class IconAdd extends StatelessWidget {
  166. const IconAdd({
  167. Key? key,
  168. }) : super(key: key);
  169. @override
  170. Widget build(BuildContext context) {
  171. return IconButton(
  172. color: Colors.red,
  173. onPressed: () {},
  174. icon: Icon(Icons.add_circle),
  175. );
  176. }
  177. }
  178. class IconDelete extends StatelessWidget {
  179. final Map<String, dynamic> items;
  180. IconDelete({
  181. required this.items,
  182. Key? key,
  183. }) : super(key: key);
  184. @override
  185. Widget build(BuildContext context) {
  186. return Row(
  187. mainAxisSize: MainAxisSize.min,
  188. children: [
  189. IconButton(
  190. icon: Icon(Icons.remove_circle),
  191. color: Colors.red,
  192. onPressed: () {print(items);},
  193. ),
  194. SizedBox(width: 10),
  195. IconButton(
  196. onPressed: () => context.goNamed('detail', queryParams: items),
  197. icon: Icon(Icons.menu),
  198. )
  199. ],
  200. );
  201. }
  202. }