Skip to content

Commit

Permalink
Merge pull request #53 from PLADI-ALM/feat/PDA-16-booking-resource
Browse files Browse the repository at this point in the history
fix, feat: 장비/차량 예약 내 선택일시 버그, 예약 내역 아이템 세부 화면 연결
  • Loading branch information
chayoosang authored Dec 3, 2023
2 parents 0cf9011 + c4d8be2 commit c119185
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 45 deletions.
6 changes: 6 additions & 0 deletions lib/Model/model/booking/car_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ class CarBookingHistoryData {
@JsonSerializable()
class CarBookingHistory {
int id;
int targetId;
String? reservatorName;
String? reservatorPhone;
String name;
String? location;
String startDateTime;
Expand All @@ -144,6 +147,9 @@ class CarBookingHistory {

CarBookingHistory({
required this.id,
required this.targetId,
this.reservatorName,
this.reservatorPhone,
required this.name,
this.location,
required this.startDateTime,
Expand Down
6 changes: 6 additions & 0 deletions lib/Model/model/booking/car_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions lib/Model/model/booking/office_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ class OfficeBookingHistoryData {
@JsonSerializable()
class OfficeBookingHistory {
int id;
int targetId;
String? reservatorName;
String? reservatorPhone;
String name;
String? detailInfo;
String startDateTime;
Expand All @@ -242,6 +245,9 @@ class OfficeBookingHistory {

OfficeBookingHistory({
required this.id,
required this.targetId,
this.reservatorName,
this.reservatorPhone,
required this.name,
this.detailInfo,
required this.startDateTime,
Expand Down
6 changes: 6 additions & 0 deletions lib/Model/model/booking/office_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions lib/Model/model/booking/resource_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ class ResourceBookingHistoryData {
@JsonSerializable()
class ResourceBookingHistory {
int id;
int targetId;
String? reservatorName;
String? reservatorPhone;
String name;
String? location;
String startDateTime;
Expand All @@ -245,6 +248,9 @@ class ResourceBookingHistory {

ResourceBookingHistory({
required this.id,
required this.targetId,
this.reservatorName,
this.reservatorPhone,
required this.name,
this.location,
required this.startDateTime,
Expand Down
6 changes: 6 additions & 0 deletions lib/Model/model/booking/resource_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 34 additions & 2 deletions lib/View/booking/component/booking_item_card.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import 'package:flutter/material.dart';
import 'package:frontend/Presenter/booking/resource_service.dart';
import 'package:frontend/View/booking/screen/booking_screen.dart';
import 'package:frontend/View/booking/screen/office_detail_screen.dart';

import '../../../Presenter/booking/car_service.dart';
import '../../../Presenter/booking/office_service.dart';
import '../../colors.dart';
import '../screen/booking_history_screen.dart';
import '../screen/booking_return_screen.dart';
import '../screen/general_detail_screen.dart';
import 'booking_status_item.dart';

enum BookingManageType { cancel, giveBack, reject, allow } // 취소, 반납, 반려, 허가
Expand All @@ -15,6 +17,9 @@ class BookingItemCard extends StatefulWidget {
final bool isAdmin;
final BookingType type;
final int id;
final int targetId;
final String? reservatorName;
final String? reservatorPhone;
final String name;
final String? location;
final String startDateTime;
Expand All @@ -26,6 +31,9 @@ class BookingItemCard extends StatefulWidget {
required this.isAdmin,
required this.type,
required this.id,
required this.targetId,
this.reservatorName,
this.reservatorPhone,
required this.name,
required this.location,
required this.startDateTime,
Expand Down Expand Up @@ -81,7 +89,8 @@ class _BookingItemCardState extends State<BookingItemCard> {
),
Expanded(child: Container()),
SizedBox(
child: IconButton(onPressed: (){},
child: IconButton(
onPressed: didTapMoveToDetailButton,
style: IconButton.styleFrom(padding: EdgeInsets.zero),
icon: const Icon(Icons.arrow_forward_ios, size: 16,)
),
Expand All @@ -90,7 +99,22 @@ class _BookingItemCardState extends State<BookingItemCard> {
),
const Divider(thickness: 1.2,),

/// 예약일시, 이용목적, 예약상태
/// 예약자, 예약일시, 이용목적, 예약상태
widget.isAdmin
? Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Text('예약자', style: titleStyle,),
),
Text('${widget.reservatorName} (${widget.reservatorPhone})', style: contentStyle, overflow: TextOverflow.ellipsis)
],
),
)
: const SizedBox(height: 0,),

Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
Expand Down Expand Up @@ -336,4 +360,12 @@ class _BookingItemCardState extends State<BookingItemCard> {
parent!.reloadData(response);
}

void didTapMoveToDetailButton() {
switch (widget.type) {
case BookingType.office:
Navigator.of(context).push(MaterialPageRoute(builder: (_) => OfficeDetailScreen(officeId: widget.targetId,)));
default:
Navigator.of(context).push(MaterialPageRoute(builder: (_) => GeneralDetailScreen(type: widget.type, id: widget.targetId,)));
}
}
}
2 changes: 1 addition & 1 deletion lib/View/booking/component/custom_range_calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class _CustomRangeCalenderState extends State<CustomRangeCalender> {
}

/// 날짜 선택하는 경우
widget.selectDate(focusedDay); // 하단 타임 그리드 내 예약된 시간 정보 좆회를 위한 메소드 호출
widget.selectDate(focusedDay); // 하단 타임 그리드 내 예약된 시간 정보 조회를 위한 메소드 호출

if (focusedStartDay == null) { focusedStartDay = focusedDay; }
else if (focusedEndDay == null) { focusedEndDay = focusedDay; }
Expand Down
19 changes: 3 additions & 16 deletions lib/View/booking/screen/booking_car_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -338,28 +338,15 @@ class _BookingCarScreenState extends State<BookingCarScreen> {
});

} else {

setState(() {
startDate = (start == null) ? null : DateTime(start.year, start.month, start.day);
startDate = (start == null) ? null : DateTime(start.year, start.month, start.day, (startTime == -1) ? 0 : startTime);
endDate = (end == null)
? DateTime(start!.year, start!.month, start!.day)
: DateTime(end.year, end.month, end.day);
? DateTime(start!.year, start!.month, start!.day, (startTime == -1) ? 0 : startTime)
: DateTime(end.year, end.month, end.day, (endTime == -1) ? 0 : endTime);
});
}
}

void changedStartDate(DateTime? time) {
setState(() {
startDate = (time == null) ? null : DateTime(time.year, time.month, time.day);
});
}

void changedEndDate(DateTime? time) {
setState(() {
endDate = (time == null) ? null : DateTime(time.year, time.month, time.day);
});
}

void didTapResetTimeGridButton() {
setState(() {
startTime = -1;
Expand Down
3 changes: 3 additions & 0 deletions lib/View/booking/screen/booking_history_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ class BookingHistoryScreenState extends State<BookingHistoryScreen> with SingleT
isAdmin: widget.isAdmin,
type: currentType,
id: data.data.content[index].id,
targetId: data.data.content[index].targetId,
reservatorName: widget.isAdmin ? data.data.content[index].reservatorName : null,
reservatorPhone: widget.isAdmin ? data.data.content[index].reservatorPhone : null,
name: data.data.content[index].name,
location: (currentType == BookingType.office)
? data.data.content[index].detailInfo
Expand Down
14 changes: 3 additions & 11 deletions lib/View/booking/screen/booking_resource_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -340,22 +340,14 @@ class _BookingResourceScreenState extends State<BookingResourceScreen> {

} else {
setState(() {
startDate = (start == null) ? null : DateTime(start.year, start.month, start.day);
startDate = (start == null) ? null : DateTime(start.year, start.month, start.day, (startTime == -1) ? 0 : startTime);
endDate = (end == null)
? DateTime(start!.year, start!.month, start!.day)
: DateTime(end.year, end.month, end.day);
? DateTime(start!.year, start!.month, start!.day, (startTime == -1) ? 0 : startTime)
: DateTime(end.year, end.month, end.day, (endTime == -1) ? 0 : endTime);
});
}
}

void changedStartDate(DateTime? time) {
setState(() { startDate = (time == null) ? null : DateTime(time.year, time.month, time.day); });
}

void changedEndDate(DateTime? time) {
setState(() { endDate = (time == null) ? null : DateTime(time.year, time.month, time.day); });
}

void didTapResetTimeGridButton() {
setState(() {
startTime = -1;
Expand Down
22 changes: 7 additions & 15 deletions lib/View/booking/screen/general_detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,10 @@ class _GeneralDetailScreenState extends State<GeneralDetailScreen> {
isLoading = true;
dynamic response;
switch (widget.type) {
case BookingType.resource:
response = await ResourceService().getResourceDetailData(widget.id);
case BookingType.car:
response = await CarService().getCarDetailData(widget.id);
default:
return;
case BookingType.resource: response = await ResourceService().getResourceDetailData(widget.id);
case BookingType.car: response = await CarService().getCarDetailData(widget.id);
default: return;
}
// dynamic response = await ResourceService().getResourceDetailData(widget.resourceId);
isLoading = false;
return response;
}
Expand Down Expand Up @@ -95,21 +91,17 @@ class _GeneralDetailScreenState extends State<GeneralDetailScreen> {
future: fetchData(),
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.hasError || snapshot.data == null) {
print('snapshot.hasError - ${snapshot.hasError}');
print('snapshot.error - ${snapshot.error}');
print('snapshot.data - ${snapshot.data}');
return const Center(
child: Text(
'정보를 불러오지 못 하였습니다.',
style: TextStyle(fontSize: 16, color: purple),
),
);
} else {
if (isLoading) {
return const Center(
child: CircularProgressIndicator(
color: purple,
),
);
}
// data = ResourceDetailResponse.fromJson(snapshot.data);
if (isLoading) { return const Center(child: CircularProgressIndicator(color: purple,),); }
configure(snapshot.data);
return SizedBox(
width: MediaQuery.of(context).size.width,
Expand Down

0 comments on commit c119185

Please sign in to comment.