mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 18:16:21 +00:00
make the UI and link it with its blocs
This commit is contained in:
@ -0,0 +1,66 @@
|
||||
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/past_bookings_bloc/past_bookings_bloc.dart';
|
||||
import 'booking_card_widget.dart';
|
||||
|
||||
class PastBookingsWidget extends StatelessWidget {
|
||||
const PastBookingsWidget({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Past Bookings',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: ColorsManager.grayColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
BlocBuilder<PastBookingsBloc, PastBookingsState>(
|
||||
builder: (context, state) {
|
||||
if (state is PastBookingLoadingState) {
|
||||
//should use CustomLoadingWidget
|
||||
return CircularProgressIndicator();
|
||||
} else if (state is PastBookingErrorState) {
|
||||
//shold use CustomErrorWidget
|
||||
return DefaultButton(
|
||||
onPressed: () => context
|
||||
.read<PastBookingsBloc>()
|
||||
.add(GetPastBookingsEvent()),
|
||||
child: Text('Try again'),
|
||||
);
|
||||
} else if (state is PastBookingLoadedState) {
|
||||
return SizedBox(
|
||||
height: deviceHeight(context) * 0.3,
|
||||
child: state.pastBookings.isEmpty
|
||||
? Text('You Dont Have past Bookings')
|
||||
: ListView.separated(
|
||||
separatorBuilder: (context, index) => SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
itemCount: state.pastBookings.length,
|
||||
itemBuilder: (context, index) {
|
||||
final pastBooking = state.pastBookings[index];
|
||||
return BookingCardWidget(bookingModel: pastBooking);
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return SizedBox();
|
||||
}
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user