athrainsky vor 2 Jahren
Ursprung
Commit
85b2617c06
3 geänderte Dateien mit 194 neuen und 107 gelöschten Zeilen
  1. 12 0
      lib/list.dart
  2. 110 15
      lib/login.dart
  3. 72 92
      lib/main.dart

+ 12 - 0
lib/list.dart

@@ -0,0 +1,12 @@
+import 'package:flutter/material.dart';
+
+class ListPage extends StatelessWidget {
+  const ListPage({Key? key}) : super(key: key);
+
+  @override
+  Widget build(BuildContext context) {
+    return Scaffold(
+        backgroundColor: Theme.of(context).colorScheme.primaryContainer,
+        body: Column());
+  }
+}

+ 110 - 15
lib/login.dart

@@ -1,24 +1,119 @@
 import 'package:flutter/material.dart';
+import 'package:go_router/go_router.dart';
 
-class Login extends StatelessWidget {
-  /// Constructs a [DetailsScreen]
-  const Login({Key? key}) : super(key: key);
+class LoginPage extends StatelessWidget {
+  const LoginPage({Key? key}) : super(key: key);
 
   @override
   Widget build(BuildContext context) {
     return Scaffold(
-      appBar: AppBar(title: const Text('Details Screen')),
-      body: Center(
-        child: Column(
-          mainAxisAlignment: MainAxisAlignment.center,
-          children: <ElevatedButton>[
-            ElevatedButton(
-              onPressed: () {print('x');},
-              child: const Text('Go back to the Home screen'),
-            ),
-          ],
-        ),
+      backgroundColor: Theme.of(context).colorScheme.primaryContainer,
+      body: Column(
+        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
+        children: [
+          Lang(),
+          Expanded(
+            child: Center(
+                child: Text(
+              'TelNow',
+              style: TextStyle(color: Colors.orange, fontSize: 48),
+            )),
+          ),
+          Expanded(
+              child: Column(
+            children: [
+              Padding(
+                padding: const EdgeInsets.all(8.0),
+                child: TextField(
+                  decoration: InputDecoration(
+                    border: OutlineInputBorder(),
+                    labelText: 'Nama Pengguna',
+                  ),
+                ),
+              ),
+              Padding(
+                padding: const EdgeInsets.all(8.0),
+                child: TextField(
+                  obscureText: true,
+                  decoration: InputDecoration(
+                    border: OutlineInputBorder(),
+                    labelText: 'Kata Sandi',
+                  ),
+                ),
+              ),
+              Container(),
+              Padding(
+                padding: const EdgeInsets.all(8.0),
+                child: ElevatedButton(
+                    onPressed: () => context.go('/list'), child: Text('Masuk')),
+              )
+            ],
+          )),
+          Text('Kebijakan Privasi'),
+          Text('Versi 4.0.0.0'),
+          Container(
+            color: Theme.of(context).colorScheme.primaryContainer,
+          )
+        ],
       ),
     );
   }
-}
+}
+
+class Lang extends StatefulWidget {
+  const Lang({
+    Key? key,
+  }) : super(key: key);
+
+  @override
+  State<Lang> createState() => _LangState();
+}
+
+class _LangState extends State<Lang> {
+  var selectedIndex = 0;
+
+  @override
+  Widget build(BuildContext context) {
+    return Padding(
+      padding: const EdgeInsets.all(8.0),
+      child: Row(
+        children: [
+          Expanded(child: Container()),
+          ElevatedButton(
+            onPressed: () {
+              print('EN');
+            },
+            style: ButtonStyle(
+                foregroundColor: MaterialStateProperty.all<Color>(Colors.white),
+                backgroundColor:
+                    MaterialStateProperty.all<Color>(Colors.white70),
+                shape: MaterialStateProperty.all<RoundedRectangleBorder>(
+                    RoundedRectangleBorder(
+                  borderRadius: BorderRadius.only(
+                      topLeft: Radius.circular(20),
+                      bottomLeft: Radius.circular(20)),
+                  //side: BorderSide(color: Colors.red),
+                ))),
+            child: Text('EN'),
+          ),
+          ElevatedButton(
+              onPressed: () {
+                print('ID');
+              },
+              style: ButtonStyle(
+                  foregroundColor:
+                      MaterialStateProperty.all<Color>(Colors.white),
+                  backgroundColor: MaterialStateProperty.all<Color>(Colors.red),
+                  shape: MaterialStateProperty.all<RoundedRectangleBorder>(
+                      RoundedRectangleBorder(
+                    borderRadius: BorderRadius.only(
+                        topRight: Radius.circular(20),
+                        bottomRight: Radius.circular(20)),
+                    side: BorderSide(color: Colors.red),
+                  ))),
+              child: Text('ID'))
+        ],
+      ),
+    );
+  }
+}

+ 72 - 92
lib/main.dart

@@ -1,5 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:go_router/go_router.dart';
+import 'package:namer_app/list.dart';
 import 'package:namer_app/login.dart';
 
 void main() {
@@ -8,15 +9,17 @@ void main() {
 
 final _router = GoRouter(
   routes: [
-    GoRoute(
-      path: '/',
-      builder: (context, state) => MyHomePage(),
-      routes: [
-        GoRoute(
-          path: '/login',
-          builder: (context, state) => const Login(),)
-      ]
-    ),
+    GoRoute(path: '/', builder: (context, state) => MyHomePage(), //),
+        routes: [
+          GoRoute(
+            path: 'login',
+            builder: (context, state) => LoginPage(),
+          ),
+          GoRoute(
+            path: 'list',
+            builder: (context, state) => ListPage(),
+          ),
+        ]),
   ],
 );
 
@@ -26,22 +29,21 @@ class MyApp extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return MaterialApp.router(
-        title: 'TelNow Lat',
-        theme: ThemeData(
-          useMaterial3: true,
-          colorScheme: ColorScheme.fromSeed(seedColor: Color.fromARGB(255, 0, 255, 255)),
-        ),
-        // home: MyHomePage(),
-        routerConfig: _router,
+      title: 'TelNow Lat',
+      theme: ThemeData(
+        useMaterial3: true,
+        colorScheme:
+            ColorScheme.fromSeed(seedColor: Color.fromARGB(255, 0, 255, 255)),
+      ),
+      // home: MyHomePage(),
+      routerConfig: _router,
     );
-    
   }
 }
 
 class MyHomePage extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
-    
     return Scaffold(
       backgroundColor: Theme.of(context).colorScheme.primaryContainer,
       body: Column(
@@ -50,21 +52,21 @@ class MyHomePage extends StatelessWidget {
           Lang(),
           Expanded(
             child: Center(
-              child: Text('TelNow', 
-              style: TextStyle(color: Colors.orange,
-                fontSize: 48),
-              )
-            ),
+                child: Text(
+              'TelNow',
+              style: TextStyle(color: Colors.orange, fontSize: 48),
+            )),
           ),
           Padding(
             padding: const EdgeInsets.only(left: 120, right: 120),
-            child: Text('Silakan pindai QR terlebih dulu untuk mulai menggunakan aplikasi.', 
-            softWrap: true,
-            textAlign: TextAlign.center,
+            child: Text(
+              'Silakan pindai QR terlebih dulu untuk mulai menggunakan aplikasi.',
+              softWrap: true,
+              textAlign: TextAlign.center,
             ),
           ),
-          Expanded(child:
-                Center(child: Pindai()),
+          Expanded(
+            child: Center(child: Pindai()),
           ),
           Text('Kebijakan Privasi'),
           Text('Versi 4.0.0.0'),
@@ -87,46 +89,49 @@ class Lang extends StatefulWidget {
 }
 
 class _LangState extends State<Lang> {
-
-var selectedIndex = 0;
+  var selectedIndex = 0;
 
   @override
   Widget build(BuildContext context) {
     return Padding(
       padding: const EdgeInsets.all(8.0),
-      child: Row(            
+      child: Row(
         children: [
           Expanded(child: Container()),
-          ElevatedButton
-            (onPressed: (){print('EN');},
-              style: ButtonStyle(
+          ElevatedButton(
+            onPressed: () {
+              print('EN');
+            },
+            style: ButtonStyle(
                 foregroundColor: MaterialStateProperty.all<Color>(Colors.white),
-                backgroundColor: MaterialStateProperty.all<Color>(Colors.white70),
+                backgroundColor:
+                    MaterialStateProperty.all<Color>(Colors.white70),
                 shape: MaterialStateProperty.all<RoundedRectangleBorder>(
-                  RoundedRectangleBorder(
-                    borderRadius: BorderRadius.only(topLeft: Radius.circular(20), bottomLeft: Radius.circular(20)),
-                    //side: BorderSide(color: Colors.red),
-                    
-                  )
-                )
-              ), 
-              child: Text('EN'),
+                    RoundedRectangleBorder(
+                  borderRadius: BorderRadius.only(
+                      topLeft: Radius.circular(20),
+                      bottomLeft: Radius.circular(20)),
+                  //side: BorderSide(color: Colors.red),
+                ))),
+            child: Text('EN'),
           ),
-          ElevatedButton
-            (onPressed: (){print('ID');}, 
+          ElevatedButton(
+              onPressed: () {
+                print('ID');
+              },
               style: ButtonStyle(
-                  foregroundColor: MaterialStateProperty.all<Color>(Colors.white),
+                  foregroundColor:
+                      MaterialStateProperty.all<Color>(Colors.white),
                   backgroundColor: MaterialStateProperty.all<Color>(Colors.red),
                   shape: MaterialStateProperty.all<RoundedRectangleBorder>(
-                    RoundedRectangleBorder(
-                      borderRadius: BorderRadius.only(topRight: Radius.circular(20), bottomRight: Radius.circular(20)),
-                      side: BorderSide(color: Colors.red),
-                      
-                    )
-                  )
-                ),
+                      RoundedRectangleBorder(
+                    borderRadius: BorderRadius.only(
+                        topRight: Radius.circular(20),
+                        bottomRight: Radius.circular(20)),
+                    side: BorderSide(color: Colors.red),
+                  ))),
               child: Text('ID'))
-        ],        
+        ],
       ),
     );
   }
@@ -160,21 +165,19 @@ class Pindai extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return Expanded(
-            child: Center(
-              child: ElevatedButton(
-                onPressed: () => context.go('/login'),
-                style: ButtonStyle(
-                  padding: MaterialStateProperty.all<EdgeInsets>(EdgeInsets.all(50)),
-                  foregroundColor: MaterialStateProperty.all<Color>(Colors.black),
-                  shape: MaterialStateProperty.all<RoundedRectangleBorder>(
-                    RoundedRectangleBorder(
-                      borderRadius: BorderRadius.circular(18.0),
-                    )
-                  )
-                ),
-                child: Text('Pindai QR'),)
-            ),
-          );
+      child: Center(
+          child: ElevatedButton(
+        onPressed: () => context.go('/login'),
+        style: ButtonStyle(
+            padding: MaterialStateProperty.all<EdgeInsets>(EdgeInsets.all(50)),
+            foregroundColor: MaterialStateProperty.all<Color>(Colors.black),
+            shape: MaterialStateProperty.all<RoundedRectangleBorder>(
+                RoundedRectangleBorder(
+              borderRadius: BorderRadius.circular(18.0),
+            ))),
+        child: Text('Pindai QR'),
+      )),
+    );
   }
 }
 
@@ -193,26 +196,3 @@ class Pindai extends StatelessWidget {
 //     );
 //   }
 // }
-
-// class Login extends StatelessWidget {
-//   /// Constructs a [DetailsScreen]
-//   const Login({Key? key}) : super(key: key);
-
-//   @override
-//   Widget build(BuildContext context) {
-//     return Scaffold(
-//       appBar: AppBar(title: const Text('Details Screen')),
-//       body: Center(
-//         child: Column(
-//           mainAxisAlignment: MainAxisAlignment.center,
-//           children: <ElevatedButton>[
-//             ElevatedButton(
-//               onPressed: () {print('x');},
-//               child: const Text('Go back to the Home screen'),
-//             ),
-//           ],
-//         ),
-//       ),
-//     );
-//   }
-// }