6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 638686c3
Changed files
.../components/current_bookings_tab_view.dart | 113 ++++++++++++--------- 1 file changed, 64 insertions(+), 49 deletions(-)
Diff
diff --git a/comwell_key_app/lib/overview/components/current_bookings_tab_view.dart b/comwell_key_app/lib/overview/components/current_bookings_tab_view.dart
index 29651167..7481871e 100644
--- a/comwell_key_app/lib/overview/components/current_bookings_tab_view.dart
+++ b/comwell_key_app/lib/overview/components/current_bookings_tab_view.dart
@@ -1,6 +1,9 @@
import 'package:comwell_key_app/overview/components/current_booking_list_item_view.dart';
+import 'package:comwell_key_app/overview/cubit/overview_cubit.dart';
import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/themes/light_theme.dart';
import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
class CurrentBookingsTabView extends StatelessWidget {
final Iterable<Booking> bookings;
@@ -19,60 +22,72 @@ class CurrentBookingsTabView extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
- if (bookings.isEmpty) {
- return Column(
- children: [
- const SizedBox(
- height: 20,
- ),
- Container(
- height: 276,
- decoration: BoxDecoration(
- image: const DecorationImage(
- image: AssetImage("assets/images/no_current_bookings_background.jpeg"),
- fit: BoxFit.cover,
- ),
- borderRadius: BorderRadius.circular(10),
- border: Border.all(color: Colors.transparent)),
- margin: const EdgeInsets.symmetric(horizontal: 8),
- child: Padding(
- padding: const EdgeInsets.all(16),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.end,
- crossAxisAlignment: CrossAxisAlignment.start,
+ final cubit = context.read<OverviewCubit>();
+ return RefreshIndicator(
+ backgroundColor: sandColor[80],
+ color: sandColor[10],
+ onRefresh: () async {
+ await cubit.fetchBookings();
+ },
+ child: Builder(
+ builder: (context) {
+ if (bookings.isEmpty) {
+ return ListView(
children: [
- Text(
- bookingsTitle,
- textAlign: TextAlign.start,
- style: theme.textTheme.headlineMedium?.copyWith(
- color: Colors.white,
- ),
+ const SizedBox(
+ height: 20,
),
- const SizedBox(height: 6),
- Text(
- textAlign: TextAlign.start,
- bookingsSubtitle,
- style: theme.textTheme.bodySmall?.copyWith(
- color: Colors.grey.shade500,
+ Container(
+ height: 276,
+ decoration: BoxDecoration(
+ image: const DecorationImage(
+ image: AssetImage("assets/images/no_current_bookings_background.jpeg"),
+ fit: BoxFit.cover,
+ ),
+ borderRadius: BorderRadius.circular(10),
+ border: Border.all(color: Colors.transparent)),
+ margin: const EdgeInsets.symmetric(horizontal: 8),
+ child: Padding(
+ padding: const EdgeInsets.all(16),
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.end,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ bookingsTitle,
+ textAlign: TextAlign.start,
+ style: theme.textTheme.headlineMedium?.copyWith(
+ color: Colors.white,
+ ),
+ ),
+ const SizedBox(height: 6),
+ Text(
+ textAlign: TextAlign.start,
+ bookingsSubtitle,
+ style: theme.textTheme.bodySmall?.copyWith(
+ color: Colors.grey.shade500,
+ ),
+ ),
+ ],
+ ),
),
),
+ const SizedBox(
+ height: 40,
+ ),
],
- ),
- ),
- ),
- const SizedBox(
- height: 40,
- ),
- ],
- );
- } else {
- return ListView.builder(
- shrinkWrap: true,
- itemCount: bookings.length,
- itemBuilder: (context, index) => CurrentBookingListItem(
- booking: bookings.elementAt(index),
+ );
+ } else {
+ return ListView.builder(
+ shrinkWrap: true,
+ itemCount: bookings.length,
+ itemBuilder: (context, index) => CurrentBookingListItem(
+ booking: bookings.elementAt(index),
+ ),
+ );
+ }
+ },
),
- );
- }
+ );
}
}