mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
67 lines
2.3 KiB
Dart
67 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import '../../../../utils/helpers/app_size.dart';
|
|
import '../../../../utils/resource_manager/color_manager.dart';
|
|
import '../../../shared_widgets/default_button.dart';
|
|
import '../blocs/upcoming_bookings_bloc/upcoming_bookings_bloc.dart';
|
|
import 'booking_card_widget.dart';
|
|
|
|
class UpcomingBookingsWidget extends StatelessWidget {
|
|
const UpcomingBookingsWidget({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'Upcoming Bookings',
|
|
style: TextStyle(
|
|
fontSize: 15,
|
|
color: ColorsManager.grayColor,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
BlocBuilder<UpcomingBookingsBloc, UpcomingBookingsState>(
|
|
builder: (context, state) {
|
|
if (state is UpcomingBookingLoadingState) {
|
|
//should use CustomLoadingWidget
|
|
return CircularProgressIndicator();
|
|
} else if (state is UpcomingBookingErrorState) {
|
|
//shold use CustomErrorWidget
|
|
return DefaultButton(
|
|
onPressed: () => context
|
|
.read<UpcomingBookingsBloc>()
|
|
.add(GetUpcomingBookingsEvent()),
|
|
child: Text('Try again'),
|
|
);
|
|
} else if (state is UpcomingBookingLoadedState) {
|
|
return SizedBox(
|
|
height: deviceHeight(context) * 0.3,
|
|
child: state.upcomingBookings.isEmpty
|
|
? Text('You Dont Have Upcoming Bookings')
|
|
: ListView.separated(
|
|
separatorBuilder: (context, index) => SizedBox(
|
|
height: 10,
|
|
),
|
|
itemCount: state.upcomingBookings.length,
|
|
itemBuilder: (context, index) {
|
|
final upcomingBooking = state.upcomingBookings[index];
|
|
return BookingCardWidget(
|
|
bookingModel: upcomingBooking);
|
|
},
|
|
),
|
|
);
|
|
} else {
|
|
return SizedBox();
|
|
}
|
|
},
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|