diff --git a/assets/images/hey.png b/assets/images/hey.png new file mode 100644 index 0000000..caeca23 Binary files /dev/null and b/assets/images/hey.png differ diff --git a/assets/images/login_image.png b/assets/images/login_image.png new file mode 100644 index 0000000..b175b35 Binary files /dev/null and b/assets/images/login_image.png differ diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 97ee771..c4f87eb 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -2,20 +2,26 @@ PODS: - Flutter (1.0.0) - integration_test (0.0.1): - Flutter + - path_provider (0.0.1): + - Flutter DEPENDENCIES: - Flutter (from `Flutter`) - integration_test (from `.symlinks/plugins/integration_test/ios`) + - path_provider (from `.symlinks/plugins/path_provider/ios`) EXTERNAL SOURCES: Flutter: :path: Flutter integration_test: :path: ".symlinks/plugins/integration_test/ios" + path_provider: + :path: ".symlinks/plugins/path_provider/ios" SPEC CHECKSUMS: Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c integration_test: 5ed24a436eb7ec17b6a13046e9bf7ca4a404e59e + path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c diff --git a/lib/main.dart b/lib/main.dart index dda5a28..7ba9441 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,22 +1,31 @@ import 'package:flutter/material.dart'; +import 'package:flutter_catalog/pages/login_page.dart'; +import 'package:flutter_catalog/utils/routes.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'pages/home_page.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { - const MyApp({Key key}) : super(key: key); - @override Widget build(BuildContext context) { return MaterialApp( - home: Material( - child: Center( - child: Container( - child: Text("Welcome to 30 days of flutter"), - ), - ), + themeMode: ThemeMode.light, + theme: ThemeData( + primarySwatch: Colors.deepPurple, + fontFamily: GoogleFonts.lato().fontFamily, + ), + darkTheme: ThemeData( + brightness: Brightness.dark, ), + initialRoute: "/", + routes: { + "/": (context) => LoginPage(), + MyRoutes.homeRoute: (context) => HomePage(), + MyRoutes.loginRoute: (context) => LoginPage() + }, ); } } diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart new file mode 100644 index 0000000..487caed --- /dev/null +++ b/lib/pages/home_page.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; + +class HomePage extends StatelessWidget { + final int days = 30; + final String name = "Codepur"; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text("Catalog App"), + ), + body: Center( + child: Container( + child: Text("Welcome to $days days of flutter by $name"), + ), + ), + drawer: Drawer(), + ); + } +} diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart new file mode 100644 index 0000000..d176d74 --- /dev/null +++ b/lib/pages/login_page.dart @@ -0,0 +1,129 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_catalog/utils/routes.dart'; + +class LoginPage extends StatefulWidget { + @override + _LoginPageState createState() => _LoginPageState(); +} + +class _LoginPageState extends State { + String name = ""; + bool changeButton = false; + + final _formKey = GlobalKey(); + + moveToHome(BuildContext context) async { + if (_formKey.currentState.validate()) { + setState(() { + changeButton = true; + }); + await Future.delayed(Duration(seconds: 1)); + await Navigator.pushNamed(context, MyRoutes.homeRoute); + setState(() { + changeButton = false; + }); + } + } + + @override + Widget build(BuildContext context) { + return Material( + color: Colors.white, + child: SingleChildScrollView( + child: Form( + key: _formKey, + child: Column( + children: [ + Image.asset( + "assets/images/hey.png", + fit: BoxFit.cover, + ), + SizedBox( + height: 20.0, + ), + Text( + "Welcome $name", + style: TextStyle( + fontSize: 28, + fontWeight: FontWeight.bold, + ), + ), + SizedBox( + height: 20.0, + ), + Padding( + padding: const EdgeInsets.symmetric( + vertical: 16.0, horizontal: 32.0), + child: Column( + children: [ + TextFormField( + decoration: InputDecoration( + hintText: "Enter username", + labelText: "Username", + ), + validator: (value) { + if (value.isEmpty) { + return "Username cannot be empty"; + } + + return null; + }, + onChanged: (value) { + name = value; + setState(() {}); + }, + ), + TextFormField( + obscureText: true, + decoration: InputDecoration( + hintText: "Enter password", + labelText: "Password", + ), + validator: (value) { + if (value.isEmpty) { + return "Password cannot be empty"; + } else if (value.length < 6) { + return "Password length should be atleast 6"; + } + + return null; + }, + ), + SizedBox( + height: 40.0, + ), + Material( + color: Colors.deepPurple, + borderRadius: + BorderRadius.circular(changeButton ? 50 : 8), + child: InkWell( + onTap: () => moveToHome(context), + child: AnimatedContainer( + duration: Duration(seconds: 1), + width: changeButton ? 50 : 150, + height: 50, + alignment: Alignment.center, + child: changeButton + ? Icon( + Icons.done, + color: Colors.white, + ) + : Text( + "Login", + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 18), + ), + ), + ), + ), + ], + ), + ) + ], + ), + ), + )); + } +} diff --git a/lib/utils/routes.dart b/lib/utils/routes.dart new file mode 100644 index 0000000..510c16a --- /dev/null +++ b/lib/utils/routes.dart @@ -0,0 +1,4 @@ +class MyRoutes { + static String loginRoute = "/login"; + static String homeRoute = "/home"; +} diff --git a/pubspec.lock b/pubspec.lock index 62bef60..479a041 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -113,6 +113,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0-nullsafety.3" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" file: dependency: transitive description: @@ -147,6 +154,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + google_fonts: + dependency: "direct main" + description: + name: google_fonts + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.2" + http: + dependency: transitive + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.2" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.4" integration_test: dependency: "direct dev" description: flutter @@ -222,6 +250,41 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0-nullsafety.3" + path_provider: + dependency: transitive + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "1.6.27" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.1+2" + path_provider_macos: + dependency: transitive + description: + name: path_provider_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.4+8" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.4+3" pedantic: dependency: transitive description: @@ -236,6 +299,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.0.0-nullsafety.4" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" pool: dependency: transitive description: @@ -374,6 +444,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.2" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.4+1" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2" yaml: dependency: transitive description: @@ -383,3 +467,4 @@ packages: version: "2.2.1" sdks: dart: ">=2.12.0-0.0 <3.0.0" + flutter: ">=1.17.0 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 8efae22..baebcf5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -27,6 +27,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.1 + google_fonts: ^1.1.2 dev_dependencies: flutter_test: @@ -45,8 +46,8 @@ flutter: uses-material-design: true # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg + assets: + - assets/images/ # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see