Skip to content

Commit

Permalink
feat:#14 하단 api (5-10-2) 연결및 모델 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwest00 committed Oct 17, 2023
1 parent 96f281d commit 35c717b
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/model/match_history/match_history.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MatchHistory with _$MatchHistory {
required String histories,
required String historyDate,
String? flameImage,
required List<String> donationHistoryImages,
List<String>? donationHistoryImages,
}) = _MatchHistory;
factory MatchHistory.fromJson(Map<String, dynamic> json) =>
_$MatchHistoryFromJson(json);
Expand Down
32 changes: 17 additions & 15 deletions lib/model/match_history/match_history.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mixin _$MatchHistory {
String get histories => throw _privateConstructorUsedError;
String get historyDate => throw _privateConstructorUsedError;
String? get flameImage => throw _privateConstructorUsedError;
List<String> get donationHistoryImages => throw _privateConstructorUsedError;
List<String>? get donationHistoryImages => throw _privateConstructorUsedError;

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
Expand All @@ -45,7 +45,7 @@ abstract class $MatchHistoryCopyWith<$Res> {
String histories,
String historyDate,
String? flameImage,
List<String> donationHistoryImages});
List<String>? donationHistoryImages});
}

/// @nodoc
Expand All @@ -66,7 +66,7 @@ class _$MatchHistoryCopyWithImpl<$Res, $Val extends MatchHistory>
Object? histories = null,
Object? historyDate = null,
Object? flameImage = freezed,
Object? donationHistoryImages = null,
Object? donationHistoryImages = freezed,
}) {
return _then(_value.copyWith(
historyId: null == historyId
Expand All @@ -89,10 +89,10 @@ class _$MatchHistoryCopyWithImpl<$Res, $Val extends MatchHistory>
? _value.flameImage
: flameImage // ignore: cast_nullable_to_non_nullable
as String?,
donationHistoryImages: null == donationHistoryImages
donationHistoryImages: freezed == donationHistoryImages
? _value.donationHistoryImages
: donationHistoryImages // ignore: cast_nullable_to_non_nullable
as List<String>,
as List<String>?,
) as $Val);
}
}
Expand All @@ -111,7 +111,7 @@ abstract class _$$_MatchHistoryCopyWith<$Res>
String histories,
String historyDate,
String? flameImage,
List<String> donationHistoryImages});
List<String>? donationHistoryImages});
}

/// @nodoc
Expand All @@ -130,7 +130,7 @@ class __$$_MatchHistoryCopyWithImpl<$Res>
Object? histories = null,
Object? historyDate = null,
Object? flameImage = freezed,
Object? donationHistoryImages = null,
Object? donationHistoryImages = freezed,
}) {
return _then(_$_MatchHistory(
historyId: null == historyId
Expand All @@ -153,10 +153,10 @@ class __$$_MatchHistoryCopyWithImpl<$Res>
? _value.flameImage
: flameImage // ignore: cast_nullable_to_non_nullable
as String?,
donationHistoryImages: null == donationHistoryImages
donationHistoryImages: freezed == donationHistoryImages
? _value._donationHistoryImages
: donationHistoryImages // ignore: cast_nullable_to_non_nullable
as List<String>,
as List<String>?,
));
}
}
Expand All @@ -170,7 +170,7 @@ class _$_MatchHistory with DiagnosticableTreeMixin implements _MatchHistory {
required this.histories,
required this.historyDate,
this.flameImage,
required final List<String> donationHistoryImages})
final List<String>? donationHistoryImages})
: _donationHistoryImages = donationHistoryImages;

factory _$_MatchHistory.fromJson(Map<String, dynamic> json) =>
Expand All @@ -186,13 +186,15 @@ class _$_MatchHistory with DiagnosticableTreeMixin implements _MatchHistory {
final String historyDate;
@override
final String? flameImage;
final List<String> _donationHistoryImages;
final List<String>? _donationHistoryImages;
@override
List<String> get donationHistoryImages {
List<String>? get donationHistoryImages {
final value = _donationHistoryImages;
if (value == null) return null;
if (_donationHistoryImages is EqualUnmodifiableListView)
return _donationHistoryImages;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_donationHistoryImages);
return EqualUnmodifiableListView(value);
}

@override
Expand Down Expand Up @@ -265,7 +267,7 @@ abstract class _MatchHistory implements MatchHistory {
required final String histories,
required final String historyDate,
final String? flameImage,
required final List<String> donationHistoryImages}) = _$_MatchHistory;
final List<String>? donationHistoryImages}) = _$_MatchHistory;

factory _MatchHistory.fromJson(Map<String, dynamic> json) =
_$_MatchHistory.fromJson;
Expand All @@ -281,7 +283,7 @@ abstract class _MatchHistory implements MatchHistory {
@override
String? get flameImage;
@override
List<String> get donationHistoryImages;
List<String>? get donationHistoryImages;
@override
@JsonKey(ignore: true)
_$$_MatchHistoryCopyWith<_$_MatchHistory> get copyWith =>
Expand Down
4 changes: 2 additions & 2 deletions lib/model/match_history/match_history.g.dart

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

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class BurningMatchController extends GetxController {
Rx<FlameDetail> flameDetail = tmpFlameDetail.obs;

///* mapIndexed 사용불가로 index 대체 변수
RxList<MatchHistory> matchHistories = <MatchHistory>[].obs;
RxList<MatchHistory> flameHistories = <MatchHistory>[].obs;

// Future<void> getMoreProject(int index) async {
// if (!DonationApi.getDonationHistoryIsLast) {
Expand All @@ -37,7 +37,10 @@ class BurningMatchController extends GetxController {
@override
void onInit() async {
super.onInit();
///*상단 데이터 init
flameDetail.value =
await FlameApi.getDetailFlameTop(donationId: id) ?? tmpFlameDetail;
///*하단 데이터 init
flameHistories.assignAll( await FlameApi.getFlameDetailBottom(donationId: id));
}
}
7 changes: 4 additions & 3 deletions lib/modules/buring_match/view/burning_match_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,20 @@ class BurningMatchScreen extends GetView<BurningMatchController> {
ListView.separated(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: controller.flameHistories.length,
itemBuilder: (context, index) {
final history = controller.matchHistories[index];
final history = controller.flameHistories[index];
return MatchRecord(
title: history.histories,
date: history.historyDate,
imgList: history.donationHistoryImages);
imgList: history.donationHistoryImages ?? []);
},
separatorBuilder: (context, index) {
return SizedBox(
height: 12.h,
);
},
itemCount: controller.matchHistories.length),
),
// 매치기록
],
),
Expand Down
29 changes: 29 additions & 0 deletions lib/provider/api/flame_api.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:dio/dio.dart';
import 'package:match/model/match_history/match_history.dart';
import 'package:match/provider/api/util/global_api_field.dart';

import '../../model/api/pagination.dart';
Expand Down Expand Up @@ -52,4 +53,32 @@ class FlameApi {
logger.e(e.toString());
}
}

///<h2>5-10-2 API | 상세 - 불타는 매치 상세 - 하단조회</h2>
///* pagination
static Future<List<MatchHistory>> getFlameDetailBottom(
{required int donationId, bool getMore = false}) async {
try {
logger.d("api호출 성공");
if (!getMore) {
detailFlameBottom.currentpage = 0;
}
Response response = await DioServices()
.to()
.get("/donations/flame/bottom/$donationId", queryParameters: {
"page": detailFlameBottom.currentpage,
"size": PAGINATION_SIZE
});

detailFlameBottom.totalCnt = response.data[RESULT][TOTAL];
detailFlameBottom.isLast = response.data[RESULT][LAST];
logger.d(
"pagination 정보: totalCnt:${detailFlameBottom.totalCnt}, currentPage:${detailFlameBottom.currentpage} isLast:${detailFlameBottom.isLast}");
return List.generate(response.data[RESULT][CONTENTS].length,
(index) => MatchHistory.fromJson(response.data[RESULT][CONTENTS][index]));
} catch (e) {
logger.e(e.toString());
return [];
}
}
}

0 comments on commit 35c717b

Please sign in to comment.