main.dart 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import 'package:flutter/material.dart';
  2. import 'package:go_router/go_router.dart';
  3. import 'package:namer_app/list.dart';
  4. import 'package:namer_app/login.dart';
  5. void main() {
  6. runApp(MyApp());
  7. }
  8. final _router = GoRouter(
  9. routes: [
  10. GoRoute(path: '/', builder: (context, state) => MyHomePage(), //),
  11. routes: [
  12. GoRoute(
  13. path: 'login',
  14. builder: (context, state) => LoginPage(),
  15. ),
  16. GoRoute(
  17. path: 'list',
  18. builder: (context, state) => ListPage(),
  19. ),
  20. ]),
  21. ],
  22. );
  23. class MyApp extends StatelessWidget {
  24. const MyApp({super.key});
  25. @override
  26. Widget build(BuildContext context) {
  27. return MaterialApp.router(
  28. title: 'TelNow Lat',
  29. theme: ThemeData(
  30. useMaterial3: true,
  31. colorScheme:
  32. ColorScheme.fromSeed(seedColor: Color.fromARGB(255, 0, 255, 255)),
  33. ),
  34. routerConfig: _router,
  35. );
  36. }
  37. }
  38. class MyHomePage extends StatelessWidget {
  39. @override
  40. Widget build(BuildContext context) {
  41. return Scaffold(
  42. backgroundColor: Theme.of(context).colorScheme.primaryContainer,
  43. body: Column(
  44. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  45. children: [
  46. Lang(),
  47. Expanded(
  48. child: Center(
  49. child: Text(
  50. 'TelNow',
  51. style: TextStyle(color: Colors.orange, fontSize: 48),
  52. )),
  53. ),
  54. Padding(
  55. padding: const EdgeInsets.only(left: 120, right: 120),
  56. child: Text(
  57. 'Silakan pindai QR terlebih dulu untuk mulai menggunakan aplikasi.',
  58. softWrap: true,
  59. textAlign: TextAlign.center,
  60. ),
  61. ),
  62. Expanded(
  63. child: Center(child: Pindai()),
  64. ),
  65. Text('Kebijakan Privasi'),
  66. Text('Versi 4.0.0.0'),
  67. Container(
  68. color: Theme.of(context).colorScheme.primaryContainer,
  69. )
  70. ],
  71. ),
  72. );
  73. }
  74. }
  75. class Lang extends StatefulWidget {
  76. const Lang({
  77. Key? key,
  78. }) : super(key: key);
  79. @override
  80. State<Lang> createState() => _LangState();
  81. }
  82. class _LangState extends State<Lang> {
  83. var selectedIndex = 0;
  84. @override
  85. Widget build(BuildContext context) {
  86. return Padding(
  87. padding: const EdgeInsets.all(8.0),
  88. child: Row(
  89. children: [
  90. Expanded(child: Container()),
  91. ElevatedButton(
  92. onPressed: () {
  93. print('EN');
  94. },
  95. style: ButtonStyle(
  96. foregroundColor: MaterialStateProperty.all<Color>(Colors.white),
  97. backgroundColor:
  98. MaterialStateProperty.all<Color>(Colors.white70),
  99. shape: MaterialStateProperty.all<RoundedRectangleBorder>(
  100. RoundedRectangleBorder(
  101. borderRadius: BorderRadius.only(
  102. topLeft: Radius.circular(20),
  103. bottomLeft: Radius.circular(20)),
  104. ))),
  105. child: Text('EN'),
  106. ),
  107. ElevatedButton(
  108. onPressed: () {
  109. print('ID');
  110. },
  111. style: ButtonStyle(
  112. foregroundColor:
  113. MaterialStateProperty.all<Color>(Colors.white),
  114. backgroundColor: MaterialStateProperty.all<Color>(Colors.red),
  115. shape: MaterialStateProperty.all<RoundedRectangleBorder>(
  116. RoundedRectangleBorder(
  117. borderRadius: BorderRadius.only(
  118. topRight: Radius.circular(20),
  119. bottomRight: Radius.circular(20)),
  120. side: BorderSide(color: Colors.red),
  121. ))),
  122. child: Text('ID'))
  123. ],
  124. ),
  125. );
  126. }
  127. }
  128. class Pindai extends StatelessWidget {
  129. const Pindai({
  130. Key? key,
  131. }) : super(key: key);
  132. @override
  133. Widget build(BuildContext context) {
  134. return Expanded(
  135. child: Center(
  136. child: ElevatedButton(
  137. onPressed: () => context.go('/login'),
  138. style: ButtonStyle(
  139. padding: MaterialStateProperty.all<EdgeInsets>(EdgeInsets.all(50)),
  140. foregroundColor: MaterialStateProperty.all<Color>(Colors.black),
  141. shape: MaterialStateProperty.all<RoundedRectangleBorder>(
  142. RoundedRectangleBorder(
  143. borderRadius: BorderRadius.circular(18.0),
  144. ))),
  145. child: Text('Pindai QR'),
  146. )),
  147. );
  148. }
  149. }