diff --git a/app/lib/screens/init_screen.dart b/app/lib/screens/init_screen.dart index e16bd2559..92a07e0e6 100644 --- a/app/lib/screens/init_screen.dart +++ b/app/lib/screens/init_screen.dart @@ -12,6 +12,6 @@ class _InitState extends State { @override Widget build(BuildContext context) { - return Scaffold(body: SafeArea(child: SwipePage())); + return const Scaffold(body: SafeArea(child: SwipePage())); } } diff --git a/app/lib/screens/wizard/page5.dart b/app/lib/screens/wizard/page5.dart index 522b4ce1d..8255fc461 100644 --- a/app/lib/screens/wizard/page5.dart +++ b/app/lib/screens/wizard/page5.dart @@ -2,7 +2,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:provider/provider.dart'; -import 'package:threebotlogin/screens/unregistered_screen.dart'; +import 'package:threebotlogin/screens/main_screen.dart'; import 'package:threebotlogin/screens/wizard/web_view.dart'; import 'package:threebotlogin/services/shared_preference_service.dart'; import 'package:threebotlogin/widgets/wizard/terms_agreement.dart'; @@ -10,7 +10,8 @@ import 'package:threebotlogin/widgets/wizard/terms_agreement.dart'; class Page5 extends StatefulWidget { const Page5({super.key}); - _Page5State createState() => _Page5State(); + @override + State createState() => _Page5State(); } class _Page5State extends State { @@ -63,26 +64,22 @@ class _Page5State extends State { termsAgreement.attemptToContinue(); } else { saveInitDone(); - await Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - const UnregisteredScreen())); + await Navigator.of(context).push(MaterialPageRoute( + builder: (context) => const MainScreen( + initDone: true, + registered: false, + ))); } }, - style: ButtonStyle( - shape: - MaterialStateProperty.all( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(30), - ), - ), - backgroundColor: MaterialStatePropertyAll( - Theme.of(context).colorScheme.primary, - )), + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), + backgroundColor: Theme.of(context).colorScheme.primary, + ), child: Text( 'GET STARTED', - style: TextStyle( + style: Theme.of(context).textTheme.bodyLarge!.copyWith( color: Theme.of(context).colorScheme.onPrimary), )), ), @@ -102,22 +99,37 @@ class _Page5State extends State { children: [ TextSpan( text: "I agree to Threefold's ", - style: TextStyle( - color: termsAgreement.attemptedWithoutAccepting && - !termsAgreement.isChecked - ? Colors.red - : Theme.of(context).colorScheme.onBackground, - ), + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( + color: termsAgreement + .attemptedWithoutAccepting && + !termsAgreement.isChecked + ? Theme.of(context).colorScheme.error + : Theme.of(context) + .colorScheme + .onBackground, + ), ), TextSpan( text: 'Terms and conditions.', - style: TextStyle( - color: termsAgreement.attemptedWithoutAccepting && - !termsAgreement.isChecked - ? Colors.red - : Theme.of(context).colorScheme.onBackground, - decoration: TextDecoration.underline, - ), + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( + color: termsAgreement + .attemptedWithoutAccepting && + !termsAgreement.isChecked + ? Theme.of(context).colorScheme.error + : Colors.blue, + decoration: TextDecoration.underline, + decorationColor: termsAgreement + .attemptedWithoutAccepting && + !termsAgreement.isChecked + ? Theme.of(context).colorScheme.error + : Colors.blue, + ), recognizer: TapGestureRecognizer() ..onTap = () { Navigator.push( diff --git a/app/lib/screens/wizard/swipe_page.dart b/app/lib/screens/wizard/swipe_page.dart index 1c48015f9..38b6560dc 100644 --- a/app/lib/screens/wizard/swipe_page.dart +++ b/app/lib/screens/wizard/swipe_page.dart @@ -9,14 +9,21 @@ import 'package:threebotlogin/screens/wizard/page5.dart'; import '../../widgets/wizard/terms_and_conditions.dart'; class SwipePage extends StatefulWidget { + const SwipePage({super.key}); + @override - _SwipePagesState createState() => _SwipePagesState(); + State createState() => _SwipePagesState(); } class _SwipePagesState extends State { final PageController _pageController = PageController(); // Controls the PageView - int _currentPage = 0; + + @override + void dispose() { + _pageController.dispose(); + super.dispose(); + } @override Widget build(BuildContext context) { @@ -40,7 +47,7 @@ class _SwipePagesState extends State { }, child: Text( 'SKIP', - style: TextStyle( + style: Theme.of(context).textTheme.bodyLarge!.copyWith( color: Theme.of(context).colorScheme.onBackground), )) ], @@ -50,9 +57,7 @@ class _SwipePagesState extends State { child: PageView( controller: _pageController, onPageChanged: (int index) { - setState(() { - _currentPage = index; - }); + setState(() {}); }, children: const [Page1(), Page2(), Page3(), Page4(), Page5()], ), @@ -67,8 +72,8 @@ class _SwipePagesState extends State { effect: ExpandingDotsEffect( dotWidth: 20, dotHeight: 20, - activeDotColor: Theme.of(context).colorScheme.secondary, - dotColor: Colors.blue, + activeDotColor: Theme.of(context).colorScheme.primary, + dotColor: Theme.of(context).colorScheme.outline, ), ), ], diff --git a/app/lib/widgets/wizard/common_page.dart b/app/lib/widgets/wizard/common_page.dart index 6086b930e..37b1e3b23 100644 --- a/app/lib/widgets/wizard/common_page.dart +++ b/app/lib/widgets/wizard/common_page.dart @@ -18,7 +18,9 @@ class CommonPage extends StatefulWidget { this.heightPercentage = 100, this.widthPercentage = 300, }) : super(key: key); - _CommonPageState createState() => _CommonPageState(); + + @override + State createState() => _CommonPageState(); } class _CommonPageState extends State { diff --git a/app/lib/widgets/wizard/terms_and_conditions.dart b/app/lib/widgets/wizard/terms_and_conditions.dart index 68ae346f1..e9f450935 100644 --- a/app/lib/widgets/wizard/terms_and_conditions.dart +++ b/app/lib/widgets/wizard/terms_and_conditions.dart @@ -1,32 +1,32 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:threebotlogin/screens/unregistered_screen.dart'; +import 'package:threebotlogin/screens/main_screen.dart'; import 'package:threebotlogin/screens/wizard/web_view.dart'; import 'package:threebotlogin/services/shared_preference_service.dart'; +import 'package:threebotlogin/widgets/custom_dialog.dart'; import 'package:threebotlogin/widgets/wizard/terms_agreement.dart'; class TermsAndConditions extends StatefulWidget { const TermsAndConditions({Key? key}) : super(key: key); @override - _TermsAndConditionsState createState() => _TermsAndConditionsState(); + State createState() => _TermsAndConditionsState(); } class _TermsAndConditionsState extends State { - @override Widget build(BuildContext context) { - return AlertDialog( - title: Text( - 'Accept the terms and conditions?', - style: TextStyle(color: Theme.of(context).colorScheme.onBackground), - ), - content: SingleChildScrollView( - child: ListBody( - children: [ + return CustomDialog( + title: 'Accept the terms and conditions?', + widgetDescription: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ Text( 'Before you can start using the app, you must accept the Terms and Conditions.', - style: TextStyle( + style: Theme.of(context).textTheme.bodyMedium!.copyWith( color: Theme.of(context).colorScheme.onBackground)), GestureDetector( onTap: () { @@ -35,13 +35,11 @@ class _TermsAndConditionsState extends State { MaterialPageRoute(builder: (context) => const WebView()), ); }, - child: const Text( - 'Terms and Conditions', - style: TextStyle( - color: Colors.blue, - decoration: TextDecoration.underline, - ), - ), + child: Text('Terms and Conditions', + style: Theme.of(context).textTheme.bodyLarge!.copyWith( + color: Colors.blue, + decoration: TextDecoration.underline, + decorationColor: Colors.blue)), ), SizedBox(height: MediaQuery.of(context).size.height * 0.01), Consumer(builder: (context, termsAgreement, child) { @@ -55,8 +53,11 @@ class _TermsAndConditionsState extends State { ), Expanded( child: Text('I Accept the terms and conditions.', - style: TextStyle( - color: Theme.of(context).colorScheme.onBackground)), + style: Theme.of(context).textTheme.bodyMedium!.copyWith( + color: termsAgreement.attemptedWithoutAccepting && + !termsAgreement.isChecked + ? Theme.of(context).colorScheme.error + : Theme.of(context).colorScheme.onBackground)), ), ], ); @@ -64,16 +65,23 @@ class _TermsAndConditionsState extends State { ], ), ), - actions: [ + actions: [ TextButton( onPressed: () async { - if (Provider.of(context, listen: false).isChecked) { + final termsAgreement = + Provider.of(context, listen: false); + if (!termsAgreement.isChecked) { + termsAgreement.attemptToContinue(); + } else { saveInitDone(); Navigator.of(context).pop(); await Navigator.push( context, MaterialPageRoute( - builder: (context) => const UnregisteredScreen())); + builder: (context) => const MainScreen( + initDone: true, + registered: false, + ))); } }, child: const Text('Continue'),