Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a safearea around all the screens #264

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 29 additions & 34 deletions lib/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,28 @@ final List<GoRoute> 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 @@ -239,15 +236,13 @@ final List<GoRoute> 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
28 changes: 15 additions & 13 deletions lib/ui/screens/album_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,22 @@ class _AlbumScreenState extends State<AlbumScreen> {
),
],
),
body: PhotoViewGallery.builder(
loadingBuilder: (_, __) => const Center(
child: CircularProgressIndicator(),
),
backgroundDecoration: const BoxDecoration(
color: Colors.transparent,
),
itemCount: album.photos.length,
builder: (context, i) => PhotoViewGalleryPageOptions(
imageProvider: NetworkImage(album.photos[i].full),
minScale: PhotoViewComputedScale.contained * 0.8,
maxScale: PhotoViewComputedScale.covered * 2,
body: SafeArea(
child: PhotoViewGallery.builder(
loadingBuilder: (_, __) => const Center(
child: CircularProgressIndicator(),
),
backgroundDecoration: const BoxDecoration(
color: Colors.transparent,
),
itemCount: album.photos.length,
builder: (context, i) => PhotoViewGalleryPageOptions(
imageProvider: NetworkImage(album.photos[i].full),
minScale: PhotoViewComputedScale.contained * 0.8,
maxScale: PhotoViewComputedScale.covered * 2,
),
pageController: pageController,
),
pageController: pageController,
),
);
},
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