diff --git a/android/app/src/main/res/drawable/launch_background.xml b/android/app/src/main/res/drawable/launch_background.xml index 97f2d62..331d9ff 100644 --- a/android/app/src/main/res/drawable/launch_background.xml +++ b/android/app/src/main/res/drawable/launch_background.xml @@ -4,9 +4,9 @@ - + diff --git a/android/app/src/main/res/mipmap/launch_image.png b/android/app/src/main/res/mipmap/launch_image.png new file mode 100644 index 0000000..e8d5eb3 Binary files /dev/null and b/android/app/src/main/res/mipmap/launch_image.png differ diff --git a/assets/images/launch_image.png b/assets/images/launch_image.png new file mode 100644 index 0000000..e8d5eb3 Binary files /dev/null and b/assets/images/launch_image.png differ diff --git a/lib/common/widgets/basic_drawer.dart b/lib/common/widgets/basic_drawer.dart index 65728e5..85ab80e 100644 --- a/lib/common/widgets/basic_drawer.dart +++ b/lib/common/widgets/basic_drawer.dart @@ -18,17 +18,17 @@ class _BasicDrawerState extends State { Widget build(BuildContext context) { return Drawer( child: Container( - padding: new EdgeInsets.all(32.0), + padding: new EdgeInsets.all(32), child: ListView( children: [ ListTile( - title: Text ( - "Home", - style: TextStyle(color: Colors.black, fontSize: 20.0), - ), - onTap: () { - Navigator.of(context).pushNamed('/HomePage'); - } + title: Text ( + "Home", + style: TextStyle(color: Colors.black, fontSize: 20.0), + ), + onTap: () { + Navigator.of(context).pushNamed('/HomePage'); + } ), ListTile( title: Text( diff --git a/lib/main.dart b/lib/main.dart index e180def..408b8b3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -5,6 +5,7 @@ import 'package:local_spend/pages/receipt_page.dart'; import 'package:local_spend/pages/spash_screen.dart'; import 'package:local_spend/pages/about_screen.dart'; import 'package:local_spend/config.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; void main() { runApp(MyApp()); @@ -15,6 +16,15 @@ class MyApp extends StatelessWidget { Widget build(BuildContext context) { //var config = ConfigWrapper.of(context); return new MaterialApp( + + localizationsDelegates: [ + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ], + supportedLocales: [ + Locale("en") + ], + title: "Splash and Token Authentication", theme: new ThemeData( primarySwatch: Colors.blueGrey, diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index 93ae53e..0ab6210 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -2,6 +2,10 @@ import 'package:flutter/material.dart'; import 'package:local_spend/common/platform/platform_scaffold.dart'; import 'package:local_spend/common/widgets/basic_drawer.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:flutter/services.dart'; +import 'package:local_spend/common/apifunctions/request_logout_api.dart'; +import 'package:local_spend/common/functions/get_token.dart'; +import 'package:flutter_fadein/flutter_fadein.dart'; class HomePage extends StatefulWidget { @override @@ -10,6 +14,7 @@ class HomePage extends StatefulWidget { class _HomePageState extends State { @override + void initState() { super.initState(); _saveCurrentRoute("/HomePage"); @@ -25,7 +30,7 @@ class _HomePageState extends State { return PlatformScaffold( appBar: AppBar( title: Text( - "Home Page", + "Navigation", style: TextStyle(color: Colors.black), ), iconTheme: IconThemeData(color: Colors.black), @@ -33,11 +38,54 @@ class _HomePageState extends State { ), drawer: BasicDrawer(), body: Container( - padding: EdgeInsets.all(32.0), - child: Center( + child: FadeIn( + duration: Duration(milliseconds: 500), + curve: Curves.easeIn, + child: Column( children: [ - Text('This is the Home page'), + + ListTile( + contentPadding: EdgeInsets.fromLTRB(0, 15, 0, 0), + title: new Center( + child: new Text( + "Submit Receipt", + style: TextStyle(color: Colors.black, fontSize: 20.0), + textAlign: TextAlign.center, + ), + ), + onTap: () { + // debugPrint('$token'); + Navigator.of(context).pushNamed('/ReceiptPage'); + }, + ), + + ListTile( + title: new Center( + child: new Text( + "About", + style: TextStyle(color: Colors.black, fontSize: 20.0), + ), + ), + onTap: () { + SystemChannels.textInput.invokeMethod('TextInput.hide'); + Navigator.of(context).pushReplacementNamed('/AboutPage'); + }, + ), + + ListTile( + title: new Center( + child: new Text( + "Logout", + style: TextStyle(color: Colors.black, fontSize: 20.0), + ), + ), + onTap: () { + requestLogoutAPI(context); + Navigator.of(context).pushReplacementNamed('/LoginPage'); + }, + + ), ], ), ), diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart index 9518fdb..8ebb064 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -1,5 +1,4 @@ import 'dart:async'; - import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -58,7 +57,6 @@ class LoginPageState extends State { @override Widget build(BuildContext context) { - var drawer = Drawer(); return WillPopScope( onWillPop: () { if (Navigator.canPop(context)) { @@ -69,7 +67,7 @@ class LoginPageState extends State { } }, child: PlatformScaffold( - drawer: BasicDrawer(), +// drawer: BasicDrawer(), appBar: AppBar( title: Text( "LOGIN", diff --git a/lib/pages/receipt_page.dart b/lib/pages/receipt_page.dart index b316ca7..5141df1 100644 --- a/lib/pages/receipt_page.dart +++ b/lib/pages/receipt_page.dart @@ -12,6 +12,7 @@ import 'package:intl/intl.dart'; import 'package:datetime_picker_formfield/datetime_picker_formfield.dart'; const URL = "https://flutter.io/"; +const demonstration = true; class ReceiptPage extends StatefulWidget { @override @@ -127,12 +128,30 @@ class ReceiptPageState extends State { decoration: InputDecoration( hintText: 'Value in £', ), - obscureText: true, +// obscureText: true, + autocorrect: false, + keyboardType: TextInputType.number, style: TextStyle( fontSize: 18.0, color: Colors.grey[800], fontWeight: FontWeight.bold, ), + onSubmitted: (_) { + SystemChannels.textInput.invokeMethod('TextInput.hide'); + + if (demonstration) + { + showDialogSingleButton( + context, + "Success", + "Recepit successfully submitted.", + "OK"); + } + else { + submitReceiptAPI(context, _amountController.text, + _timeController.text); + } + }, ), ), Padding( @@ -142,8 +161,19 @@ class ReceiptPageState extends State { child: RaisedButton( onPressed: () { SystemChannels.textInput.invokeMethod('TextInput.hide'); - submitReceiptAPI(context, _amountController.text, - _timeController.text); + + if (demonstration) + { + showDialogSingleButton( + context, + "Success", + "Recepit successfully submitted.", + "OK"); + } + else { + submitReceiptAPI(context, _amountController.text, + _timeController.text); + } }, child: Text("SUBMIT", style: diff --git a/lib/pages/spash_screen.dart b/lib/pages/spash_screen.dart index 955e730..3b7c4c6 100644 --- a/lib/pages/spash_screen.dart +++ b/lib/pages/spash_screen.dart @@ -32,16 +32,17 @@ class _SplashScreenState extends State { return PlatformScaffold( drawer: drawer, body: Container( - decoration: BoxDecoration(color: Colors.black), + decoration: BoxDecoration(color: Colors.white), child: Column( children: [ Expanded( child: Container( - decoration: BoxDecoration(color: Colors.black), + margin: EdgeInsets.all(15), alignment: FractionalOffset(0.5, 0.3), - child: Text( - "Local Loop", - style: TextStyle(fontSize: 40.0, color: Colors.white), + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/images/launch_image.png') + ), ), ), ), @@ -51,7 +52,7 @@ class _SplashScreenState extends State { "© Copyright Statement 2018", style: TextStyle( fontSize: 16.0, - color: Colors.white, + color: Colors.black, ), ), ), diff --git a/pubspec.lock b/pubspec.lock index 331bd50..a1721f3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -160,6 +160,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_fadein: + dependency: "direct main" + description: + name: flutter_fadein + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" flutter_linkify: dependency: "direct main" description: @@ -167,6 +174,11 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.1" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" flutter_test: dependency: "direct dev" description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index 056b22a..a5d9364 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,12 +15,15 @@ environment: dependencies: flutter: sdk: flutter + flutter_localizations: + sdk: flutter shared_preferences: ^0.4.2 url_launcher: ^3.0.3 json_annotation : ^2.2.0 http: ^0.12.0+2 datetime_picker_formfield: ^0.1.8 flutter_linkify: ^1.0.3 + flutter_fadein: ^1.1.1 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. @@ -48,7 +51,10 @@ flutter: # assets: # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg - + assets: + - assets/ + - assets/images/ + - assets/images/launch_image.png # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.io/assets-and-images/#resolution-aware.