main.dart 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. // ignore_for_file: must_call_super, prefer_typing_uninitialized_variables
  2. import 'package:flutter/material.dart';
  3. import 'package:go_router/go_router.dart';
  4. import 'package:namer_app/bug/addbug.dart';
  5. import 'package:namer_app/platform/addplatform.dart';
  6. import 'package:namer_app/bug/editbug.dart';
  7. import 'package:namer_app/platform/editplatform.dart';
  8. import 'package:namer_app/project/addmember.dart';
  9. import 'package:namer_app/project/addproject.dart';
  10. import 'package:namer_app/project/editproject.dart';
  11. import 'package:namer_app/project/listproject.dart';
  12. import 'package:namer_app/user/chgpass.dart';
  13. import 'package:namer_app/user/edituser.dart';
  14. import 'package:namer_app/footer.dart';
  15. import 'package:namer_app/header.dart';
  16. import 'package:namer_app/bug/listbug.dart';
  17. import 'package:namer_app/bug/listcomment.dart';
  18. import 'package:namer_app/project/listmember.dart';
  19. import 'package:namer_app/platform/listplatform.dart';
  20. import 'package:namer_app/listtable.dart';
  21. import 'package:namer_app/user/listuser.dart';
  22. import 'package:namer_app/login.dart';
  23. import 'package:flutter/rendering.dart';
  24. import 'package:namer_app/user/signup.dart';
  25. import 'bug/addcomment.dart';
  26. void main() {
  27. runApp(MyApp());
  28. }
  29. // @override
  30. // void initState(){
  31. // getData();
  32. // }
  33. // var jsonList;
  34. // void getData() async {
  35. // try {
  36. // var response = await Dio()
  37. // .get('http://localhost:8080/api/v1/projects',
  38. // options: Options(headers: headers));
  39. // if (response.statusCode == 200) {
  40. // setState(() {
  41. // jsonList = response.data['results'] as List;
  42. // });
  43. // } else {
  44. // print(response.statusCode);
  45. // }
  46. // } catch (e) {
  47. // print(e);
  48. // }
  49. // }
  50. // var jsonList;
  51. final _router = GoRouter(
  52. routes: [
  53. GoRoute(path: '/', builder: (context, state) => MyHomePage(), routes: [
  54. GoRoute(path: 'login', builder: (context, state) => LoginPage(), routes: [
  55. GoRoute(
  56. path: 'bug',
  57. builder: (context, state) => ListBugPage(),
  58. routes: [
  59. GoRoute(
  60. path: 'comment',
  61. builder: (context, state) => ListCommentPage(bugId: 1,),
  62. ),
  63. GoRoute(
  64. path: 'editbug',
  65. builder: (context, state) => EditBugPage(),
  66. )
  67. ])
  68. ]),
  69. GoRoute(
  70. path: 'signup',
  71. builder: (context, state) => SignupPage(),
  72. routes: [
  73. GoRoute(
  74. path: 'listuser',
  75. builder: (context, state) => ListUserPage(),
  76. routes: [
  77. GoRoute(
  78. path: 'edit/:id',
  79. builder: (context, state) {
  80. // var item = jsonList.firstWhere(
  81. // (element) => element('id') == state.pathParameters['id']);
  82. // return EditUserPage(json: item);
  83. return EditUserPage(json: null);
  84. })
  85. ])
  86. ]),
  87. GoRoute(
  88. path: 'maintenance',
  89. builder: (context, state) => ListTablePage(),
  90. ),
  91. GoRoute(
  92. path: 'listplatform',
  93. builder: (context, state) => ListPlatformPage(),
  94. routes: [
  95. GoRoute(
  96. path: 'listmember',
  97. builder: (context, state) => ListMemberPage(projId: 1,),
  98. ),
  99. GoRoute(
  100. path: 'editplatform',
  101. builder: (context, state) => EditPlatformPage(),
  102. )
  103. ]),
  104. GoRoute(
  105. path: 'addbug',
  106. builder: (context, state) => AddBugPage(),
  107. ),
  108. GoRoute(
  109. path: 'addplatform',
  110. builder: (context, state) => AddPlatformPage(),
  111. ),
  112. GoRoute(path: 'listproject',
  113. builder: (context, state) => ListProjectPage(),
  114. ),
  115. GoRoute(path: 'addproject',
  116. builder: (context, state) => AddProjectPage(),
  117. ),
  118. GoRoute(path: 'editproject',
  119. builder: (context, state) => EditProjectPage(),
  120. ),
  121. GoRoute(path: 'addmember',
  122. builder: (context, state) => AddMemberPage(projId: 1),
  123. ),
  124. GoRoute(path: 'changepass',
  125. builder: (context, state) => ChangepassPage(), ),
  126. GoRoute(path: 'addcomment',
  127. builder: (context, state) => AddCommentPage(/*bugId: 1*/),),
  128. ]),
  129. ],
  130. );
  131. class MyApp extends StatelessWidget {
  132. const MyApp({super.key});
  133. @override
  134. Widget build(BuildContext context) {
  135. return MaterialApp.router(
  136. debugShowCheckedModeBanner: false,
  137. title: 'Bug Listing',
  138. routerConfig: _router,
  139. );
  140. }
  141. }
  142. class MyHomePage extends StatelessWidget {
  143. @override
  144. Widget build(BuildContext context) {
  145. debugPaintSizeEnabled = false;
  146. return Scaffold(
  147. appBar: CustomAppbar(),
  148. body: Container(
  149. decoration: BoxDecoration(color: Colors.black.withOpacity(0.6)),
  150. child: Column(
  151. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  152. children: [
  153. Expanded(
  154. child: Center(
  155. child: Row(
  156. mainAxisAlignment: MainAxisAlignment.center,
  157. children: [
  158. Text(
  159. 'Welcome to Bug Tracker',
  160. style: TextStyle(
  161. color: Colors.white,
  162. fontSize: 40,
  163. fontWeight: FontWeight.bold),
  164. ),
  165. ],
  166. )),
  167. ),
  168. Padding(
  169. padding: const EdgeInsets.all(8.0),
  170. child: Text(
  171. 'Track, manage, and resolve bugs efficiently',
  172. style: TextStyle(color: Colors.white, fontSize: 16),
  173. ),
  174. ),
  175. Row(
  176. mainAxisAlignment: MainAxisAlignment.center,
  177. children: [
  178. Padding(
  179. padding: const EdgeInsets.symmetric(horizontal: 10),
  180. child: ElevatedButton(
  181. onPressed: () => context.go('/signup'),
  182. style: ElevatedButton.styleFrom(
  183. side: BorderSide(color: Colors.white),
  184. backgroundColor: Colors.transparent),
  185. child: Text(
  186. 'Sign Up',
  187. style: TextStyle(color: Colors.white),
  188. ),
  189. ),
  190. ),
  191. Padding(
  192. padding: const EdgeInsets.symmetric(horizontal: 10),
  193. child: ElevatedButton(
  194. onPressed: () => context.go('/login'),
  195. style: ElevatedButton.styleFrom(
  196. backgroundColor: Colors.black,
  197. ),
  198. child: Text(
  199. 'Login',
  200. style: TextStyle(color: Colors.white),
  201. ),
  202. ),
  203. ),
  204. ],
  205. ),
  206. Expanded(child: Container())
  207. ],
  208. ),
  209. ),
  210. bottomNavigationBar: Footer());
  211. }
  212. }