Skip to content

Commit f741fc4

Browse files
committed
replaced title with date range app bar
1 parent 9643ebc commit f741fc4

File tree

5 files changed

+126
-5
lines changed

5 files changed

+126
-5
lines changed

apps/weekly_menu_app/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@
172172
TargetAttributes = {
173173
97C146ED1CF9000F007C117D = {
174174
CreatedOnToolsVersion = 7.3.1;
175-
DevelopmentTeam = 6ZBR4AVJLB;
176175
LastSwiftMigration = 0910;
177176
};
178177
};
@@ -399,6 +398,8 @@
399398
buildSettings = {
400399
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
401400
CLANG_ENABLE_MODULES = YES;
401+
CODE_SIGN_IDENTITY = "Apple Development";
402+
CODE_SIGN_STYLE = Automatic;
402403
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
403404
DEVELOPMENT_TEAM = 6ZBR4AVJLB;
404405
ENABLE_BITCODE = NO;
@@ -417,6 +418,7 @@
417418
);
418419
PRODUCT_BUNDLE_IDENTIFIER = com.example.weeklyMenuApp;
419420
PRODUCT_NAME = "$(TARGET_NAME)";
421+
PROVISIONING_PROFILE_SPECIFIER = "";
420422
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
421423
SWIFT_VERSION = 4.0;
422424
VERSIONING_SYSTEM = "apple-generic";
@@ -536,6 +538,8 @@
536538
buildSettings = {
537539
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
538540
CLANG_ENABLE_MODULES = YES;
541+
CODE_SIGN_IDENTITY = "Apple Development";
542+
CODE_SIGN_STYLE = Automatic;
539543
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
540544
DEVELOPMENT_TEAM = 6ZBR4AVJLB;
541545
ENABLE_BITCODE = NO;
@@ -554,6 +558,7 @@
554558
);
555559
PRODUCT_BUNDLE_IDENTIFIER = com.example.weeklyMenuApp;
556560
PRODUCT_NAME = "$(TARGET_NAME)";
561+
PROVISIONING_PROFILE_SPECIFIER = "";
557562
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
558563
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
559564
SWIFT_VERSION = 4.0;
@@ -567,6 +572,8 @@
567572
buildSettings = {
568573
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
569574
CLANG_ENABLE_MODULES = YES;
575+
CODE_SIGN_IDENTITY = "Apple Development";
576+
CODE_SIGN_STYLE = Automatic;
570577
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
571578
DEVELOPMENT_TEAM = 6ZBR4AVJLB;
572579
ENABLE_BITCODE = NO;
@@ -585,6 +592,7 @@
585592
);
586593
PRODUCT_BUNDLE_IDENTIFIER = com.example.weeklyMenuApp;
587594
PRODUCT_NAME = "$(TARGET_NAME)";
595+
PROVISIONING_PROFILE_SPECIFIER = "";
588596
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
589597
SWIFT_VERSION = 4.0;
590598
VERSIONING_SYSTEM = "apple-generic";

apps/weekly_menu_app/lib/widgets/screens/menu_page/daily_menu_section.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class DailyMenuSectionStreamWrapper extends HookConsumerWidget {
5757
),
5858
errorBuilder: (context, error) {
5959
if (error != null) {
60+
// in case we have a 404 just place an empty DailyMenuSection
6061
if (error is DataException && error.statusCode == 404) {
6162
return NewDailyMenuNotifierWrapper(
6263
date,

apps/weekly_menu_app/lib/widgets/screens/menu_page/menu_app_bar.dart

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import 'package:flutter/material.dart';
22
import 'package:hooks_riverpod/hooks_riverpod.dart';
33
import 'package:weekly_menu_app/widgets/screens/menu_page/notifier.dart';
4+
import 'package:weekly_menu_app/widgets/shared/app_bar.dart';
5+
import 'package:common/date.dart';
46

57
class MenuAppBar extends HookConsumerWidget implements PreferredSizeWidget {
68
MenuAppBar();
@@ -12,9 +14,25 @@ class MenuAppBar extends HookConsumerWidget implements PreferredSizeWidget {
1214
Widget build(BuildContext context, WidgetRef ref) {
1315
final notifier = ref.read(menuScreenNotifierProvider.notifier);
1416

15-
final editingMode = ref.watch(menuScreenNotifierProvider.select((s) => s.editMode));
17+
final editingMode =
18+
ref.watch(menuScreenNotifierProvider.select((s) => s.editMode));
1619

17-
return AppBar(
20+
return DateRangeAppBar(
21+
dateRange: DateRange(Date.now(), Date.now().add(Duration(days: 7))),
22+
actionIcon: editingMode
23+
? Icon(Icons.done)
24+
: Icon(Icons.mode_edit_outline_outlined),
25+
onActionTap: () => notifier.setEditMode(!editingMode),
26+
onLeadingTap: () {
27+
/*
28+
* We need the root Scaffold so we need the above context. If we don't
29+
* do this the InherithedWidget will look into first parent Scaffold
30+
* that does not contains any Drawer.
31+
*/
32+
Scaffold.of(Scaffold.of(context).context).openDrawer();
33+
},
34+
);
35+
/* return AppBar(
1836
title: Text("Weekly Menu"),
1937
centerTitle: true,
2038
actions: [
@@ -35,6 +53,6 @@ class MenuAppBar extends HookConsumerWidget implements PreferredSizeWidget {
3553
Scaffold.of(Scaffold.of(context).context).openDrawer();
3654
},
3755
),
38-
);
56+
); */
3957
}
4058
}

apps/weekly_menu_app/lib/widgets/shared/app_bar.dart

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,84 @@
11
import 'package:flutter/material.dart';
2-
2+
import 'package:common/date.dart';
3+
import 'package:intl/intl.dart';
34
import 'appbar_button.dart';
45

6+
const APP_BAR_HEIGHT = 80.0;
7+
8+
class DateRangeAppBar extends StatelessWidget implements PreferredSizeWidget {
9+
final Icon leadingIcon;
10+
final Icon actionIcon;
11+
final void Function()? onLeadingTap;
12+
final void Function()? onActionTap;
13+
final DateRange dateRange;
14+
final void Function(DateRange)? onRangeChanged;
15+
final DateFormat dateFormat;
16+
17+
DateRangeAppBar(
18+
{required this.dateRange,
19+
this.leadingIcon = const Icon(Icons.menu),
20+
this.onLeadingTap,
21+
this.actionIcon = const Icon(Icons.edit),
22+
this.onActionTap,
23+
this.onRangeChanged,
24+
DateFormat? dateFormat})
25+
: this.dateFormat = dateFormat ?? DateFormat('MM/dd');
26+
27+
@override
28+
Size get preferredSize => Size.fromHeight(APP_BAR_HEIGHT);
29+
30+
@override
31+
Widget build(BuildContext context) {
32+
final appBarTheme = Theme.of(context).appBarTheme;
33+
final osTopPadding = MediaQuery.of(context).padding.top;
34+
35+
return Stack(
36+
children: [
37+
Material(
38+
elevation: appBarTheme.elevation ?? 0,
39+
child: Container(
40+
height: osTopPadding,
41+
color: appBarTheme.backgroundColor,
42+
),
43+
),
44+
AppBar(
45+
toolbarHeight: 100,
46+
title: ElevatedButton(
47+
style: ElevatedButton.styleFrom(
48+
backgroundColor: appBarTheme.backgroundColor,
49+
elevation: 0,
50+
textStyle: appBarTheme.titleTextStyle,
51+
foregroundColor: appBarTheme.titleTextStyle!.color,
52+
),
53+
child: Row(
54+
mainAxisAlignment: MainAxisAlignment.center,
55+
children: [
56+
Icon(Icons.calendar_month),
57+
Text(
58+
'${dateRange.start.format(dateFormat)} - ${dateRange.end.format(dateFormat)}')
59+
],
60+
),
61+
onPressed: () {},
62+
),
63+
leading: Transform.scale(
64+
scale: 0.85,
65+
child: AppBarButton(
66+
icon: leadingIcon,
67+
onPressed: () => onLeadingTap?.call(),
68+
),
69+
),
70+
actions: <Widget>[
71+
AppBarButton(
72+
icon: actionIcon,
73+
onPressed: () => onActionTap?.call(),
74+
)
75+
],
76+
),
77+
],
78+
);
79+
}
80+
}
81+
582
class SearchAppBar extends StatefulWidget implements PreferredSizeWidget {
683
final Icon leadingIcon;
784
final void Function()? onLeadingTap;

packages/common/lib/date.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,20 @@ class Date {
3636

3737
static Date toDate(DateTime dt) => Date(dt);
3838
}
39+
40+
class DateRange {
41+
final Date start;
42+
final Date end;
43+
44+
DateRange(this.start, this.end);
45+
46+
@override
47+
String toString() => "($start - $end)";
48+
49+
@override
50+
bool operator ==(o) =>
51+
o is DateRange && o.start == this.start && o.end == this.end;
52+
53+
@override
54+
int get hashCode => start.hashCode ^ end.hashCode;
55+
}

0 commit comments

Comments
 (0)