Skip to content

Commit

Permalink
feature:onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
DairoIyin committed Sep 6, 2024
1 parent 8d16151 commit 0dee12c
Show file tree
Hide file tree
Showing 16 changed files with 444 additions and 137 deletions.
121 changes: 2 additions & 119 deletions packages/volunteerapp/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,125 +1,8 @@
import 'package:flutter/material.dart';
import 'package:volunteerapp/volunteer_app.dart';

void main() {
runApp(const MyApp());
runApp(const VolunteerApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// TRY THIS: Try running your application with "flutter run". You'll see
// the application has a purple toolbar. Then, without quitting the app,
// try changing the seedColor in the colorScheme below to Colors.green
// and then invoke "hot reload" (save your changes or press the "hot
// reload" button in a Flutter-supported IDE, or press "r" if you used
// the command line to start the app).
//
// Notice that the counter didn't reset back to zero; the application
// state is not lost during the reload. To reset the state, use hot
// restart instead.
//
// This works for code too, not just values: Most code changes can be
// tested with just a hot reload.
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}

class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});

// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.

// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".

final String title;

@override
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;

void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}

@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
//
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
// action in the IDE, or press "p" in the console), to see the
// wireframe for each widget.
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:flutter/material.dart';

class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});

@override
Widget build(BuildContext context) {
return const Placeholder();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

import 'package:cave/cave.dart';
import 'package:cave/constants.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:volunteerapp/src/routing/routing.dart';
import 'package:volunteerapp/src/shared/shared.dart';

class OnboardingHomeScreen extends StatelessWidget {
const OnboardingHomeScreen({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Padding(
padding: EdgeInsets.symmetric(horizontal: Constants.horizontalMargin.w),
child: Column(
children: [
const HeaderText(
title: Text('Get attendees checked in faster than before'),
subtitle: Text(
'Hey rockstar volunteer, we have made attendees check in more convenient for you.',
),
),
SizedBox(height: (Constants.largeVerticalGutter * 3).h),
DevfestFilledButton(
onPressed: () {
context.goNamed(Devfest2024Routes.onboardingLogin.name);
},
title: const Text('Login'),
)
],
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

import 'package:cave/cave.dart';
import 'package:cave/constants.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:volunteerapp/src/routing/routing.dart';
import 'package:volunteerapp/src/shared/shared.dart';

class OnboardingLoginScreen extends StatelessWidget {
const OnboardingLoginScreen({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: SafeArea(
child: Padding(
padding:
EdgeInsets.symmetric(horizontal: Constants.horizontalMargin.w),
child: Column(
children: [
Expanded(
child: Form(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const HeaderText(
title: Text('Login 🤙🏾'),
subtitle: Text('Enter your details to continue!'),
),
Constants.largeVerticalGutter.verticalSpace,
DevfestTextFormField(
title: 'Email Address',
hint: 'e.g [email protected]',
onChanged: (value) {},
),
DevfestTextFormField(
title: 'Password',
hint: 'Enter Password',
onChanged: (value) {},
),

],
),
),
),
),
DevfestFilledButton(
title: const Text('Continue'),
onPressed: () {
context.goNamed(Devfest2024Routes.home.name);
},
),

],
),
),
),
);
}
}
50 changes: 50 additions & 0 deletions packages/volunteerapp/lib/src/routing/router.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

import 'package:volunteerapp/src/features/home/presentation/screens/home_screen.dart';
import 'package:volunteerapp/src/features/onboarding/presentation/screens/onboarding_home.dart';
import 'package:volunteerapp/src/features/onboarding/presentation/screens/onboarding_login.dart';

import 'routes.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';

class Devfest2024Router {
static final rootNavigatorKey = GlobalKey<NavigatorState>();

Devfest2024Router._();

static final Devfest2024Router instance = Devfest2024Router._();

void initialiseRouter(WidgetRef ref) {
router = _getRouter(ref);
}

late GoRouter router;

GoRouter _getRouter(WidgetRef ref) {
return GoRouter(
navigatorKey: rootNavigatorKey,
initialLocation: '/onboarding',
routes: [
GoRoute(
path: '/${Devfest2024Routes.onboardingHome.path}',
name: Devfest2024Routes.onboardingHome.name,
builder: (context, state) => const OnboardingHomeScreen(),
routes: [
GoRoute(
path: Devfest2024Routes.onboardingLogin.path,
name: Devfest2024Routes.onboardingLogin.name,
builder: (context, state) => const OnboardingLoginScreen(),
),

],
),
GoRoute(
path: '/',
name: Devfest2024Routes.home.name,
builder: (context, state) => const HomeScreen(),

),
]);
}
}
12 changes: 12 additions & 0 deletions packages/volunteerapp/lib/src/routing/routes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
enum Devfest2024Routes {
onboardingHome('onboarding'),
onboardingLogin('log-in'),
home(''),
profile('profile'),
scanQrCode('qr-code'),
search('map');

const Devfest2024Routes(this.path);

final String path;
}
2 changes: 2 additions & 0 deletions packages/volunteerapp/lib/src/routing/routing.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export 'router.dart';
export 'routes.dart';
Empty file.
28 changes: 28 additions & 0 deletions packages/volunteerapp/lib/src/shared/extensions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

import 'package:cave/cave.dart';
import 'package:flutter/material.dart';
import 'package:volunteerapp/src/routing/routing.dart';

extension DevfestColorsX on Color {
/// utility extension used on colors when prototyping from light-mode
/// converts colors passed in light mode to their respective dark-mode
/// variants
Color get possibleDarkVariant {
final context = Devfest2024Router.rootNavigatorKey.currentContext;
if (context == null) return this;
final isDarkMode = Theme.of(context).brightness == Brightness.dark;

if (isDarkMode) {
return switch (this) {
DevfestColors.grey40 || DevfestColors.grey60 => DevfestColors.grey70,
DevfestColors.grey10 => DevfestColors.backgroundLight,
// DevfestColors.grey50 =>
DevfestColors.primariesYellow90 => DevfestColors.grey40,
DevfestColors.primariesYellow100 => DevfestColors.backgroundDark,
_ => this,
};
}

return this;
}
}
4 changes: 4 additions & 0 deletions packages/volunteerapp/lib/src/shared/shared.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export 'exceptions/exceptions.dart';
export 'ui_model/ui_state_model.dart';
export 'widgets/widgets.dart';
export 'extensions.dart';
Empty file.
Loading

0 comments on commit 0dee12c

Please sign in to comment.