Skip to content

Commit

Permalink
Add a safearea around all the screens
Browse files Browse the repository at this point in the history
  • Loading branch information
JAicewizard committed Dec 1, 2022
1 parent 28a6de6 commit aa89844
Show file tree
Hide file tree
Showing 13 changed files with 576 additions and 539 deletions.
63 changes: 29 additions & 34 deletions lib/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,28 @@ final List<RouteBase> routes = [
),
routes: [
GoRoute(
path: 'sales/order/:pk/pay',
name: 'sales-order-pay',
pageBuilder: (context, state) {
return CustomTransitionPage(
barrierColor: Colors.black54,
opaque: false,
transitionDuration: const Duration(milliseconds: 150),
transitionsBuilder: (
context,
animation,
secondaryAnimation,
child,
) {
return FadeTransition(
opacity: CurvedAnimation(
parent: animation,
curve: Curves.easeOut,
),
child: child,
);
},
child: SalesOrderDialog(pk: state.params['pk']!),
);
},
),
path: 'sales/order/:pk/pay',
name: 'sales-order-pay',
pageBuilder: (context, state) => CustomTransitionPage(
barrierColor: Colors.black54,
opaque: false,
transitionDuration: const Duration(milliseconds: 150),
transitionsBuilder: (
context,
animation,
secondaryAnimation,
child,
) {
return FadeTransition(
opacity: CurvedAnimation(
parent: animation,
curve: Curves.easeOut,
),
child: child,
);
},
child: SalesOrderDialog(pk: state.params['pk']!),
)),
]),
GoRoute(
path: '/events',
Expand Down Expand Up @@ -373,15 +370,13 @@ final List<RouteBase> routes = [
GoRoute(
path: '/pizzas',
name: 'food',
pageBuilder: (context, state) {
return MaterialPage(
key: state.pageKey,
child: FoodScreen(
pk: (state.extra as Event?)?.foodEvent,
event: state.extra as Event?,
),
);
},
pageBuilder: (context, state) => MaterialPage(
key: state.pageKey,
child: FoodScreen(
pk: (state.extra as Event?)?.foodEvent,
event: state.extra as Event?,
),
),
routes: [
GoRoute(
path: 'admin',
Expand Down
26 changes: 14 additions & 12 deletions lib/ui/screens/albums_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,20 @@ class _AlbumsScreenState extends State<AlbumsScreen> {
onRefresh: () async {
await _cubit.load();
},
child: BlocBuilder<AlbumListCubit, AlbumListState>(
builder: (context, listState) {
if (listState.hasException) {
return ErrorScrollView(listState.message!);
} else {
return AlbumListScrollView(
key: const PageStorageKey('albums'),
controller: _controller,
listState: listState,
);
}
},
child: SafeArea(
child: BlocBuilder<AlbumListCubit, AlbumListState>(
builder: (context, listState) {
if (listState.hasException) {
return ErrorScrollView(listState.message!);
} else {
return AlbumListScrollView(
key: const PageStorageKey('albums'),
controller: _controller,
listState: listState,
);
}
},
),
),
),
);
Expand Down
26 changes: 14 additions & 12 deletions lib/ui/screens/calendar_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,20 @@ class _CalendarScreenState extends State<CalendarScreen> {
onRefresh: () async {
await _cubit.load();
},
child: BlocBuilder<CalendarCubit, CalendarState>(
builder: (context, calendarState) {
if (calendarState.hasException) {
return ErrorScrollView(calendarState.message!);
} else {
return CalendarScrollView(
key: const PageStorageKey('calendar'),
controller: _controller,
calendarState: calendarState,
);
}
},
child: SafeArea(
child: BlocBuilder<CalendarCubit, CalendarState>(
builder: (context, calendarState) {
if (calendarState.hasException) {
return ErrorScrollView(calendarState.message!);
} else {
return CalendarScrollView(
key: const PageStorageKey('calendar'),
controller: _controller,
calendarState: calendarState,
);
}
},
),
),
),
);
Expand Down
40 changes: 21 additions & 19 deletions lib/ui/screens/event_admin_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,28 @@ class _EventAdminScreenState extends State<EventAdminScreen> {
context,
).loadRegistrations();
},
child: BlocBuilder<EventAdminCubit, EventAdminState>(
builder: (context, state) {
if (state.hasException) {
return ErrorScrollView(state.message!);
} else if (state.isLoading) {
return const Center(child: CircularProgressIndicator());
} else {
return Scrollbar(
child: ListView.separated(
key: const PageStorageKey('event-admin'),
itemBuilder: (context, index) => _RegistrationTile(
registration: state.registrations[index],
requiresPayment: state.event!.paymentIsRequired,
child: SafeArea(
child: BlocBuilder<EventAdminCubit, EventAdminState>(
builder: (context, state) {
if (state.hasException) {
return ErrorScrollView(state.message!);
} else if (state.isLoading) {
return const Center(child: CircularProgressIndicator());
} else {
return Scrollbar(
child: ListView.separated(
key: const PageStorageKey('event-admin'),
itemBuilder: (context, index) => _RegistrationTile(
registration: state.registrations[index],
requiresPayment: state.event!.paymentIsRequired,
),
separatorBuilder: (_, __) => const Divider(),
itemCount: state.registrations.length,
),
separatorBuilder: (_, __) => const Divider(),
itemCount: state.registrations.length,
),
);
}
},
);
}
},
),
),
),
);
Expand Down
99 changes: 50 additions & 49 deletions lib/ui/screens/event_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -898,24 +898,23 @@ class _EventScreenState extends State<EventScreen> {
actions: [_makeShareEventButton(widget.pk)],
),
body: RefreshIndicator(
onRefresh: () async {
// Await only the event info.
_registrationsCubit.load();
await _eventCubit.load();
},
child: ErrorScrollView(state.message!),
),
onRefresh: () async {
// Await only the event info.
_registrationsCubit.load();
await _eventCubit.load();
},
child: SafeArea(child: ErrorScrollView(state.message!))),
);
} else if (state.isLoading &&
widget.event == null &&
state.result == null) {
return Scaffold(
appBar: ThaliaAppBar(
title: const Text('EVENT'),
actions: [_makeShareEventButton(widget.pk)],
),
body: const Center(child: CircularProgressIndicator()),
);
appBar: ThaliaAppBar(
title: const Text('EVENT'),
actions: [_makeShareEventButton(widget.pk)],
),
body: const SafeArea(
child: Center(child: CircularProgressIndicator())));
} else {
final event = (state.result ?? widget.event)!;
return Scaffold(
Expand All @@ -941,46 +940,48 @@ class _EventScreenState extends State<EventScreen> {
_registrationsCubit.load();
await _eventCubit.load();
},
child: BlocBuilder<RegistrationsCubit, RegistrationsState>(
bloc: _registrationsCubit,
builder: (context, listState) {
return Scrollbar(
controller: _controller,
child: CustomScrollView(
child: SafeArea(
child: BlocBuilder<RegistrationsCubit, RegistrationsState>(
bloc: _registrationsCubit,
builder: (context, listState) {
return Scrollbar(
controller: _controller,
key: const PageStorageKey('event'),
slivers: [
SliverToBoxAdapter(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_makeMap(event),
const Divider(height: 0),
_makeEventInfo(event),
const Divider(),
_makeDescription(event),
],
child: CustomScrollView(
controller: _controller,
key: const PageStorageKey('event'),
slivers: [
SliverToBoxAdapter(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_makeMap(event),
const Divider(height: 0),
_makeEventInfo(event),
const Divider(),
_makeDescription(event),
],
),
),
),
if (event.registrationIsOptional ||
event.registrationIsRequired) ...[
const SliverToBoxAdapter(child: Divider()),
_makeRegistrationsHeader(listState),
_makeRegistrations(listState),
if (listState.isLoadingMore)
const SliverPadding(
padding: EdgeInsets.all(8),
sliver: SliverList(
delegate: SliverChildListDelegate.fixed([
Center(child: CircularProgressIndicator()),
]),
if (event.registrationIsOptional ||
event.registrationIsRequired) ...[
const SliverToBoxAdapter(child: Divider()),
_makeRegistrationsHeader(listState),
_makeRegistrations(listState),
if (listState.isLoadingMore)
const SliverPadding(
padding: EdgeInsets.all(8),
sliver: SliverList(
delegate: SliverChildListDelegate.fixed([
Center(child: CircularProgressIndicator()),
]),
),
),
),
],
],
],
),
);
},
),
);
},
),
),
),
);
Expand Down
38 changes: 20 additions & 18 deletions lib/ui/screens/food_admin_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,26 @@ class _FoodAdminScreenState extends State<FoodAdminScreen> {
onRefresh: () async {
await BlocProvider.of<FoodAdminCubit>(context).load();
},
child: BlocBuilder<FoodAdminCubit, FoodAdminState>(
builder: (context, state) {
if (state.hasException) {
return ErrorScrollView(state.message!);
} else if (state.isLoading) {
return const Center(child: CircularProgressIndicator());
} else {
return Scrollbar(
child: ListView.separated(
key: const PageStorageKey('food-admin'),
itemBuilder: (context, index) => _OrderTile(
order: state.result![index],
),
separatorBuilder: (_, __) => const Divider(),
itemCount: state.result!.length,
));
}
},
child: SafeArea(
child: BlocBuilder<FoodAdminCubit, FoodAdminState>(
builder: (context, state) {
if (state.hasException) {
return ErrorScrollView(state.message!);
} else if (state.isLoading) {
return const Center(child: CircularProgressIndicator());
} else {
return Scrollbar(
child: ListView.separated(
key: const PageStorageKey('food-admin'),
itemBuilder: (context, index) => _OrderTile(
order: state.result![index],
),
separatorBuilder: (_, __) => const Divider(),
itemCount: state.result!.length,
));
}
},
),
),
),
);
Expand Down
Loading

0 comments on commit aa89844

Please sign in to comment.