feat: Fix calendar view using a stack
This commit is contained in:
@@ -84,6 +84,9 @@ class CalendarPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CalendarPageState extends State<CalendarPage> {
|
class CalendarPageState extends State<CalendarPage> {
|
||||||
|
/// State for the "refreshing" overlay.
|
||||||
|
OverlayEntry? _overlayEntry;
|
||||||
|
|
||||||
List<Widget> _renderWeekdayList(
|
List<Widget> _renderWeekdayList(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
Weekday day,
|
Weekday day,
|
||||||
@@ -177,112 +180,20 @@ class CalendarPageState extends State<CalendarPage> {
|
|||||||
listenWhen: (previous, current) =>
|
listenWhen: (previous, current) =>
|
||||||
previous.refreshing != current.refreshing,
|
previous.refreshing != current.refreshing,
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
// Force an update
|
|
||||||
if (!state.refreshing) {
|
if (!state.refreshing) {
|
||||||
setState(() {});
|
_overlayEntry?.remove();
|
||||||
}
|
_overlayEntry?.dispose();
|
||||||
},
|
_overlayEntry = null;
|
||||||
child: WillPopScope(
|
} else {
|
||||||
onWillPop: () async =>
|
_overlayEntry = OverlayEntry(
|
||||||
!context.read<CalendarBloc>().state.refreshing,
|
builder: (context) => SafeArea(
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Positioned(
|
const ModalBarrier(
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
top: 0,
|
|
||||||
bottom: 0,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsetsGeometry.symmetric(
|
|
||||||
horizontal: 12,
|
|
||||||
),
|
|
||||||
child: CustomScrollView(
|
|
||||||
slivers: [
|
|
||||||
// Render all available weekdays
|
|
||||||
..._renderWeekdayList(
|
|
||||||
context,
|
|
||||||
Weekday.unknown,
|
|
||||||
airingAnimeMap,
|
|
||||||
),
|
|
||||||
..._renderWeekdayList(
|
|
||||||
context,
|
|
||||||
Weekday.monday,
|
|
||||||
airingAnimeMap,
|
|
||||||
),
|
|
||||||
..._renderWeekdayList(
|
|
||||||
context,
|
|
||||||
Weekday.tuesday,
|
|
||||||
airingAnimeMap,
|
|
||||||
),
|
|
||||||
..._renderWeekdayList(
|
|
||||||
context,
|
|
||||||
Weekday.wednesday,
|
|
||||||
airingAnimeMap,
|
|
||||||
),
|
|
||||||
..._renderWeekdayList(
|
|
||||||
context,
|
|
||||||
Weekday.thursday,
|
|
||||||
airingAnimeMap,
|
|
||||||
),
|
|
||||||
..._renderWeekdayList(
|
|
||||||
context,
|
|
||||||
Weekday.friday,
|
|
||||||
airingAnimeMap,
|
|
||||||
),
|
|
||||||
..._renderWeekdayList(
|
|
||||||
context,
|
|
||||||
Weekday.saturday,
|
|
||||||
airingAnimeMap,
|
|
||||||
),
|
|
||||||
..._renderWeekdayList(
|
|
||||||
context,
|
|
||||||
Weekday.sunday,
|
|
||||||
airingAnimeMap,
|
|
||||||
),
|
|
||||||
|
|
||||||
// Provide a nice bottom padding, while keeping the elastic effect attached
|
|
||||||
// to the bottom-most edge.
|
|
||||||
const SliverToBoxAdapter(
|
|
||||||
child: SizedBox(
|
|
||||||
height: 16,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
top: 0,
|
|
||||||
bottom: 0,
|
|
||||||
child: BlocBuilder<CalendarBloc, CalendarState>(
|
|
||||||
buildWhen: (previous, current) =>
|
|
||||||
previous.refreshing != current.refreshing,
|
|
||||||
builder: (context, state) {
|
|
||||||
if (!state.refreshing) {
|
|
||||||
return const SizedBox();
|
|
||||||
}
|
|
||||||
|
|
||||||
return const ModalBarrier(
|
|
||||||
dismissible: false,
|
dismissible: false,
|
||||||
color: Colors.black54,
|
color: Colors.black54,
|
||||||
);
|
),
|
||||||
},
|
Center(
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
top: 0,
|
|
||||||
bottom: 0,
|
|
||||||
child: BlocBuilder<CalendarBloc, CalendarState>(
|
|
||||||
builder: (context, state) {
|
|
||||||
if (!state.refreshing) {
|
|
||||||
return const SizedBox();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Center(
|
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 150,
|
width: 150,
|
||||||
height: 150,
|
height: 150,
|
||||||
@@ -299,22 +210,89 @@ class CalendarPageState extends State<CalendarPage> {
|
|||||||
padding: EdgeInsets.all(25),
|
padding: EdgeInsets.all(25),
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
),
|
),
|
||||||
Text(
|
BlocBuilder<CalendarBloc, CalendarState>(
|
||||||
t.settings.importIndicator(
|
builder: (context, state) => Text(
|
||||||
current: state.refreshingCount,
|
t.settings.importIndicator(
|
||||||
total: state.refreshingTotal,
|
current: state.refreshingCount,
|
||||||
|
total: state.refreshingTotal,
|
||||||
|
),
|
||||||
|
style: Theme.of(
|
||||||
|
context,
|
||||||
|
).textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
},
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
);
|
||||||
|
Overlay.of(context).insert(_overlayEntry!);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: WillPopScope(
|
||||||
|
onWillPop: () async =>
|
||||||
|
!context.read<CalendarBloc>().state.refreshing,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsetsGeometry.symmetric(
|
||||||
|
horizontal: 12,
|
||||||
|
),
|
||||||
|
child: CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
// Render all available weekdays
|
||||||
|
..._renderWeekdayList(
|
||||||
|
context,
|
||||||
|
Weekday.unknown,
|
||||||
|
airingAnimeMap,
|
||||||
|
),
|
||||||
|
..._renderWeekdayList(
|
||||||
|
context,
|
||||||
|
Weekday.monday,
|
||||||
|
airingAnimeMap,
|
||||||
|
),
|
||||||
|
..._renderWeekdayList(
|
||||||
|
context,
|
||||||
|
Weekday.tuesday,
|
||||||
|
airingAnimeMap,
|
||||||
|
),
|
||||||
|
..._renderWeekdayList(
|
||||||
|
context,
|
||||||
|
Weekday.wednesday,
|
||||||
|
airingAnimeMap,
|
||||||
|
),
|
||||||
|
..._renderWeekdayList(
|
||||||
|
context,
|
||||||
|
Weekday.thursday,
|
||||||
|
airingAnimeMap,
|
||||||
|
),
|
||||||
|
..._renderWeekdayList(
|
||||||
|
context,
|
||||||
|
Weekday.friday,
|
||||||
|
airingAnimeMap,
|
||||||
|
),
|
||||||
|
..._renderWeekdayList(
|
||||||
|
context,
|
||||||
|
Weekday.saturday,
|
||||||
|
airingAnimeMap,
|
||||||
|
),
|
||||||
|
..._renderWeekdayList(
|
||||||
|
context,
|
||||||
|
Weekday.sunday,
|
||||||
|
airingAnimeMap,
|
||||||
|
),
|
||||||
|
|
||||||
|
// Provide a nice bottom padding, while keeping the elastic effect attached
|
||||||
|
// to the bottom-most edge.
|
||||||
|
const SliverToBoxAdapter(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user