Skip to content

Commit

Permalink
Some adjusting to wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedHanafy725 committed Sep 30, 2024
1 parent 28c3fa4 commit 3944498
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 65 deletions.
2 changes: 1 addition & 1 deletion app/lib/screens/init_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class _InitState extends State<InitScreen> {

@override
Widget build(BuildContext context) {
return Scaffold(body: SafeArea(child: SwipePage()));
return const Scaffold(body: SafeArea(child: SwipePage()));
}
}
74 changes: 43 additions & 31 deletions app/lib/screens/wizard/page5.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ 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';

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

_Page5State createState() => _Page5State();
@override
State<Page5> createState() => _Page5State();
}

class _Page5State extends State<Page5> {
Expand Down Expand Up @@ -63,26 +64,22 @@ class _Page5State extends State<Page5> {
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>(
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),
)),
),
Expand All @@ -102,22 +99,37 @@ class _Page5State extends State<Page5> {
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(
Expand Down
21 changes: 13 additions & 8 deletions app/lib/screens/wizard/swipe_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<SwipePage> createState() => _SwipePagesState();
}

class _SwipePagesState extends State<SwipePage> {
final PageController _pageController =
PageController(); // Controls the PageView
int _currentPage = 0;

@override
void dispose() {
_pageController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
Expand All @@ -40,7 +47,7 @@ class _SwipePagesState extends State<SwipePage> {
},
child: Text(
'SKIP',
style: TextStyle(
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
color: Theme.of(context).colorScheme.onBackground),
))
],
Expand All @@ -50,9 +57,7 @@ class _SwipePagesState extends State<SwipePage> {
child: PageView(
controller: _pageController,
onPageChanged: (int index) {
setState(() {
_currentPage = index;
});
setState(() {});
},
children: const [Page1(), Page2(), Page3(), Page4(), Page5()],
),
Expand All @@ -67,8 +72,8 @@ class _SwipePagesState extends State<SwipePage> {
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,
),
),
],
Expand Down
4 changes: 3 additions & 1 deletion app/lib/widgets/wizard/common_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class CommonPage extends StatefulWidget {
this.heightPercentage = 100,
this.widthPercentage = 300,
}) : super(key: key);
_CommonPageState createState() => _CommonPageState();

@override
State<CommonPage> createState() => _CommonPageState();
}

class _CommonPageState extends State<CommonPage> {
Expand Down
56 changes: 32 additions & 24 deletions app/lib/widgets/wizard/terms_and_conditions.dart
Original file line number Diff line number Diff line change
@@ -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<TermsAndConditions> createState() => _TermsAndConditionsState();
}

class _TermsAndConditionsState extends State<TermsAndConditions> {

@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: <Widget>[
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: () {
Expand All @@ -35,13 +35,11 @@ class _TermsAndConditionsState extends State<TermsAndConditions> {
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<TermsAgreement>(builder: (context, termsAgreement, child) {
Expand All @@ -55,25 +53,35 @@ class _TermsAndConditionsState extends State<TermsAndConditions> {
),
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)),
),
],
);
})
],
),
),
actions: <Widget>[
actions: [
TextButton(
onPressed: () async {
if (Provider.of<TermsAgreement>(context, listen: false).isChecked) {
final termsAgreement =
Provider.of<TermsAgreement>(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'),
Expand Down

0 comments on commit 3944498

Please sign in to comment.