Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import 'package:flutter / material . dart'; import ' . . / viewmodel / owner _ request _ list _ viewmodel.dart'; class OwnerRequestListPage extends StatefulWidget {
import 'package:fluttermaterialdart';
import viewmodelownerrequestlistviewmodel.dart';
class OwnerRequestListPage extends StatefulWidget
@override
OwnerRequestListPageState createStateOwnerRequestListPageState;
class OwnerRequestListPageState extends State
final OwnerRequestListViewModel viewModel OwnerRequestListViewModel;
@override
Widget buildBuildContext context
return Scaffold
appBar: AppBar
title: const TextReservation Requests'
backgroundColor: Colors.blueGrey,
automaticallyImplyLeading: false,
actions:
PopupMenuButton
onSelected: value
if value 'viewProfile'
Navigator.pushNamedcontextrestaurantProfilePage;
else if value 'logout'
handleLogoutcontext;
itemBuilder: context
const PopupMenuItem
value: 'viewProfile',
child: TextView Restaurant Profile'
const PopupMenuItem
value: 'logout',
child: TextLogout
body: buildReservationList
;
Widget buildReservationList
return viewModel.reservationRequests.isEmpty
const Center
child: Text
No reservation requests',
style: TextStylefontSize:
: ListView.builder
itemCount: viewModel.reservationRequests.length,
itemBuilder: context index
return buildReservationRequestCard
context, viewModel.reservationRequestsindex;
;
Widget buildReservationRequestCard
BuildContext context, Reservation reservation
return Card
margin: const EdgeInsets.all
child: ListTile
title: Text
$reservationuserName $reservationnumberOfGuests Guests'
subtitle: TextDate: $reservationdateTime
trailing: Row
mainAxisSize: MainAxisSize.min,
children:
ElevatedButton
onPressed:
handleAcceptcontext reservation;
style: ElevatedButton.styleFrombackgroundColor: Colors.blueGrey
child: const TextAccept
style: TextStyle
color: Colors.black, fontWeight: FontWeight.bold
const SizedBoxwidth:
ElevatedButton
onPressed:
handleRejectcontext reservation;
style: ElevatedButton.styleFrombackgroundColor: Colors.orangeAccent
child: const Text
'Reject',
style:
TextStylecolor: Colors.black, fontWeight: FontWeight.bold
;
void handleAcceptBuildContext context, Reservation reservation
viewModel.acceptReservationreservation;
showSnackbarcontext 'Reservation accepted';
void handleRejectBuildContext context, Reservation reservation
viewModel.rejectReservationreservation;
showSnackbarcontext 'Reservation rejected';
void handleLogoutBuildContext context
Navigator.pushReplacementNamedcontext;
void showSnackbarBuildContext context, String message
ScaffoldMessenger.ofcontextshowSnackBar
SnackBar
content: Textmessage
duration: Durationseconds:
actionOverflowThreshold:
;
MAKE THIS CODE HAVE FIREBASE DATABASE WHEN YOU CLICK SIGN IN BY USERNAME AND PASSWORD, GOES TO THIS PAGE
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started