Skip to content

Commit

Permalink
viewing preferences.....This is still in deep beta
Browse files Browse the repository at this point in the history
  • Loading branch information
kzawadi committed Jul 29, 2022
1 parent 9a2ed72 commit 47dcfa9
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 78 deletions.
5 changes: 5 additions & 0 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:private_fit/application/on_boarding/bloc/on_boarding_bloc.dart';
import 'package:private_fit/application/open_food/bloc/open_food_bloc.dart';
import 'package:private_fit/application/setting/bloc/settings_bloc.dart';
import 'package:private_fit/injections.dart';
import 'package:private_fit/l10n/l10n.dart';
import 'package:private_fit/presentation/routes/router.gr.dart' as app_router;
Expand Down Expand Up @@ -37,6 +38,10 @@ class PrivateFitApp extends StatelessWidget {
BlocProvider(
create: (context) => getIt<OpenFoodBloc>(),
),
BlocProvider(
create: (context) => getIt<SettingsBloc>(),
child: Container(),
)
],
child: AnimatedTheme(
curve: Curves.easeInOut,
Expand Down
3 changes: 2 additions & 1 deletion lib/presentation/home/home_navigator_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:private_fit/presentation/home/widgets/bot_nav_bar.dart';
import 'package:private_fit/presentation/menstrual/menstrual_page.dart';
import 'package:private_fit/presentation/open_food/scanner_page.dart';
import 'package:private_fit/presentation/settings/settings_page.dart';
import 'package:private_fit/presentation/settings/settings_view.dart';

class HomeNavigatorWidget extends StatelessWidget {
const HomeNavigatorWidget({super.key});
Expand Down Expand Up @@ -41,7 +42,7 @@ class HomeNavigatorWidget extends StatelessWidget {
: i == 2
? const ScannerPage()
: i == 3
? const SettingsPage()
? const SettingsPageView()
// Container(
// color: Colors.white,
// child: const Center(
Expand Down
38 changes: 25 additions & 13 deletions lib/presentation/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ class HomePage extends StatelessWidget {
Widget build(BuildContext context) {
final l10n = context.l10n;
return Scaffold(
floatingActionButton: FloatingActionButton.extended(
onPressed: () {},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
extendedIconLabelSpacing: 16,
icon: const Icon(Icons.edit),
label: const Text('New activity'),
),
//todo(@CemTitor): we do not need this for now, do we?
// floatingActionButton: FloatingActionButton.extended(
// onPressed: () {},
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(24),
// ),
// extendedIconLabelSpacing: 16,
// icon: const Icon(Icons.edit),
// label: const Text('New activity'),
// ),
body: BlocConsumer<HomeBloc, HomeState>(
bloc: getIt<HomeBloc>(),
listener: (context, state) {
Expand Down Expand Up @@ -85,8 +86,7 @@ class HomeAppBar extends StatelessWidget {
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
largeTitle: Row(
children: const [
CircleAvatar(),
Spacer(),
// Spacer(),
AutoSizeText(
'Kelvin',
minFontSize: 21,
Expand All @@ -97,6 +97,17 @@ class HomeAppBar extends StatelessWidget {
),
],
),
trailing: CircleAvatar(
child: Image(
height: 70,
width: 70,
fit: BoxFit.cover,
gaplessPlayback: true,
image: Image.asset(
'assets/on_boarding/images/artist_1.png',
).image,
),
),
// largeTitle: const AutoSizeText(
// 'Kelvin',
// minFontSize: 21,
Expand Down Expand Up @@ -126,12 +137,13 @@ class HomeSilver extends StatelessWidget {
return const WorkoutList();
case 4:
return const PedomaterPage();
default:
return const PedomaterPage();
// default:
// return const PedomaterPage();
}
} else {
return Container();
}
return null;
},

/// Sets ChildCount to one incase of error
Expand Down
2 changes: 1 addition & 1 deletion lib/presentation/home/widgets/homepage_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class HomepageCard extends StatelessWidget {
Widget build(BuildContext context) {
return Card(
color: cardColor ?? Colors.white,
elevation: 10,
elevation: 2,
margin: EdgeInsets.symmetric(
horizontal: MediaQuery.of(context).size.width / 25,
vertical: MediaQuery.of(context).size.width / 30,
Expand Down
13 changes: 10 additions & 3 deletions lib/presentation/home/widgets/workout_list.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:private_fit/presentation/home/widgets/homepage_card.dart';
import 'package:private_fit/shared/iconly_icon.dart';
import 'package:private_fit/shared/icons_curved.dart';

class WorkoutList extends StatelessWidget {
const WorkoutList({Key? key}) : super(key: key);
Expand All @@ -17,13 +19,18 @@ class WorkoutList extends StatelessWidget {
MaterialButton(
height: 60,
onPressed: () {},
color: Colors.blue,
color: Theme.of(context).primaryColor,
textColor: Colors.white,
shape: const CircleBorder(),
child: Icon(
Icons.camera_alt,
child: IconlyIcon(
path: IconlyCurved.Activity,
size: MediaQuery.of(context).size.height * 0.03,
color: const Color.fromARGB(255, 12, 49, 54),
),
// Icon(
// IconlyCurved(),
// size: MediaQuery.of(context).size.height * 0.03,
// ),
),
Divider(
height: MediaQuery.of(context).size.height * 0.01,
Expand Down
2 changes: 1 addition & 1 deletion lib/presentation/routes/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ other stuff. AutoRoute does all that for you and much more.
AutoRoute<dynamic>(page: HomeNavigator),
AutoRoute<dynamic>(page: OnBoardingPage),
AutoRoute<dynamic>(page: ScannerPage),
AutoRoute<dynamic>(page: SettingsPage),
// AutoRoute<dynamic>(page: SettingsPage),
AutoRoute<dynamic>(page: MenstrualPage),
AutoRoute<dynamic>(page: OnBoarding, initial: true),
],
Expand Down
69 changes: 27 additions & 42 deletions lib/presentation/routes/router.gr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,63 +10,57 @@
//
// ignore_for_file: type=lint

import 'package:auto_route/auto_route.dart' as _i7;
import 'package:flutter/material.dart' as _i8;
import 'package:auto_route/auto_route.dart' as _i6;
import 'package:flutter/material.dart' as _i7;

import '../home/home_navigator.dart' as _i1;
import '../menstrual/menstrual_page.dart' as _i5;
import '../menstrual/menstrual_page.dart' as _i4;
import '../on_boarding/on_boarding_page.dart' as _i2;
import '../open_food/scanner_page.dart' as _i3;
import '../settings/settings_page.dart' as _i4;
import '../splash/splash_widgets/on_boarding/on_boarding/initial_route.dart'
as _i6;
as _i5;

class Router extends _i7.RootStackRouter {
Router([_i8.GlobalKey<_i8.NavigatorState>? navigatorKey])
class Router extends _i6.RootStackRouter {
Router([_i7.GlobalKey<_i7.NavigatorState>? navigatorKey])
: super(navigatorKey);

@override
final Map<String, _i7.PageFactory> pagesMap = {
final Map<String, _i6.PageFactory> pagesMap = {
HomeNavigatorRoute.name: (routeData) {
return _i7.CupertinoPageX<dynamic>(
return _i6.CupertinoPageX<dynamic>(
routeData: routeData, child: const _i1.HomeNavigator());
},
OnBoardingPageRoute.name: (routeData) {
return _i7.CupertinoPageX<dynamic>(
return _i6.CupertinoPageX<dynamic>(
routeData: routeData, child: const _i2.OnBoardingPage());
},
ScannerPageRoute.name: (routeData) {
return _i7.CupertinoPageX<dynamic>(
return _i6.CupertinoPageX<dynamic>(
routeData: routeData, child: const _i3.ScannerPage());
},
SettingsPageRoute.name: (routeData) {
return _i7.CupertinoPageX<dynamic>(
routeData: routeData, child: const _i4.SettingsPage());
},
MenstrualPageRoute.name: (routeData) {
return _i7.CupertinoPageX<dynamic>(
routeData: routeData, child: const _i5.MenstrualPage());
return _i6.CupertinoPageX<dynamic>(
routeData: routeData, child: const _i4.MenstrualPage());
},
OnBoardingRoute.name: (routeData) {
return _i7.CupertinoPageX<dynamic>(
routeData: routeData, child: const _i6.OnBoarding());
return _i6.CupertinoPageX<dynamic>(
routeData: routeData, child: const _i5.OnBoarding());
}
};

@override
List<_i7.RouteConfig> get routes => [
_i7.RouteConfig(HomeNavigatorRoute.name, path: '/home-navigator'),
_i7.RouteConfig(OnBoardingPageRoute.name, path: '/on-boarding-page'),
_i7.RouteConfig(ScannerPageRoute.name, path: '/scanner-page'),
_i7.RouteConfig(SettingsPageRoute.name, path: '/settings-page'),
_i7.RouteConfig(MenstrualPageRoute.name, path: '/menstrual-page'),
_i7.RouteConfig(OnBoardingRoute.name, path: '/')
List<_i6.RouteConfig> get routes => [
_i6.RouteConfig(HomeNavigatorRoute.name, path: '/home-navigator'),
_i6.RouteConfig(OnBoardingPageRoute.name, path: '/on-boarding-page'),
_i6.RouteConfig(ScannerPageRoute.name, path: '/scanner-page'),
_i6.RouteConfig(MenstrualPageRoute.name, path: '/menstrual-page'),
_i6.RouteConfig(OnBoardingRoute.name, path: '/')
];
}

/// generated route for
/// [_i1.HomeNavigator]
class HomeNavigatorRoute extends _i7.PageRouteInfo<void> {
class HomeNavigatorRoute extends _i6.PageRouteInfo<void> {
const HomeNavigatorRoute()
: super(HomeNavigatorRoute.name, path: '/home-navigator');

Expand All @@ -75,7 +69,7 @@ class HomeNavigatorRoute extends _i7.PageRouteInfo<void> {

/// generated route for
/// [_i2.OnBoardingPage]
class OnBoardingPageRoute extends _i7.PageRouteInfo<void> {
class OnBoardingPageRoute extends _i6.PageRouteInfo<void> {
const OnBoardingPageRoute()
: super(OnBoardingPageRoute.name, path: '/on-boarding-page');

Expand All @@ -84,34 +78,25 @@ class OnBoardingPageRoute extends _i7.PageRouteInfo<void> {

/// generated route for
/// [_i3.ScannerPage]
class ScannerPageRoute extends _i7.PageRouteInfo<void> {
class ScannerPageRoute extends _i6.PageRouteInfo<void> {
const ScannerPageRoute()
: super(ScannerPageRoute.name, path: '/scanner-page');

static const String name = 'ScannerPageRoute';
}

/// generated route for
/// [_i4.SettingsPage]
class SettingsPageRoute extends _i7.PageRouteInfo<void> {
const SettingsPageRoute()
: super(SettingsPageRoute.name, path: '/settings-page');

static const String name = 'SettingsPageRoute';
}

/// generated route for
/// [_i5.MenstrualPage]
class MenstrualPageRoute extends _i7.PageRouteInfo<void> {
/// [_i4.MenstrualPage]
class MenstrualPageRoute extends _i6.PageRouteInfo<void> {
const MenstrualPageRoute()
: super(MenstrualPageRoute.name, path: '/menstrual-page');

static const String name = 'MenstrualPageRoute';
}

/// generated route for
/// [_i6.OnBoarding]
class OnBoardingRoute extends _i7.PageRouteInfo<void> {
/// [_i5.OnBoarding]
class OnBoardingRoute extends _i6.PageRouteInfo<void> {
const OnBoardingRoute() : super(OnBoardingRoute.name, path: '/');

static const String name = 'OnBoardingRoute';
Expand Down
31 changes: 15 additions & 16 deletions lib/presentation/settings/settings_page.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:private_fit/application/setting/bloc/settings_bloc.dart';
import 'package:private_fit/injections.dart';
import 'package:private_fit/presentation/settings/settings_view.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_bloc/flutter_bloc.dart';
// import 'package:private_fit/application/setting/bloc/settings_bloc.dart';
// import 'package:private_fit/injections.dart';
// import 'package:private_fit/presentation/settings/settings_view.dart';

class SettingsPage extends StatelessWidget {
const SettingsPage({Key? key}) : super(key: key);
// class SettingsPage extends StatelessWidget {
// const SettingsPage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return BlocProvider<SettingsBloc>(
create: (context) =>
getIt<SettingsBloc>()..add(const SettingsEvent.started()),
child: const SettingsPageView(),
);
}
}
// @override
// Widget build(BuildContext context) {
// return BlocProvider<SettingsBloc>(
// create: (context) => getIt<SettingsBloc>(),
// child: const SettingsPageView(),
// );
// }
// }
3 changes: 2 additions & 1 deletion lib/presentation/settings/settings_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class _SettingsPageViewState extends State<SettingsPageView> {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@override
void initState() {
getIt<SettingsBloc>().add(const SettingsEvent.started());
Future<void>.delayed(Duration.zero, () async {
packageInfo = await PackageInfo.fromPlatform();

Expand Down Expand Up @@ -62,7 +63,7 @@ class _SettingsPageViewState extends State<SettingsPageView> {
@override
Widget build(BuildContext context) {
return BlocConsumer<SettingsBloc, SettingsState>(
bloc: getIt<SettingsBloc>()..add(const SettingsEvent.started()),
bloc: getIt<SettingsBloc>(),
listener: (context, state) {
final t = state.userNameModel.username.getOrCrash();
_userNameController.value = TextEditingValue(
Expand Down

0 comments on commit 47dcfa9

Please sign in to comment.