From f1c1523bb811054ea52a1b681e3b1e082500ddd0 Mon Sep 17 00:00:00 2001 From: Aryaman Godara Date: Tue, 5 Oct 2021 11:38:34 +0530 Subject: [PATCH] theme data added --- lib/control.dart | 101 ++++++++++++++++++++++++----------------------- lib/login.dart | 62 +++++++++++++++-------------- lib/main.dart | 13 ++++-- lib/splash.dart | 1 - 4 files changed, 93 insertions(+), 84 deletions(-) diff --git a/lib/control.dart b/lib/control.dart index bad8ea5..6daffdd 100644 --- a/lib/control.dart +++ b/lib/control.dart @@ -10,62 +10,63 @@ class _ControlState extends State { Widget build(BuildContext context) { return MaterialApp( home: Scaffold( - appBar: AppBar( - title: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Home page", - ), - TextButton.icon( - label: Text("Exit"), - icon: Icon( - Icons.exit_to_app, - color: Colors.white, - ), - onPressed: () { - Navigator.pop(context); - }, - ) - ], - ), - ), - backgroundColor: Colors.white, - body: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - mainAxisAlignment: MainAxisAlignment.center, + appBar: AppBar( + title: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Icon( - Icons.home, - size: 250.0, - color: Colors.grey, - ), Text( - 'HOME', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 40.0, - color: Colors.grey, - ), + "Home page", ), + TextButton.icon( + label: Text("Exit"), + icon: Icon( + Icons.exit_to_app, + color: Colors.white, + ), + onPressed: () { + Navigator.pop(context); + }, + ) ], ), - bottomNavigationBar: BottomNavigationBar( - items: const [ - BottomNavigationBarItem( - icon: Icon(Icons.home), - label: 'Home', - ), - BottomNavigationBarItem( - icon: Icon(Icons.business), - label: 'Business', - ), - BottomNavigationBarItem( - icon: Icon(Icons.school), - label: 'School', + ), + backgroundColor: Colors.white, + body: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.home, + size: 250.0, + color: Colors.grey, + ), + Text( + 'Home', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 40.0, + color: Colors.grey, ), - ], - )), + ), + ], + ), + bottomNavigationBar: BottomNavigationBar( + items: const [ + BottomNavigationBarItem( + icon: Icon(Icons.home), + label: 'Home', + ), + BottomNavigationBarItem( + icon: Icon(Icons.business), + label: 'Business', + ), + BottomNavigationBarItem( + icon: Icon(Icons.school), + label: 'School', + ), + ], + ), + ), ); } } diff --git a/lib/login.dart b/lib/login.dart index 5b73377..0d918d5 100644 --- a/lib/login.dart +++ b/lib/login.dart @@ -16,7 +16,6 @@ class _LoginState extends State { Widget build(BuildContext context) { return MaterialApp( home: Scaffold( - backgroundColor: Colors.blue, appBar: AppBar( title: Text("Login page"), ), @@ -43,36 +42,41 @@ class _LoginState extends State { obscureText: true, //text hiding ), SizedBox(height: 45.0), - TextButton( - style: TextButton.styleFrom( - primary: Colors.white, - backgroundColor: Colors.blue, - shadowColor: Colors.grey, - elevation: 5.0, - ), - onPressed: () { - if (emailController.text == 'anant1234@gmail.com' && - passwordController.text == - 'anant') // email and password static - { - Navigator.pushNamed( - context, '/control'); //push to next route - Fluttertoast.showToast( - msg: 'Login successfull', - textColor: Colors.red, - backgroundColor: Colors.grey, - gravity: ToastGravity.BOTTOM, - ); - } else { - Fluttertoast.showToast( - msg: 'Login unsuccessfull', + Container( + width: double.infinity, + height: 40, + child: TextButton( + style: TextButton.styleFrom( + primary: Colors.white, + backgroundColor: Theme.of(context).primaryColor, + shadowColor: Colors.grey, + elevation: 5.0, + ), + onPressed: () { + if (emailController.text == + 'anant1234@gmail.com' && + passwordController.text == + 'anant') // email and password static + { + Navigator.pushNamed( + context, '/control'); //push to next route + Fluttertoast.showToast( + msg: 'Login successfull', textColor: Colors.red, backgroundColor: Colors.grey, - toastLength: Toast.LENGTH_SHORT, - gravity: ToastGravity.BOTTOM); - } - }, - child: Text('Login'), + gravity: ToastGravity.BOTTOM, + ); + } else { + Fluttertoast.showToast( + msg: 'Login unsuccessfull', + textColor: Colors.red, + backgroundColor: Colors.grey, + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.BOTTOM); + } + }, + child: Text('Login'), + ), ) ]))), ), diff --git a/lib/main.dart b/lib/main.dart index 6adb536..ab6bc37 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,12 +1,17 @@ import 'package:flutter/material.dart'; - -import 'control.dart'; -import 'login.dart'; -import 'splash.dart'; +import './control.dart'; +import './login.dart'; +import './splash.dart'; void main() { runApp( MaterialApp( + theme: ThemeData( + primaryColor: Colors.pink, + accentColor: Colors.amber, + canvasColor: Color.fromRGBO(255, 254, 229, 1), + visualDensity: VisualDensity.adaptivePlatformDensity, + ), home: Splash(), routes: { '/control': (context) => Control(), diff --git a/lib/splash.dart b/lib/splash.dart index 261c4ad..46e8ee5 100644 --- a/lib/splash.dart +++ b/lib/splash.dart @@ -1,5 +1,4 @@ import 'dart:async'; - import 'package:flutter/material.dart'; import 'package:p_track/login.dart';