Skip to content

Commit

Permalink
fix bottom sheets and make them look good again (finally)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeXTormer committed Feb 16, 2024
1 parent 8ebcfe2 commit be979d0
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 182 deletions.
2 changes: 1 addition & 1 deletion lib/frederic_main_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'misc/ExtraIcons.dart';
import 'screens/screens.dart';

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

@override
Widget build(BuildContext context) {
Expand Down
18 changes: 9 additions & 9 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:isolate';

import 'package:cupertino_modal_sheet/cupertino_modal_sheet.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
Expand All @@ -24,6 +23,7 @@ import 'package:frederic/theme/frederic_theme.dart';
import 'package:get_it/get_it.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sheet/route.dart';

final getIt = GetIt.instance;

Expand Down Expand Up @@ -202,16 +202,16 @@ class _FredericBaseState extends State<FredericBase> {
brightness:
theme.isBright ? Brightness.light : Brightness.dark)),
onGenerateRoute: (RouteSettings settings) {
switch (settings.name) {
case '/':
return CupertinoModalSheetRoute(
settings: settings,
builder: (context) {
return FredericMainApp();
});
if (settings.name == '/') {
return MaterialExtendedPageRoute<void>(
builder: (BuildContext context) {
return const FredericMainApp();
},
);
}
return null;
},
//home: FredericMainApp()
// home: FredericMainApp()
// OrientationBuilder(
// builder: (context, orientation) {
// if (orientation == Orientation.portrait) {
Expand Down
66 changes: 6 additions & 60 deletions lib/misc/bottom_sheet.dart
Original file line number Diff line number Diff line change
@@ -1,69 +1,15 @@
import 'package:cupertino_modal_sheet/cupertino_modal_sheet.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:sheet/route.dart';

Future<void> showFredericBottomSheet(
{required BuildContext context,
bool enableDrag = false,
bool isDismissible = true,
required Widget Function(BuildContext) builder}) {
return showCupertinoModalSheet(
context: context,
HapticFeedback.lightImpact();
return Navigator.of(context).push(CupertinoSheetRoute<void>(
stops: isDismissible ? <double>[0, 1] : <double>[1],
builder: builder,
);

// return showModalBottomSheet(
// context: context,
// shape: const RoundedRectangleBorder(
// borderRadius: BorderRadius.vertical(
// top: Radius.circular(25.0),
// ),
// ),
// builder: (c) =>
// Container(height: MediaQuery.of(context).size.height * 0.9));
//
// // Use `CupertinoModalSheetRoute` to show an ios 15 style modal sheet.
// // For declarative navigation (Navigator 2.0), use `CupertinoModalSheetPage` instead.
// print("WERNER FINDENIG");
// final modalRoute = CupertinoModalSheetRoute(
// builder: (context) => DraggableSheet(
// child: DecoratedBox(
// decoration: const ShapeDecoration(
// color: CupertinoColors.white,
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.all(
// Radius.circular(16),
// ),
// ),
// ),
// child: SizedBox.expand(
// child: Builder(builder: builder),
// ))));
//
// return Navigator.push(context, modalRoute);
));
}

// Future<void> showFredericBottomSheetOld(
// {required BuildContext context,
// bool enableDrag = false,
// bool isDismissible = true,
// required Widget Function(BuildContext) builder}) {
// HapticFeedback.lightImpact();
//
// return showCupertinoModalSheet(
// context: context,
// builder: builder,
// //barrierDismissible: isDismissible,
// );
//
// // return Navigator.of(context)
// // .push(CupertinoSheetRoute<void>(builder: builder));
// // Navigator.of(context)
// // .push(SheetRoute<void>(builder: builder, draggable: enableDrag));
// }

// void showOldCupertinoFredericBottomSheet({required BuildContext context, required Widget Function(BuildContext) builder}) {
// CupertinoScaffold.showCupertinoModalBottomSheet(
// context: context,
// builder: builder);
// }
1 change: 1 addition & 0 deletions lib/screens/add_progress_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class _AddProgressScreenState extends State<AddProgressScreen> {
: null;
return CustomScrollView(
physics: ClampingScrollPhysics(),
primary: true,
slivers: [
SliverPadding(padding: EdgeInsets.only(bottom: 12)),
_DisplayActivityCard(widget.activity),
Expand Down
82 changes: 36 additions & 46 deletions lib/screens/bottom_navigation_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class _BottomNavigationScreenState extends State<BottomNavigationScreen>
Widget build(BuildContext context) {
return CupertinoPageScaffold(
child: Scaffold(
backgroundColor: Colors.black,
backgroundColor: theme.backgroundColor,
extendBodyBehindAppBar: false,
body: AnnotatedRegion<SystemUiOverlayStyle>(
value: theme.isDark || theme.isColorful
Expand All @@ -60,52 +60,42 @@ class _BottomNavigationScreenState extends State<BottomNavigationScreen>
},
),
),
bottomNavigationBar: Stack(
children: [
// Weird workaround to make the space behind the corners
// the correct colors
Container(color: Colors.white, height: kBottomNavigationBarHeight),
Container(
decoration: BoxDecoration(
color: theme.backgroundColor,
borderRadius: BorderRadius.only(
topRight: Radius.circular(12),
topLeft: Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Color(0x17000000), spreadRadius: 0, blurRadius: 3),
],
),
child: ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(12),
topRight: Radius.circular(12)),
child: BottomNavigationBar(
items: items,
elevation: 0,
backgroundColor: theme.isColorful
? theme.mainColor
: theme.backgroundColor,
selectedItemColor: theme.isColorful
? theme.textColorColorfulBackground
: theme.accentColor,
unselectedItemColor: theme.isColorful
? theme.textColorColorfulBackground
: theme.mainColor,
showUnselectedLabels: true,
type: BottomNavigationBarType.fixed,
currentIndex: currentIndex,
onTap: (index) {
HapticFeedback.selectionClick();
setState(() {
currentIndex = index;
pageController.jumpToPage(index);
});
},
),
),
bottomNavigationBar: Container(
decoration: BoxDecoration(
color: theme.backgroundColor,
borderRadius: BorderRadius.only(
topRight: Radius.circular(12), topLeft: Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Color(0x17000000), spreadRadius: 0, blurRadius: 3),
],
),
child: ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(12), topRight: Radius.circular(12)),
child: BottomNavigationBar(
items: items,
elevation: 0,
backgroundColor:
theme.isColorful ? theme.mainColor : theme.backgroundColor,
selectedItemColor: theme.isColorful
? theme.textColorColorfulBackground
: theme.accentColor,
unselectedItemColor: theme.isColorful
? theme.textColorColorfulBackground
: theme.mainColor,
showUnselectedLabels: true,
type: BottomNavigationBarType.fixed,
currentIndex: currentIndex,
onTap: (index) {
HapticFeedback.selectionClick();
setState(() {
currentIndex = index;
pageController.jumpToPage(index);
});
},
),
],
),
),
),
);
Expand Down
127 changes: 65 additions & 62 deletions lib/screens/start_trial_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,69 +10,72 @@ class StartTrialScreen extends StatelessWidget {

@override
Widget build(BuildContext context) {
return FredericScaffold(
backgroundColor: theme.accentColorLight,
body: SingleChildScrollView(
child: Container(
color: theme.accentColorLight,
padding: const EdgeInsets.all(48),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 200,
height: 200,
child: Image(
colorBlendMode: BlendMode.screen,
fit: BoxFit.scaleDown,
image: AssetImage('assets/images/abdominal-bench.png')),
),
Text(
tr('app_name'),
style: TextStyle(
fontSize: 26,
fontWeight: FontWeight.w700,
color: theme.mainColor,
letterSpacing: 0.6),
),
const SizedBox(height: 4),
Text(
tr('trial.day_free_trial_text', args: [
FredericBackend.instance.defaults.trialDuration.toString()
]),
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w300,
color: Colors.black,
letterSpacing: 0.2),
),
const SizedBox(height: 32),
buildListEntry(tr('trial.list_item_1')),
buildListEntry(tr('trial.list_item_2')),
buildListEntry(tr('trial.list_item_3')),
const SizedBox(height: 88),
Text(
tr('trial.trial_description', args: [
FredericBackend.instance.defaults.trialDuration.toString()
]),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w300,
color: Colors.black,
letterSpacing: 0.2),
),
const SizedBox(height: 18),
FredericButton(tr('trial.start_trial_button'), onPressed: () {
FredericBackend.instance.purchaseManager.startFreeTrial();
Navigator.of(context).pop();
}),
const SizedBox(height: 24),
],
return PopScope(
canPop: false,
child: FredericScaffold(
backgroundColor: theme.accentColorLight,
body: SingleChildScrollView(
child: Container(
color: theme.accentColorLight,
padding: const EdgeInsets.all(48),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 200,
height: 200,
child: Image(
colorBlendMode: BlendMode.screen,
fit: BoxFit.scaleDown,
image: AssetImage('assets/images/abdominal-bench.png')),
),
Text(
tr('app_name'),
style: TextStyle(
fontSize: 26,
fontWeight: FontWeight.w700,
color: theme.mainColor,
letterSpacing: 0.6),
),
const SizedBox(height: 4),
Text(
tr('trial.day_free_trial_text', args: [
FredericBackend.instance.defaults.trialDuration.toString()
]),
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w300,
color: Colors.black,
letterSpacing: 0.2),
),
const SizedBox(height: 32),
buildListEntry(tr('trial.list_item_1')),
buildListEntry(tr('trial.list_item_2')),
buildListEntry(tr('trial.list_item_3')),
const SizedBox(height: 88),
Text(
tr('trial.trial_description', args: [
FredericBackend.instance.defaults.trialDuration.toString()
]),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w300,
color: Colors.black,
letterSpacing: 0.2),
),
const SizedBox(height: 18),
FredericButton(tr('trial.start_trial_button'), onPressed: () {
FredericBackend.instance.purchaseManager.startFreeTrial();
Navigator.of(context).pop();
}),
const SizedBox(height: 24),
],
),
),
),
));
)),
);
}

Widget buildListEntry(String text) {
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/workout_list_screen/workout_card.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:frederic/backend/backend.dart';
import 'package:frederic/main.dart';
Expand All @@ -10,6 +9,7 @@ import 'package:frederic/widgets/standard_elements/frederic_card.dart';
import 'package:frederic/widgets/standard_elements/frederic_chip.dart';
import 'package:frederic/widgets/standard_elements/picture_icon.dart';
import 'package:frederic/widgets/workout_list_screen/enable_workout_dialog.dart';
import 'package:sheet/route.dart';

class WorkoutCard extends StatefulWidget {
const WorkoutCard(this.workout,
Expand Down Expand Up @@ -61,7 +61,7 @@ class _WorkoutCardState extends State<WorkoutCard> {
onTap: widget.clickable
? () {
HapticFeedback.selectionClick();
Navigator.of(context).push(MaterialPageRoute(
Navigator.of(context).push(MaterialExtendedPageRoute(
builder: (context) => EditWorkoutScreen(
widget.workout.id,
defaultPage: hasStartDate
Expand Down
Loading

0 comments on commit be979d0

Please sign in to comment.