From b2a46642160066362d3c9ed5c0a4125eccbe1f91 Mon Sep 17 00:00:00 2001 From: Felix Holz Date: Thu, 15 Feb 2024 23:46:42 +0100 Subject: [PATCH] working on new bottom sheet implementation (again) --- lib/misc/bottom_sheet.dart | 52 +++++++++---- lib/screens/bottom_navigation_screen.dart | 77 +++++++++++-------- .../standard_elements/frederic_scaffold.dart | 22 +++--- .../ephemeral/Flutter-Generated.xcconfig | 8 +- .../ephemeral/flutter_export_environment.sh | 8 +- pubspec.yaml | 5 +- 6 files changed, 106 insertions(+), 66 deletions(-) diff --git a/lib/misc/bottom_sheet.dart b/lib/misc/bottom_sheet.dart index 1c49ec1..5871579 100644 --- a/lib/misc/bottom_sheet.dart +++ b/lib/misc/bottom_sheet.dart @@ -1,27 +1,51 @@ -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:smooth_sheets/smooth_sheets.dart'; Future showFredericBottomSheet( {required BuildContext context, bool enableDrag = false, bool isDismissible = true, required Widget Function(BuildContext) builder}) { - HapticFeedback.lightImpact(); + // 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, - //barrierDismissible: isDismissible, - ); - - // return Navigator.of(context) - // .push(CupertinoSheetRoute(builder: builder)); - // Navigator.of(context) - // .push(SheetRoute(builder: builder, draggable: enableDrag)); + return Navigator.push(context, modalRoute); } +// Future 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(builder: builder)); +// // Navigator.of(context) +// // .push(SheetRoute(builder: builder, draggable: enableDrag)); +// } + // void showOldCupertinoFredericBottomSheet({required BuildContext context, required Widget Function(BuildContext) builder}) { // CupertinoScaffold.showCupertinoModalBottomSheet( // context: context, diff --git a/lib/screens/bottom_navigation_screen.dart b/lib/screens/bottom_navigation_screen.dart index 749d77b..c28c235 100644 --- a/lib/screens/bottom_navigation_screen.dart +++ b/lib/screens/bottom_navigation_screen.dart @@ -41,7 +41,7 @@ class _BottomNavigationScreenState extends State @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: theme.backgroundColor, + backgroundColor: Colors.black, extendBodyBehindAppBar: false, body: AnnotatedRegion( value: theme.isDark || theme.isColorful @@ -58,40 +58,49 @@ class _BottomNavigationScreenState extends State }, ), ), - bottomNavigationBar: Container( - decoration: BoxDecoration( - 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); + }); + }, + ), + ), ), - ), + ], ), ); } diff --git a/lib/widgets/standard_elements/frederic_scaffold.dart b/lib/widgets/standard_elements/frederic_scaffold.dart index f2cebb2..019b6f3 100644 --- a/lib/widgets/standard_elements/frederic_scaffold.dart +++ b/lib/widgets/standard_elements/frederic_scaffold.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:frederic/main.dart'; +import 'package:smooth_sheets/smooth_sheets.dart'; class FredericScaffold extends StatelessWidget { const FredericScaffold( @@ -17,15 +18,18 @@ class FredericScaffold extends StatelessWidget { @override Widget build(BuildContext context) { - return Scaffold( - floatingActionButton: floatingActionButton, - floatingActionButtonLocation: floatingActionButtonLocation, - backgroundColor: backgroundColor ?? - (theme.isColorful ? theme.mainColor : theme.backgroundColor), - body: SafeArea( - child: Container( - color: theme.backgroundColor, - child: body, + 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, + ), ), ), ); diff --git a/macos/Flutter/ephemeral/Flutter-Generated.xcconfig b/macos/Flutter/ephemeral/Flutter-Generated.xcconfig index 8982152..03e0e01 100644 --- a/macos/Flutter/ephemeral/Flutter-Generated.xcconfig +++ b/macos/Flutter/ephemeral/Flutter-Generated.xcconfig @@ -1,10 +1,10 @@ // This is a generated file; do not edit or check into version control. -FLUTTER_ROOT=/Users/felix/Developer/SDKs/flutter -FLUTTER_APPLICATION_PATH=/Users/felix/Developer/Projects/NeverSkip +FLUTTER_ROOT=/home/felix/Dev/SDKs/flutter +FLUTTER_APPLICATION_PATH=/home/felix/Dev/Projects/frederic COCOAPODS_PARALLEL_CODE_SIGN=true FLUTTER_BUILD_DIR=build -FLUTTER_BUILD_NAME=1.1.0 -FLUTTER_BUILD_NUMBER=23123102 +FLUTTER_BUILD_NAME=1.1.4 +FLUTTER_BUILD_NUMBER=24021102 DART_OBFUSCATION=false TRACK_WIDGET_CREATION=true TREE_SHAKE_ICONS=false diff --git a/macos/Flutter/ephemeral/flutter_export_environment.sh b/macos/Flutter/ephemeral/flutter_export_environment.sh index 733ce26..23b3b15 100755 --- a/macos/Flutter/ephemeral/flutter_export_environment.sh +++ b/macos/Flutter/ephemeral/flutter_export_environment.sh @@ -1,11 +1,11 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/Users/felix/Developer/SDKs/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/felix/Developer/Projects/NeverSkip" +export "FLUTTER_ROOT=/home/felix/Dev/SDKs/flutter" +export "FLUTTER_APPLICATION_PATH=/home/felix/Dev/Projects/frederic" export "COCOAPODS_PARALLEL_CODE_SIGN=true" export "FLUTTER_BUILD_DIR=build" -export "FLUTTER_BUILD_NAME=1.1.0" -export "FLUTTER_BUILD_NUMBER=23123102" +export "FLUTTER_BUILD_NAME=1.1.4" +export "FLUTTER_BUILD_NUMBER=24021102" export "DART_OBFUSCATION=false" export "TRACK_WIDGET_CREATION=true" export "TREE_SHAKE_ICONS=false" diff --git a/pubspec.yaml b/pubspec.yaml index 6093694..6ab31f3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -66,8 +66,11 @@ dependencies: 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: url: https://github.com/jamesblasco/modal_bottom_sheet.git