Skip to content

Commit

Permalink
Clean up the screens
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedHanafy725 committed Dec 4, 2023
1 parent 612cf72 commit 2be8fd2
Show file tree
Hide file tree
Showing 16 changed files with 353 additions and 359 deletions.
6 changes: 3 additions & 3 deletions app/lib/screens/authentication_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class AuthenticationScreenState extends State<AuthenticationScreen> {
backgroundColor: HexColor('#0a73b8'));
}
});
return Container(
return SizedBox(
width: double.infinity,
child: Center(
child: Column(
Expand Down Expand Up @@ -260,7 +260,7 @@ class AuthenticationScreenState extends State<AuthenticationScreen> {
pin += char;
}

int currentTime = new DateTime.now().millisecondsSinceEpoch;
int currentTime = DateTime.now().millisecondsSinceEpoch;

if (globals.incorrectPincodeAttempts >= 3 &&
(globals.tooManyAuthenticationAttempts &&
Expand Down Expand Up @@ -296,7 +296,7 @@ class AuthenticationScreenState extends State<AuthenticationScreen> {
'Too many incorrect attempts, please wait ${((globals.lockedUntill - currentTime) / 1000).toStringAsFixed(0)} seconds',
);
} else {
dialog = CustomDialog(
dialog = const CustomDialog(
title: 'Incorrect pin',
description: 'Your pin code is incorrect.',
);
Expand Down
18 changes: 9 additions & 9 deletions app/lib/screens/error_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import 'package:package_info_plus/package_info_plus.dart';
import 'package:threebotlogin/helpers/globals.dart';

class ErrorScreen extends StatefulWidget {
const ErrorScreen({super.key, this.errorScreen, this.errorMessage = ''});

final Widget? errorScreen;
final String errorMessage;

ErrorScreen({Key? key, this.errorScreen, this.errorMessage = ''})
: super(key: key);

_ErrorScreenState createState() => _ErrorScreenState();
@override
State<ErrorScreen> createState() => _ErrorScreenState();
}

class _ErrorScreenState extends State<ErrorScreen> {
Expand All @@ -29,7 +29,7 @@ class _ErrorScreenState extends State<ErrorScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Error'),
title: const Text('Error'),
elevation: 0.0,
),
body: Column(
Expand All @@ -41,21 +41,21 @@ class _ErrorScreenState extends State<ErrorScreen> {
Icon(
Icons.warning,
size: 42.0,
color: Theme.of(context).errorColor,
color: Theme.of(context).colorScheme.error,
),
SizedBox(
const SizedBox(
height: 20.0,
),
Text(widget.errorMessage.isEmpty
? 'Please update the app before continuing'
: widget.errorMessage),
SizedBox(
const SizedBox(
height: 60.0,
),
Expanded(
child: Container(),
),
Text('v ' + version + (Globals.isInDebugMode ? '-DEBUG' : '')),
Text('v $version${Globals.isInDebugMode ? '-DEBUG' : ''}'),
],
),
);
Expand Down
40 changes: 20 additions & 20 deletions app/lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:async';

import 'package:flutter/material.dart';

import 'package:flutter/widgets.dart';
import 'package:flutter_svg/svg.dart';

//import 'package:threebotlogin/apps/free_flow_pages/ffp.dart';
Expand Down Expand Up @@ -31,12 +30,12 @@ import 'package:uni_links/uni_links.dart';

/* Screen shows tab bar and all pages defined in router.dart */
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key, this.initialLink, this.backendConnection});
final String? initialLink;
final BackendConnection? backendConnection;

HomeScreen({this.initialLink, this.backendConnection});

_HomeScreenState createState() => _HomeScreenState();
@override
State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen>
Expand All @@ -60,15 +59,15 @@ class _HomeScreenState extends State<HomeScreen>
MaterialPageRoute(
builder: (context) => AuthenticationScreen(
correctPin: pin!,
userMessage: "Please enter your PIN code",
userMessage: 'Please enter your PIN code',
),
),
);

pinCheckOpen = false;

if (authenticated != null && authenticated) {
lastCheck = new DateTime.now().millisecondsSinceEpoch;
lastCheck = DateTime.now().millisecondsSinceEpoch;
timeoutExpiredInBackground = false;
globals.tabController.animateTo(indexIfAuthIsSuccess);
}
Expand Down Expand Up @@ -123,11 +122,11 @@ class _HomeScreenState extends State<HomeScreen>
Events().onEvent(GoHomeEvent().runtimeType, close);

Events().onEvent(GoHomeEvent().runtimeType, (GoHomeEvent event) {
globals.tabController.animateTo(0, duration: Duration(seconds: 0));
globals.tabController.animateTo(0, duration: const Duration(seconds: 0));
});

Events().onEvent(GoNewsEvent().runtimeType, (GoNewsEvent event) {
globals.tabController.animateTo(1, duration: Duration(seconds: 0));
globals.tabController.animateTo(1, duration: const Duration(seconds: 0));
});

// Needed to hardcode this to prevent double tapping and gaining access without knowing the pincode with the current logic that was implemented.
Expand All @@ -144,16 +143,16 @@ class _HomeScreenState extends State<HomeScreen>
});

Events().onEvent(GoSupportEvent().runtimeType, (GoSupportEvent event) {
globals.tabController.animateTo(3, duration: Duration(seconds: 0));
globals.tabController.animateTo(3, duration: const Duration(seconds: 0));
});

Events().onEvent(GoSettingsEvent().runtimeType, (GoSettingsEvent event) {
globals.tabController.animateTo(4, duration: Duration(seconds: 0));
globals.tabController.animateTo(4, duration: const Duration(seconds: 0));
});

Events().onEvent(GoReservationsEvent().runtimeType,
(GoReservationsEvent event) {
globals.tabController.animateTo(5, duration: Duration(seconds: 0));
globals.tabController.animateTo(5, duration: const Duration(seconds: 0));
});

Events().onEvent(NewLoginEvent().runtimeType, (NewLoginEvent event) {
Expand All @@ -171,7 +170,8 @@ class _HomeScreenState extends State<HomeScreen>
Events().onEvent(IdentityCallbackEvent().runtimeType,
(IdentityCallbackEvent event) async {
Future(() {
globals.tabController.animateTo(0, duration: Duration(seconds: 0));
globals.tabController
.animateTo(0, duration: const Duration(seconds: 0));
showIdentityMessage(context, event.type!);
});
});
Expand All @@ -198,7 +198,7 @@ class _HomeScreenState extends State<HomeScreen>
}

int timeSpendWithPausedApp =
new DateTime.now().millisecondsSinceEpoch - lastCheck;
DateTime.now().millisecondsSinceEpoch - lastCheck;

if (timeSpendWithPausedApp >= pinCheckTimeout) {
timeoutExpiredInBackground = true;
Expand All @@ -211,7 +211,7 @@ class _HomeScreenState extends State<HomeScreen>
}
} else if (state == AppLifecycleState.inactive) {
} else if (state == AppLifecycleState.paused) {
lastCheck = new DateTime.now().millisecondsSinceEpoch;
lastCheck = DateTime.now().millisecondsSinceEpoch;
}
}

Expand All @@ -234,16 +234,18 @@ class _HomeScreenState extends State<HomeScreen>
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: PreferredSize(
child: new AppBar(
preferredSize: const Size.fromHeight(0),
child: AppBar(
automaticallyImplyLeading: true,
backgroundColor: HexColor("#2d4052"),
backgroundColor: HexColor('#2d4052'),
),
preferredSize: Size.fromHeight(0),
),
body: DefaultTabController(
length: Globals().router.routes.length,
child: WillPopScope(
onWillPop: onWillPop,
child: Scaffold(
body: Stack(
children: <Widget>[
Expand All @@ -256,16 +258,14 @@ class _HomeScreenState extends State<HomeScreen>
SafeArea(
child: TabBarView(
controller: globals.tabController,
physics: NeverScrollableScrollPhysics(),
physics: const NeverScrollableScrollPhysics(),
children: Globals().router.getContent(),
)),
],
),
),
onWillPop: onWillPop,
),
),
resizeToAvoidBottomInset: false,
);
}

Expand Down
8 changes: 5 additions & 3 deletions app/lib/screens/identity_verification_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import 'package:country_picker/country_picker.dart';
import 'package:threebotlogin/widgets/phone_widget.dart';

class IdentityVerificationScreen extends StatefulWidget {
_IdentityVerificationScreenState createState() =>
const IdentityVerificationScreen({super.key});

@override
State<IdentityVerificationScreen> createState() =>
_IdentityVerificationScreenState();
}

Expand Down Expand Up @@ -936,8 +939,7 @@ class _IdentityVerificationScreenState

try {
Response accessTokenResponse = await getShuftiAccessToken();
if (accessTokenResponse.statusCode == 403 ||
accessTokenResponse == null) {
if (accessTokenResponse.statusCode == 403) {
setState(() {
isLoading = false;
});
Expand Down
19 changes: 10 additions & 9 deletions app/lib/screens/init_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,41 @@ import 'package:threebotlogin/app_config.dart';
import 'package:threebotlogin/services/shared_preference_service.dart';

class InitScreen extends StatefulWidget {
InitScreen();
const InitScreen({super.key});

@override
_InitState createState() => _InitState();
State<InitScreen> createState() => _InitState();
}

class _InitState extends State<InitScreen> {
late InAppWebViewController webView;
late InAppWebView iaWebView;

finish(List<dynamic> params) async {
print("**** LOAD DONE ");
print('**** LOAD DONE ');
saveInitDone();
Navigator.pop(context, true);
}

addHandler() {
webView.addJavaScriptHandler(handlerName: "FINISH", callback: finish);
webView.addJavaScriptHandler(handlerName: 'FINISH', callback: finish);
}

_InitState() {
iaWebView = InAppWebView(
initialUrlRequest: URLRequest(
url: Uri.parse(AppConfig().wizardUrl() +
'?cache_buster=' +
new DateTime.now().millisecondsSinceEpoch.toString())),
url: Uri.parse(
'${AppConfig().wizardUrl()}?cache_buster=${DateTime.now().millisecondsSinceEpoch}')),
initialOptions: InAppWebViewGroupOptions(
android: AndroidInAppWebViewOptions(supportMultipleWindows: true, useHybridComposition: true),
android: AndroidInAppWebViewOptions(
supportMultipleWindows: true, useHybridComposition: true),
),
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
addHandler();
},
onCreateWindow: (InAppWebViewController controller, CreateWindowAction req) {
onCreateWindow:
(InAppWebViewController controller, CreateWindowAction req) {
return Future.value(true);
},
onLoadStart: (InAppWebViewController controller, Uri? url) {},
Expand Down
7 changes: 4 additions & 3 deletions app/lib/screens/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ import 'package:threebotlogin/widgets/login_dialogs.dart';
import 'package:threebotlogin/widgets/preference_dialog.dart';

class LoginScreen extends StatefulWidget {
final Login loginData;
const LoginScreen(this.loginData, {super.key});

LoginScreen(this.loginData);
final Login loginData;

_LoginScreenState createState() => _LoginScreenState();
@override
State<LoginScreen> createState() => _LoginScreenState();
}

class _LoginScreenState extends State<LoginScreen> with BlockAndRunMixin {
Expand Down
8 changes: 4 additions & 4 deletions app/lib/screens/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import 'package:threebotlogin/widgets/error_widget.dart';
import 'package:uni_links/uni_links.dart';

class MainScreen extends StatefulWidget {
const MainScreen({super.key, this.initDone, this.registered});

final bool? initDone;
final bool? registered;

const MainScreen({this.initDone, this.registered});

@override
_AppState createState() => _AppState();
State<MainScreen> createState() => _AppState();
}

class _AppState extends State<MainScreen> {
Expand Down Expand Up @@ -239,7 +239,7 @@ class _AppState extends State<MainScreen> {
try {
String baseUrl = AppConfig().baseUrl();
final List<InternetAddress> result =
await InternetAddress.lookup('$baseUrl')
await InternetAddress.lookup(baseUrl)
.timeout(Duration(seconds: Globals().timeOutSeconds));

if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
Expand Down
Loading

0 comments on commit 2be8fd2

Please sign in to comment.