Skip to content

Commit

Permalink
Merge pull request #2394 from airqo-platform/GuestUserExperience
Browse files Browse the repository at this point in the history
Implemented the guest user experience and pages
  • Loading branch information
Baalmart authored Jan 24, 2025
2 parents 80a95de + e210df6 commit fa361ca
Show file tree
Hide file tree
Showing 13 changed files with 497 additions and 135 deletions.
3 changes: 3 additions & 0 deletions mobile-v3/assets/icons/chevron-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions mobile-v3/assets/images/shared/Frame 26085560.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions mobile-v3/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import 'package:airqo/src/app/other/places/repository/google_places_repository.d
import 'package:airqo/src/app/other/theme/bloc/theme_bloc.dart';
import 'package:airqo/src/app/other/theme/repository/theme_repository.dart';
import 'package:airqo/src/app/profile/bloc/user_bloc.dart';
import 'package:airqo/src/app/profile/pages/guest_profile%20page.dart';
import 'package:airqo/src/app/profile/repository/user_repository.dart';
import 'package:airqo/src/app/shared/bloc/connectivity_bloc.dart';
import 'package:airqo/src/app/shared/pages/nav_page.dart';
Expand Down
2 changes: 2 additions & 0 deletions mobile-v3/lib/src/app/auth/bloc/auth_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
),
);
}
} else if (event is UseAsGuest) {
emit(GuestUser());
}
});
}
Expand Down
4 changes: 4 additions & 0 deletions mobile-v3/lib/src/app/auth/bloc/auth_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ class RegisterUser extends AuthEvent {

const RegisterUser(this.model);
}

class UseAsGuest extends AuthEvent {
const UseAsGuest();
}
3 changes: 3 additions & 0 deletions mobile-v3/lib/src/app/auth/bloc/auth_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ class AuthLoadingError extends AuthState {
}

enum AuthPurpose { LOGIN, REGISTER }

final class GuestUser extends AuthState {}

202 changes: 116 additions & 86 deletions mobile-v3/lib/src/app/auth/pages/welcome_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ import 'package:airqo/src/app/auth/widgets/know_your_air.dart';
import 'package:airqo/src/app/auth/widgets/welcome_widget.dart';
import 'package:airqo/src/meta/utils/colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart';

import '../../shared/pages/nav_page.dart';
import '../bloc/auth_bloc.dart';

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

Expand Down Expand Up @@ -38,101 +43,126 @@ class _WelcomeScreenState extends State<WelcomeScreen> {

@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Stack(
children: [
SizedBox(
height: MediaQuery.of(context).size.height * 0.6,
child: PageView(
controller: controller,
onPageChanged: changeIndex,
children: [
WelcomeWidget(),
BreatheClean(),
KnowYourAir(),
],
return BlocListener<AuthBloc, AuthState>(
listener: (context, state) {
if (state is GuestUser) {
Future.microtask(() => Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (context) => NavPage()),
));
}
},
child: Scaffold(
body: Column(
children: [
Stack(
children: [
SizedBox(
height: MediaQuery.of(context).size.height * 0.6,
child: PageView(
controller: controller,
onPageChanged: changeIndex,
children: [
WelcomeWidget(),
BreatheClean(),
KnowYourAir(),
],
),
),
),
Container(
width: double.infinity,
height: MediaQuery.of(context).size.height * 0.6,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
AnimatedSmoothIndicator(
activeIndex: currentIndex,
count: 3,
effect: ExpandingDotsEffect(
dotWidth: 7,
radius: 7,
dotColor: Color(0xff60646C),
// activeDotColor: Color(0xffF6F6F7),
activeDotColor: AppColors.primaryColor,
dotHeight: 7),
),
SizedBox(height: 16)
],
Container(
width: double.infinity,
height: MediaQuery.of(context).size.height * 0.6,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
AnimatedSmoothIndicator(
activeIndex: currentIndex,
count: 3,
effect: ExpandingDotsEffect(
dotWidth: 7,
radius: 7,
dotColor: Color(0xff60646C),
// activeDotColor: Color(0xffF6F6F7),
activeDotColor: AppColors.primaryColor,
dotHeight: 7),
),
SizedBox(height: 16)
],
),
),
),
],
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.4,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16 * 2),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
InkWell(
onTap: () => Navigator.of(context).push(MaterialPageRoute(
builder: (context) => CreateAccountScreen())),
child: Container(
height: 56,
decoration: BoxDecoration(
color: AppColors.primaryColor,
borderRadius: BorderRadius.circular(4)),
child: Center(
child: Text(
"Create Account",
style: TextStyle(
fontWeight: FontWeight.w500,
color: Colors.white,
],
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.4,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16 * 2),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
InkWell(
onTap: () => Navigator.of(context).push(MaterialPageRoute(
builder: (context) => CreateAccountScreen())),
child: Container(
height: 56,
decoration: BoxDecoration(
color: AppColors.primaryColor,
borderRadius: BorderRadius.circular(4)),
child: Center(
child: Text(
"Create Account",
style: TextStyle(
fontWeight: FontWeight.w500,
color: Colors.white,
),
),
),
),
),
SizedBox(height: 18),
InkWell(
onTap: () => Navigator.of(context).push(
MaterialPageRoute(builder: (context) => LoginPage())),
child: Container(
height: 56,
decoration: BoxDecoration(
color: Theme.of(context).brightness == Brightness.dark
? Colors.white
: Theme.of(context).highlightColor,
borderRadius: BorderRadius.circular(4)),
child: Center(
child: Text(
"Login Here",
style: TextStyle(
fontWeight: FontWeight.w500, color: Colors.black),
),
),
),
),
),
SizedBox(height: 16),
InkWell(
onTap: () => Navigator.of(context).push(
MaterialPageRoute(builder: (context) => LoginPage())),
child: Container(
height: 56,
decoration: BoxDecoration(
color: Theme.of(context).brightness == Brightness.dark
? Colors.white
: Theme.of(context).highlightColor,
borderRadius: BorderRadius.circular(4)),
SizedBox(height: 18),

InkWell(
onTap: () =>context.read<AuthBloc>().add(UseAsGuest()),
child: Center(
child: Text(
"Login Here",
style: TextStyle(
fontWeight: FontWeight.w500, color: Colors.black),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Continue as guest ",
style: TextStyle(
color: AppColors.boldHeadlineColor2,
fontWeight: FontWeight.w500)),
SvgPicture.asset('assets/icons/chevron-right.svg',
height: 16.0,
width: 16.0,
color: AppColors.boldHeadlineColor2,)
],
),
),
),
),
SizedBox(height: 16),
Text(
"",
style: TextStyle(color: AppColors.boldHeadlineColor),
)
],
),
))
],
));

],
),
))
],
)),
);
}
}
Loading

0 comments on commit fa361ca

Please sign in to comment.