Skip to content

Commit

Permalink
frustrations with bottom sheets
Browse files Browse the repository at this point in the history
  • Loading branch information
NeXTormer committed Feb 15, 2024
1 parent b2a4664 commit 0c2cd55
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 127 deletions.
75 changes: 43 additions & 32 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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 Down Expand Up @@ -184,38 +185,48 @@ class _FredericBaseState extends State<FredericBase> {
value: FredericBackend.instance.goalManager),
],
child: MaterialApp(
showPerformanceOverlay: false,
title: 'NeverSkip Fitness',
locale: context.locale,
debugShowCheckedModeBanner: false,
supportedLocales: context.supportedLocales,
localizationsDelegates: context.localizationDelegates,
theme: ThemeData(
useMaterial3: false,
primaryColor: theme.mainColor,
brightness: theme.isBright ? Brightness.light : Brightness.dark,
fontFamily: 'Montserrat',
colorScheme: ColorScheme.fromSwatch().copyWith(
secondary: theme.accentColor,
primary: theme.mainColor,
brightness:
theme.isBright ? Brightness.light : Brightness.dark)),
home: FredericMainApp()
// OrientationBuilder(
// builder: (context, orientation) {
// if (orientation == Orientation.portrait) {
// return FredericMainApp();
// }
//
// if (getIt.isRegistered<AdminBackend>())
// getIt.unregister<AdminBackend>();
// getIt.registerSingleton<AdminBackend>(AdminBackend());
// return BlocProvider<AdminIconManager>.value(
// value: AdminBackend.instance.iconManager,
// child: FredericAdminPanel());
// },
// ),
),
showPerformanceOverlay: false,
title: 'NeverSkip Fitness',
locale: context.locale,
debugShowCheckedModeBanner: false,
supportedLocales: context.supportedLocales,
localizationsDelegates: context.localizationDelegates,
theme: ThemeData(
useMaterial3: false,
primaryColor: theme.mainColor,
brightness: theme.isBright ? Brightness.light : Brightness.dark,
fontFamily: 'Montserrat',
colorScheme: ColorScheme.fromSwatch().copyWith(
secondary: theme.accentColor,
primary: theme.mainColor,
brightness:
theme.isBright ? Brightness.light : Brightness.dark)),
onGenerateRoute: (RouteSettings settings) {
switch (settings.name) {
case '/':
return CupertinoModalSheetRoute(
settings: settings,
builder: (context) {
return FredericMainApp();
});
}
},
//home: FredericMainApp()
// OrientationBuilder(
// builder: (context, orientation) {
// if (orientation == Orientation.portrait) {
// return FredericMainApp();
// }
//
// if (getIt.isRegistered<AdminBackend>())
// getIt.unregister<AdminBackend>();
// getIt.registerSingleton<AdminBackend>(AdminBackend());
// return BlocProvider<AdminIconManager>.value(
// value: AdminBackend.instance.iconManager,
// child: FredericAdminPanel());
// },
// ),
),
),
);
}
Expand Down
54 changes: 35 additions & 19 deletions lib/misc/bottom_sheet.dart
Original file line number Diff line number Diff line change
@@ -1,30 +1,46 @@
import 'package:cupertino_modal_sheet/cupertino_modal_sheet.dart';
import 'package:flutter/cupertino.dart';
import 'package:smooth_sheets/smooth_sheets.dart';
import 'package:flutter/material.dart';

Future<void> showFredericBottomSheet(
{required BuildContext context,
bool enableDrag = false,
bool isDismissible = true,
required Widget Function(BuildContext) builder}) {
// 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 showCupertinoModalSheet(
context: context,
builder: builder,
);

return Navigator.push(context, modalRoute);
// 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(
Expand Down
122 changes: 64 additions & 58 deletions lib/screens/bottom_navigation_screen.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:frederic/backend/backend.dart';
Expand Down Expand Up @@ -40,67 +41,72 @@ class _BottomNavigationScreenState extends State<BottomNavigationScreen>

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
extendBodyBehindAppBar: false,
body: AnnotatedRegion<SystemUiOverlayStyle>(
value: theme.isDark || theme.isColorful
? SystemUiOverlayStyle.light
: SystemUiOverlayStyle.dark,
child: PageView(
children: screens,
controller: pageController,
onPageChanged: (index) {
setState(() {
currentIndex = index;
});
_sendCurrentTabToAnalytics();
},
return CupertinoPageScaffold(
child: Scaffold(
backgroundColor: Colors.black,
extendBodyBehindAppBar: false,
body: AnnotatedRegion<SystemUiOverlayStyle>(
value: theme.isDark || theme.isColorful
? SystemUiOverlayStyle.light
: SystemUiOverlayStyle.dark,
child: PageView(
children: screens,
controller: pageController,
onPageChanged: (index) {
setState(() {
currentIndex = index;
});
_sendCurrentTabToAnalytics();
},
),
),
),
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: 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);
});
},
),
),
),
),
],
],
),
),
);
}
Expand Down
22 changes: 9 additions & 13 deletions lib/widgets/standard_elements/frederic_scaffold.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:frederic/main.dart';
import 'package:smooth_sheets/smooth_sheets.dart';

class FredericScaffold extends StatelessWidget {
const FredericScaffold(
Expand All @@ -18,18 +17,15 @@ class FredericScaffold extends StatelessWidget {

@override
Widget build(BuildContext context) {
return CupertinoStackedTransition(
cornerRadius: Tween(begin: 0.0, end: 16.0),
child: Scaffold(
floatingActionButton: floatingActionButton,
floatingActionButtonLocation: floatingActionButtonLocation,
backgroundColor: backgroundColor ??
(theme.isColorful ? theme.mainColor : theme.backgroundColor),
body: SafeArea(
child: Container(
color: theme.backgroundColor,
child: body,
),
return Scaffold(
floatingActionButton: floatingActionButton,
floatingActionButtonLocation: floatingActionButtonLocation,
backgroundColor: backgroundColor ??
(theme.isColorful ? theme.mainColor : theme.backgroundColor),
body: SafeArea(
child: Container(
color: theme.backgroundColor,
child: body,
),
),
);
Expand Down
6 changes: 1 addition & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ dependencies:
infinite_listview: ^1.1.0
introduction_screen: ^3.1.12
cached_network_image: ^3.3.0

smooth_sheets:
git:
url: https://github.com/fujidaiti/smooth_sheets.git
path: package
cupertino_modal_sheet: ^1.1.0

sheet:
git:
Expand Down

0 comments on commit 0c2cd55

Please sign in to comment.