Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PDA-44/feat] 비품 조회 #51

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions asset/image/location.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions lib/Model/model/equipment/equipment_list_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import 'dart:ffi';

import 'package:frontend/Model/model/general_list_model.dart';
import 'package:frontend/Model/model/general_model.dart';
import 'package:json_annotation/json_annotation.dart';

part 'equipment_list_model.g.dart';

@JsonSerializable()
class EquipmentResponseModel extends GeneralModel {
final EquipmentResponse data;

EquipmentResponseModel({
required super.status,
required super.code,
required super.message,
required this.data,
});

factory EquipmentResponseModel.fromJson(Map<String, dynamic> json) =>
_$EquipmentResponseModelFromJson(json);
}

@JsonSerializable()
class EquipmentResponse extends GeneralListModel {
List<EquipmentModel> content;

EquipmentResponse({
required super.pageable,
required super.last,
required super.totalPages,
required super.totalElements,
required super.size,
required super.number,
required super.sort,
required super.first,
required super.numberOfElements,
required super.empty,
required this.content,
});

factory EquipmentResponse.fromJson(Map<String, dynamic> json) =>
_$EquipmentResponseFromJson(json);
}

@JsonSerializable()
class EquipmentModel {
String category;
String contact;
String? description;
int equipmentId;
String? imgUrl;
String keeper;
String? location;
String name;
int quantity;

EquipmentModel({
required this.category,
required this.contact,
required this.description,
required this.equipmentId,
required this.imgUrl,
required this.keeper,
required this.location,
required this.name,
required this.quantity,
});

factory EquipmentModel.fromJson(Map<String, dynamic> json) =>
_$EquipmentModelFromJson(json);
}
83 changes: 83 additions & 0 deletions lib/Model/model/equipment/equipment_list_model.g.dart

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

17 changes: 17 additions & 0 deletions lib/Presenter/equipment/equipment_service.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:frontend/Model/network/api_manager.dart';

class EquipmentService {
final equipmentURL = '/equipments?size=100';

static final EquipmentService _equipmentService = EquipmentService._();
EquipmentService._();
factory EquipmentService() {
return _equipmentService;
}

Future<dynamic> getEquipment() async {
final response =
APIManager().request(RequestType.get, equipmentURL, null, null, null);
return response;
}
}
46 changes: 22 additions & 24 deletions lib/View/common/screen/root_tab.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import 'package:flutter/material.dart';
import 'package:frontend/Model/network/api_manager.dart';
import 'package:frontend/View/colors.dart';
import 'package:frontend/View/equipment/screen/equipment_screen.dart';

import '../../booking/screen/booking_screen.dart';
import '../component/tabbar_item.dart';
import '../../booking/screen/booking_history_screen.dart';

class RootTab extends StatefulWidget {

final int? initialIndex;

const RootTab({
this.initialIndex,
Key? key
}) : super(key: key);
const RootTab({this.initialIndex, Key? key}) : super(key: key);

@override
State<RootTab> createState() => _RootTabState();
Expand All @@ -38,9 +35,10 @@ class _RootTabState extends State<RootTab> with SingleTickerProviderStateMixin {
super.initState();

controller = TabController(
length: APIManager().isAdmin ? adminTabBarIcons.length : basicTabBarIcons.length,
vsync: this
);
length: APIManager().isAdmin
? adminTabBarIcons.length
: basicTabBarIcons.length,
vsync: this);
controller.addListener(tabListener);
index = widget.initialIndex ?? 0;
selectedTab = widget.initialIndex ?? 0;
Expand Down Expand Up @@ -71,26 +69,31 @@ class _RootTabState extends State<RootTab> with SingleTickerProviderStateMixin {
if (APIManager().isAdmin) {
return [
const BookingScreen(),
const BookingScreen(),
const BookingHistoryScreen(isAdmin: false,),
const BookingHistoryScreen(isAdmin: true,),
const EquipmentScreen(),
const BookingHistoryScreen(
isAdmin: false,
),
const BookingHistoryScreen(
isAdmin: true,
),
];
} else {
return [
const BookingScreen(),
const BookingScreen(),
const BookingHistoryScreen(isAdmin: false,),
const EquipmentScreen(),
const BookingHistoryScreen(
isAdmin: false,
),
];
}
}

/// 화면 중앙 UI 구현 메소드 ///
Widget renderTabBarView() {
return TabBarView(
physics: const NeverScrollableScrollPhysics(),
controller: controller,
children: getTabBarItemList()
);
physics: const NeverScrollableScrollPhysics(),
controller: controller,
children: getTabBarItemList());
}

/// 하단 탭바 구현 메소드 ///
Expand All @@ -101,12 +104,10 @@ class _RootTabState extends State<RootTab> with SingleTickerProviderStateMixin {
backgroundColor: Colors.white,
selectedItemColor: purple,
unselectedItemColor: Colors.black,

selectedLabelStyle: renderLabelStyle(),
unselectedLabelStyle: renderLabelStyle(),
type: BottomNavigationBarType.fixed,

onTap: (index){
onTap: (index) {
controller.animateTo(index);
setState(() {
selectedTab = 0;
Expand All @@ -119,9 +120,6 @@ class _RootTabState extends State<RootTab> with SingleTickerProviderStateMixin {
}

TextStyle renderLabelStyle() {
return const TextStyle(
fontSize: 10,
fontWeight: FontWeight.w500
);
return const TextStyle(fontSize: 10, fontWeight: FontWeight.w500);
}
}
Loading