Skip to content

Commit

Permalink
working on new bottom sheet implementation (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeXTormer committed Feb 15, 2024
1 parent 7e0a374 commit b2a4664
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 66 deletions.
52 changes: 38 additions & 14 deletions lib/misc/bottom_sheet.dart
Original file line number Diff line number Diff line change
@@ -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<void> 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<void>(builder: builder));
// Navigator.of(context)
// .push(SheetRoute<void>(builder: builder, draggable: enableDrag));
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,
Expand Down
77 changes: 43 additions & 34 deletions lib/screens/bottom_navigation_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class _BottomNavigationScreenState extends State<BottomNavigationScreen>
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: theme.backgroundColor,
backgroundColor: Colors.black,
extendBodyBehindAppBar: false,
body: AnnotatedRegion<SystemUiOverlayStyle>(
value: theme.isDark || theme.isColorful
Expand All @@ -58,40 +58,49 @@ class _BottomNavigationScreenState extends State<BottomNavigationScreen>
},
),
),
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);
});
},
),
),
),
),
],
),
);
}
Expand Down
22 changes: 13 additions & 9 deletions lib/widgets/standard_elements/frederic_scaffold.dart
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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,
),
),
),
);
Expand Down
8 changes: 4 additions & 4 deletions macos/Flutter/ephemeral/Flutter-Generated.xcconfig
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions macos/Flutter/ephemeral/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
5 changes: 4 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b2a4664

Please sign in to comment.