From a49fae40d867709f1845fa2a9ce133f5ca7cba55 Mon Sep 17 00:00:00 2001 From: adamlindroth Date: Mon, 9 May 2022 14:14:33 +0200 Subject: [PATCH 1/3] Skapade LoginPage --- lib/LoginPage.dart | 171 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 lib/LoginPage.dart diff --git a/lib/LoginPage.dart b/lib/LoginPage.dart new file mode 100644 index 0000000..95d8061 --- /dev/null +++ b/lib/LoginPage.dart @@ -0,0 +1,171 @@ +// ignore_for_file: prefer_const_constructors + +import 'package:flutter/material.dart'; +import 'package:flutter_applicationdemo/BottomNavPage.dart'; + +import 'package:flutter_applicationdemo/HomePage.dart'; +import 'package:flutter_signin_button/flutter_signin_button.dart'; + +class LoginPage extends StatefulWidget { + _LoginPageState createState() => _LoginPageState(); +} + +class _LoginPageState extends State { + Color pinkBackgroundColor = const Color.fromARGB(255, 240, 229, 229); + Color textColor = const Color.fromARGB(255, 79, 98, 114); + @override + Widget build(BuildContext context) { + Size size = MediaQuery.of(context).size; + + return Scaffold( + backgroundColor: pinkBackgroundColor, + body: SafeArea( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + createBackButton(), + createTitleText(), + Text( + "Create Log in:", + style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold), + ), + createUsernameField(), + createEmailField(), + createPasswordField(), + createCreateAccountButton(), + Text("or"), + createGoogleButton(), + Padding( + padding: EdgeInsets.only(top: 100), + child: createContinueWithoutLoggingInButton(), + ), + ], + ), + ), + ); + } + + SignInButton createGoogleButton() { + return SignInButton(Buttons.Google, onPressed: () {}); + } + + Text createTitleText() { + return Text( + 'Sun Chasers', + style: TextStyle( + fontSize: 50, + color: textColor, + fontFamily: 'Sacramento', + shadows: const [ + Shadow( + offset: Offset(2, 2), + blurRadius: 10.0, + color: Color.fromARGB(255, 0, 0, 0), + ), + ], + ), + ); + } + + InputField createUsernameField() { + return InputField( + text: "Username:", isPassword: false, icon: Icon(Icons.person)); + } + + InputField createEmailField() { + return InputField( + text: "Email:", isPassword: false, icon: Icon(Icons.email)); + } + + InputField createPasswordField() { + return InputField( + text: "Password:", isPassword: true, icon: Icon(Icons.lock)); + } + + Padding createBackButton() { + return Padding( + padding: EdgeInsets.only(bottom: 20, left: 10), + child: Align( + alignment: Alignment.topLeft, + child: IconButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => HomePage()), + ); + }, + icon: Icon(Icons.arrow_back), + iconSize: 40, + ), + ), + ); + } + + ElevatedButton createCreateAccountButton() { + return ElevatedButton( + onPressed: () {}, + child: Text( + "Create Account", + style: TextStyle(color: Colors.black, fontWeight: FontWeight.w400), + ), + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all(Colors.white), + ), + ); + } + + ElevatedButton createContinueWithoutLoggingInButton() { + return ElevatedButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => BottomNavPage()), + ); + }, + child: Text( + "Continue without logging in", + style: TextStyle(color: Colors.black, fontWeight: FontWeight.w400), + ), + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all(Colors.white), + ), + ); + } +} // _LoginPageState + +class InputField extends StatelessWidget { + final Icon icon; + final String text; + final bool isPassword; + const InputField({ + Key? key, + required this.text, + required this.isPassword, + required this.icon, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + Size size = MediaQuery.of(context).size; + + return Container( + alignment: Alignment.center, + margin: const EdgeInsets.symmetric(vertical: 10, horizontal: 60), + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), + width: size.width * 0.7, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.white, + ), + child: TextField( + obscureText: isPassword, + decoration: InputDecoration( + hintText: text, + icon: icon, + border: InputBorder.none, + ), + ), + ); + } +} -- 2.39.5 From 6626cca0dd7eb907adfb38c225a61eb47e7251b9 Mon Sep 17 00:00:00 2001 From: adamlindroth Date: Mon, 9 May 2022 14:15:58 +0200 Subject: [PATCH 2/3] =?UTF-8?q?Lade=20till=20dependency=20f=C3=B6r=20login?= =?UTF-8?q?=5Fbutton?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pubspec.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pubspec.yaml b/pubspec.yaml index b8de192..09b67aa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,6 +42,8 @@ dependencies: flutter_native_splash: ^2.1.6 settings_ui: ^2.0.2 google_fonts: ^2.3.2 + google_sign_in: ^5.3.0 + flutter_signin_button: ^2.0.0 flutter_native_splash: background_image: assets/images/outdoor.png -- 2.39.5 From c66ef6020fc6efacc2ebd6dcf58e95491f2b90ea Mon Sep 17 00:00:00 2001 From: adamlindroth Date: Mon, 9 May 2022 14:17:47 +0200 Subject: [PATCH 3/3] =?UTF-8?q?Fixade=20onPressed=20p=C3=A5=20sign=20in=20?= =?UTF-8?q?knappen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/HomePage.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/HomePage.dart b/lib/HomePage.dart index 814ae6a..a43d890 100644 --- a/lib/HomePage.dart +++ b/lib/HomePage.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'BottomNavPage.dart'; +import 'package:flutter_applicationdemo/LoginPage.dart'; class HomePage extends StatefulWidget { const HomePage({Key? key}) : super(key: key); @@ -93,7 +94,7 @@ class _HomePageState extends State { onPressed: () { Navigator.push( context, - MaterialPageRoute(builder: (context) => Container()), //Replace Container() with call to Map-page. + MaterialPageRoute(builder: (context) => LoginPage()), //Replace Container() with call to Map-page. ); }, child: const Text('Sign in', -- 2.39.5