From 3bd2ba5cbcfd7480a3756377c85c757f4a38d855 Mon Sep 17 00:00:00 2001 From: Reimar Date: Tue, 20 Aug 2024 14:04:40 +0200 Subject: [PATCH] Add login page --- Mobile/lib/login.dart | 41 +++++++++++++++++++++++++++++++++++++++++ Mobile/lib/main.dart | 26 ++++++++------------------ 2 files changed, 49 insertions(+), 18 deletions(-) create mode 100644 Mobile/lib/login.dart diff --git a/Mobile/lib/login.dart b/Mobile/lib/login.dart new file mode 100644 index 0000000..26b35ec --- /dev/null +++ b/Mobile/lib/login.dart @@ -0,0 +1,41 @@ +import 'package:flutter/material.dart'; + +class LoginPage extends StatefulWidget { + const LoginPage({super.key, required this.title}); + + final String title; + + @override + State createState() => _LoginPageState(); +} + +class _LoginPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Theme.of(context).colorScheme.inversePrimary, + title: Text(widget.title), + ), + body: Center( + child: Container( + constraints: const BoxConstraints(minWidth: 100, maxWidth: 400), + child: Column( + children: [ + const SizedBox(height: 80), + const Text('Email'), + const TextField(), + const SizedBox(height: 30), + const Text('Password'), + const TextField(obscureText: true, enableSuggestions: false, autocorrect: false), + const SizedBox(height: 30), + ElevatedButton(child: const Text('Login'), onPressed: () => Navigator.pop(context)), + const SizedBox(height: 10), + TextButton(child: const Text('Registrer konto'), onPressed: () {}) + ] + ) + ) + ) + ); + } +} diff --git a/Mobile/lib/main.dart b/Mobile/lib/main.dart index 6fe965c..18d4079 100644 --- a/Mobile/lib/main.dart +++ b/Mobile/lib/main.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import "package:latlong2/latlong.dart"; +import "login.dart"; void main() { runApp(const MyApp()); @@ -30,10 +31,10 @@ class MyApp extends StatelessWidget { // // This works for code too, not just values: Most code changes can be // tested with just a hot reload. - colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), + colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue), useMaterial3: true, ), - home: const MyHomePage(title: 'H4 med Flutter'), + home: const MyHomePage(title: 'SkanTravels'), ); } } @@ -57,19 +58,6 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - int _counter = 0; - - void _incrementCounter() { - setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. - _counter++; - }); - } - @override Widget build(BuildContext context) { return Scaffold( @@ -90,9 +78,11 @@ class _MyHomePageState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: const Icon(Icons.add), + onPressed: () { + Navigator.push(context, MaterialPageRoute(builder: (context) => const LoginPage(title: "Login"))); + }, + tooltip: 'Login', + child: const Icon(Icons.login), ), ], ),