6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit fcfa80dc
Changed files
.../lib/common/components/comwell_app_bar.dart | 3 +- .../lib/find_booking/find_booking_page.dart | 6 +- .../components/current_bookings_tab_view.dart | 19 +- .../lib/overview/cubit/overview_state.dart | 1 + comwell_key_app/lib/overview/overview_page.dart | 208 ++++++++++++--------- .../overview/repository/overview_repository.dart | 4 +- .../components/address_bottom_sheet.dart | 3 +- .../components/change_password_modal.dart | 3 +- .../profile_settings/profile_settings_page.dart | 3 +- 9 files changed, 128 insertions(+), 122 deletions(-)
Diff
diff --git a/comwell_key_app/lib/common/components/comwell_app_bar.dart b/comwell_key_app/lib/common/components/comwell_app_bar.dart
index f2c53086..189470f5 100644
--- a/comwell_key_app/lib/common/components/comwell_app_bar.dart
+++ b/comwell_key_app/lib/common/components/comwell_app_bar.dart
@@ -38,7 +38,6 @@ class ComwellAppBar extends StatelessWidget implements PreferredSizeWidget {
child: RoundIconButton(
color: Colors.white,
icon: "assets/icons/arrow-right.svg",
- color: Colors.white,
onPressed: () {
Navigator.of(context).pop();
},
@@ -49,7 +48,7 @@ class ComwellAppBar extends StatelessWidget implements PreferredSizeWidget {
child: RoundIconButton(
color: Colors.white,
icon: "assets/icons/user-open.svg",
- color: Colors.white,
+
onPressed: () {
context.goNamed(AppRoutes.profile.name);
},
diff --git a/comwell_key_app/lib/find_booking/find_booking_page.dart b/comwell_key_app/lib/find_booking/find_booking_page.dart
index b7d977d5..936b73c0 100644
--- a/comwell_key_app/lib/find_booking/find_booking_page.dart
+++ b/comwell_key_app/lib/find_booking/find_booking_page.dart
@@ -1,8 +1,5 @@
import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
import 'package:comwell_key_app/common/components/comwell_text_field.dart';
-import 'package:comwell_key_app/common/components/round_icon_button.dart';
-import 'package:comwell_key_app/find_booking/components/hotel_tab_view.dart';
-import 'package:comwell_key_app/find_booking/loading_page.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/routing/app_routes.dart';
@@ -11,7 +8,6 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
-import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
class FindBookingPage extends StatefulWidget {
const FindBookingPage({super.key});
@@ -63,7 +59,7 @@ class FindBookingPageState extends State<FindBookingPage>
if (mounted) {
context.pop();
- context.pop();
+
}
}
@override
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 f51d3aa0..5c751839 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
@@ -63,24 +63,7 @@ class CurrentBookingsTabView extends StatelessWidget {
const SizedBox(
height: 40,
),
- SizedBox(
- width: 165,
- height: 40,
- child: OutlinedButton(
- onPressed: () {},
- child: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- SvgPicture.asset('assets/icons/loop.svg'),
- const SizedBox(width: 8),
- Text(
- 'overview_add_booking'.tr(),
- style: theme.textTheme.headlineSmall,
- )
- ],
- ),
- ),
- )
+
],
);
} else {
diff --git a/comwell_key_app/lib/overview/cubit/overview_state.dart b/comwell_key_app/lib/overview/cubit/overview_state.dart
index d965dd38..ac4c9245 100644
--- a/comwell_key_app/lib/overview/cubit/overview_state.dart
+++ b/comwell_key_app/lib/overview/cubit/overview_state.dart
@@ -21,6 +21,7 @@ final class OverviewError extends OverviewState {
final class OverviewLoaded extends OverviewState {
final Bookings bookings;
+
const OverviewLoaded({required this.bookings});
@override
diff --git a/comwell_key_app/lib/overview/overview_page.dart b/comwell_key_app/lib/overview/overview_page.dart
index 44bcd131..7e4752e8 100644
--- a/comwell_key_app/lib/overview/overview_page.dart
+++ b/comwell_key_app/lib/overview/overview_page.dart
@@ -3,6 +3,7 @@ import 'package:comwell_key_app/common/components/generic_dialog.dart';
import 'package:comwell_key_app/overview/components/bookings_tab_view.dart';
import 'package:comwell_key_app/overview/components/current_bookings_tab_view.dart';
import 'package:comwell_key_app/overview/cubit/overview_cubit.dart';
+import 'package:comwell_key_app/overview/models/bookings.dart';
import 'package:comwell_key_app/routing/app_routes.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
import 'package:easy_localization/easy_localization.dart';
@@ -38,106 +39,87 @@ class OverviewTabViewState extends State<OverviewPage>
final OverviewCubit overviewCubit = BlocProvider.of<OverviewCubit>(context);
overviewCubit.fetchBookings();
- return BlocListener<OverviewCubit, OverviewState>(listener:
- (context, state) {
- if (state is OverviewNoBookingFound) {
- showNotFoundDialog(context);
- }
- }, child:
- BlocBuilder<OverviewCubit, OverviewState>(
- builder: (context, state) {
- return Scaffold(
- backgroundColor: Colors.white,
- appBar: const ComwellAppBar(
- shouldShowBackButton: false,
- ),
- body: SafeArea(
- child: Column(
- children: [
- Padding(
- padding: const EdgeInsets.all(8),
- child: Container(
- height: 39,
- decoration: BoxDecoration(
- color: sandColor[20],
- borderRadius: BorderRadius.circular(25),
- ),
- child: TabBar(
- controller: _tabController,
- indicatorPadding: const EdgeInsets.all(8),
- indicatorSize: TabBarIndicatorSize.tab,
- indicator: BoxDecoration(
+ return BlocListener<OverviewCubit, OverviewState>(
+ listener: (context, state) {
+ if (state is OverviewNoBookingFound) {
+ Future.delayed(const Duration(seconds: 4), () {
+ showNotFoundDialog(context);
+ });
+ }
+ },
+ child: BlocBuilder<OverviewCubit, OverviewState>(
+ builder: (context, state) {
+ return Scaffold(
+ backgroundColor: Colors.white,
+ appBar: const ComwellAppBar(
+ shouldShowBackButton: false,
+ ),
+ body: SafeArea(
+ child: Column(
+ children: [
+ Padding(
+ padding: const EdgeInsets.all(8),
+ child: Container(
+ height: 39,
+ decoration: BoxDecoration(
+ color: sandColor[20],
borderRadius: BorderRadius.circular(25),
- color: sandColor,
),
- labelColor: Colors.white,
- labelStyle: Theme.of(context).textTheme.bodyMedium,
- unselectedLabelColor: Colors.black,
- dividerColor: Colors.transparent,
- tabs: [
- Tab(
- text: 'overview_tabbar_active'.tr(),
+ child: TabBar(
+ controller: _tabController,
+ indicatorPadding: const EdgeInsets.all(8),
+ indicatorSize: TabBarIndicatorSize.tab,
+ indicator: BoxDecoration(
+ borderRadius: BorderRadius.circular(25),
+ color: sandColor,
),
- Tab(text: 'overview_tabbar_past'.tr()),
- Tab(text: 'overview_tabbar_cancelled'.tr()),
- ],
+ labelColor: Colors.white,
+ labelStyle: Theme.of(context).textTheme.bodyMedium,
+ unselectedLabelColor: Colors.black,
+ dividerColor: Colors.transparent,
+ tabs: [
+ Tab(
+ text: 'overview_tabbar_active'.tr(),
+ ),
+ Tab(text: 'overview_tabbar_past'.tr()),
+ Tab(text: 'overview_tabbar_cancelled'.tr()),
+ ],
+ ),
),
),
- ),
- state is OverviewLoaded
- ? Expanded(
- child: TabBarView(
- controller: _tabController,
- children: [
- CurrentBookingsTabView(
- bookings: state.bookings.current,
- bookingsTitle: 'no_current_bookings'.tr(),
- bookingsSubtitle:
- 'no_current_bookings_subtitle'.tr(),
- bookingsImage:
- 'assets/images/no_current_bookings_background.jpeg'),
- BookingsTabView(
- bookings: state.bookings.past,
- bookingsTitle: 'no_past_bookings_title'.tr(),
- bookingsSubtitle:
- 'no_past_bookings_subtitle'.tr(),
- bookingsIcon: 'assets/icons/account.svg',
- isCancelled: false),
- BookingsTabView(
- bookings: state.bookings.cancelled,
- bookingsTitle:
- 'no_cancelled_booking_title'.tr(),
- bookingsSubtitle:
- 'no_cancelled_booking_subtitle'.tr(),
- bookingsIcon: 'assets/icons/thumbs-up.svg',
- isCancelled: true),
- ],
- ),
- )
- : ,
- OutlinedButton.icon(
- onPressed: () async {
- context.pushNamed(AppRoutes.findBooking.name);
- },
- icon:
- Icon(Icons.search, color: Theme.of(context).dividerColor),
- label: Text(
- 'find_booking'.tr(),
- style: TextStyle(color: Theme.of(context).dividerColor),
- ),
- style: OutlinedButton.styleFrom(
- side: BorderSide(color: Theme.of(context).dividerColor),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(25),
+ if(state is OverviewLoaded)...[
+ OverviewTabView(tabController: _tabController, bookings: (state).bookings),
+ ] else if(state is OverviewError) ...[
+ OverviewTabView(tabController: _tabController, bookings: Bookings(cancelled: [], current: [], past: [])),
+ ] else if(state is OverviewNoBookingFound)...[
+ OverviewTabView(tabController: _tabController, bookings: state.bookings),
+ ] else...[
+ OverviewTabView(tabController: _tabController, bookings: Bookings(cancelled: [], current: [], past: [])),
+ ],
+ OutlinedButton.icon(
+ onPressed: () async {
+ context.pushNamed(AppRoutes.findBooking.name);
+ },
+ icon: Icon(Icons.search,
+ color: Theme.of(context).dividerColor),
+ label: Text(
+ 'find_booking'.tr(),
+ style: TextStyle(color: Theme.of(context).dividerColor),
+ ),
+ style: OutlinedButton.styleFrom(
+ side: BorderSide(color: Theme.of(context).dividerColor),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(25),
+ ),
),
),
- ),
- ],
+ ],
+ ),
),
- ),
- );
- },
- ),);
+ );
+ },
+ ),
+ );
}
Future<void> showNotFoundDialog(BuildContext context) {
@@ -161,3 +143,45 @@ class OverviewTabViewState extends State<OverviewPage>
);
}
}
+
+class OverviewTabView extends StatelessWidget {
+ const OverviewTabView({
+ super.key,
+ required TabController tabController,
+ required this.bookings,
+ }) : _tabController = tabController;
+
+ final TabController _tabController;
+ final Bookings bookings;
+
+ @override
+ Widget build(BuildContext context) {
+ return Expanded(
+ child: TabBarView(
+ controller: _tabController,
+ children: [
+ CurrentBookingsTabView(
+ bookings: bookings.current,
+ bookingsTitle: 'no_current_bookings'.tr(),
+ bookingsSubtitle:
+ 'no_current_bookings_subtitle'.tr(),
+ bookingsImage:
+ 'assets/images/no_current_bookings_background.jpeg'),
+ BookingsTabView(
+ bookings: bookings.past,
+ bookingsTitle: 'no_past_bookings_title'.tr(),
+ bookingsSubtitle: 'no_past_bookings_subtitle'.tr(),
+ bookingsIcon: 'assets/icons/account.svg',
+ isCancelled: false),
+ BookingsTabView(
+ bookings: bookings.cancelled,
+ bookingsTitle: 'no_cancelled_booking_title'.tr(),
+ bookingsSubtitle:
+ 'no_cancelled_booking_subtitle'.tr(),
+ bookingsIcon: 'assets/icons/thumbs-up.svg',
+ isCancelled: true),
+ ],
+ ),
+ );
+ }
+}
diff --git a/comwell_key_app/lib/overview/repository/overview_repository.dart b/comwell_key_app/lib/overview/repository/overview_repository.dart
index 428a8143..e9357f8c 100644
--- a/comwell_key_app/lib/overview/repository/overview_repository.dart
+++ b/comwell_key_app/lib/overview/repository/overview_repository.dart
@@ -17,7 +17,7 @@ class OverviewRepository {
}
Future<Booking?> findBooking(String bookingReference, String lastName) async {
- return null;await Booking.fromJson(json);
+ return await Booking.fromJson(json);
}
}
@@ -29,7 +29,7 @@ final json = {
"endDate": "2024-10-25T12:00:00",
"status": "current",
"image": "assets/images/current_room.png",
- "hotelName": "Seaside Resort",
+ "hotelName": "Hej Resort",
"hotelCode": "SR001",
"roomType": "Deluxe",
"adults": 2,
diff --git a/comwell_key_app/lib/profile_settings/components/address_bottom_sheet.dart b/comwell_key_app/lib/profile_settings/components/address_bottom_sheet.dart
index 4f4d7ec2..e3988dfc 100644
--- a/comwell_key_app/lib/profile_settings/components/address_bottom_sheet.dart
+++ b/comwell_key_app/lib/profile_settings/components/address_bottom_sheet.dart
@@ -1,4 +1,5 @@
-import 'package:comwell_key_app/components/round_icon_button.dart';
+
+import 'package:comwell_key_app/common/components/round_icon_button.dart';
import 'package:comwell_key_app/profile_settings/components/comwell_text_field.dart';
import 'package:comwell_key_app/profile_settings/cubit/profile_settings_cubit.dart';
import 'package:comwell_key_app/profile_settings/model/address.dart';
diff --git a/comwell_key_app/lib/profile_settings/components/change_password_modal.dart b/comwell_key_app/lib/profile_settings/components/change_password_modal.dart
index d1da8db4..e88800a1 100644
--- a/comwell_key_app/lib/profile_settings/components/change_password_modal.dart
+++ b/comwell_key_app/lib/profile_settings/components/change_password_modal.dart
@@ -1,4 +1,5 @@
-import 'package:comwell_key_app/components/bottom_sheet_widget.dart';
+import 'package:comwell_key_app/common/components/bottom_sheet_widget.dart';
+
import 'package:flutter/material.dart';
class ChangePasswordModal extends StatefulWidget {
diff --git a/comwell_key_app/lib/profile_settings/profile_settings_page.dart b/comwell_key_app/lib/profile_settings/profile_settings_page.dart
index 3ed1a8ac..af90ec7b 100644
--- a/comwell_key_app/lib/profile_settings/profile_settings_page.dart
+++ b/comwell_key_app/lib/profile_settings/profile_settings_page.dart
@@ -1,4 +1,5 @@
-import 'package:comwell_key_app/components/comwell_app_bar.dart';
+
+import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
import 'package:comwell_key_app/profile_settings/components/text_field_trailing_icon.dart';
import 'package:comwell_key_app/profile_settings/components/address_bottom_sheet.dart';
import 'package:comwell_key_app/profile_settings/components/comwell_text_field.dart';