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

Feat: 별점 및 거리 뜨도록 구현 #31

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
143 changes: 93 additions & 50 deletions lib/component/Recommend/Recommend.dart
Original file line number Diff line number Diff line change
@@ -1,59 +1,102 @@
import 'package:flutter/material.dart';
import 'package:carousel_slider/carousel_slider.dart';

import '../../const/recommend_title_text_enum.dart';

class Recommend extends StatelessWidget {
final String text;
final String subtext;
final List<String> list;
final List<String> cafeName;
final String title;
final String subtitle;
final List<dynamic>? listType;

Recommend(
{Key? key,
required this.text,
required this.subtext,
required this.list,
required this.cafeName})
: super(key: key);
Recommend({
Key? key,
required this.title,
required this.subtitle,
required this.listType,
}) : super(key: key);

late final List<Widget> imageSliders = list
late final List<Widget> imageSliders = listType!
.map((item) => Container(
margin: const EdgeInsets.all(5.0),
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(5.0)),
child: Stack(
children: <Widget>[
Image.network(item,
width: 280, height: 416, fit: BoxFit.fill),
Positioned(
bottom: 0.0,
left: 0.0,
right: 0.0,
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
Color.fromARGB(200, 0, 0, 0),
Color.fromARGB(0, 0, 0, 0)
],
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
margin: const EdgeInsets.all(5.0),
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(5.0)),
child: Stack(
children: <Widget>[
Image.network(item.imageUrl[0],
width: 280, height: 416, fit: BoxFit.fill),
Positioned(
bottom: 0.0,
left: 0.0,
right: 0.0,
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
Color.fromARGB(200, 0, 0, 0),
Color.fromARGB(0, 0, 0, 0)
],
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
),
),
padding: const EdgeInsets.symmetric(
vertical: 10.0, horizontal: 20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item.cafeName,
style: const TextStyle(
color: Colors.white,
fontSize: 18.0,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 5),
Row(
children: [
if (subtitle == RecommendTitleTextEnum.highRatedSubTitle.toString()) ...[
const Icon(
Icons.star_rounded,
color: Colors.white,
size: 18.0,
),
const SizedBox(width: 3),
Text(
item.star.toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 18.0,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic,
),
),
),
padding: const EdgeInsets.symmetric(
vertical: 10.0, horizontal: 20.0),
child: Text(
cafeName[list.indexOf(item)],
style: const TextStyle(
] else ...[
const Icon(
Icons.arrow_right_alt,
color: Colors.white,
fontSize: 18.0,
fontWeight: FontWeight.bold,
size: 18.0,
),
),
),
),
const SizedBox(width: 3),
Text(
'${item.distance.round().toString()}m',
style: const TextStyle(
color: Colors.white,
fontSize: 18.0,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic,
),
),
],
],
)
],
)),
))
),
),
),
],
)),
))
.toList();

@override
Expand All @@ -65,18 +108,18 @@ class Recommend extends StatelessWidget {
Padding(
padding: const EdgeInsets.fromLTRB(15, 40, 0, 2),
child: Text(
text,
title,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
if (subtext.isNotEmpty)
if (subtitle.isNotEmpty)
Padding(
padding: const EdgeInsets.fromLTRB(15, 0, 0, 2),
child: Text(
subtext,
subtitle,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
Expand All @@ -85,7 +128,7 @@ class Recommend extends StatelessWidget {
),
),
const SizedBox(
height: 8,
height: 10,
),
CarouselSlider(
options: CarouselOptions(
Expand All @@ -102,4 +145,4 @@ class Recommend extends StatelessWidget {
],
);
}
}
}
16 changes: 8 additions & 8 deletions lib/const/recommend_title_text_enum.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
enum RecommendTitleTextEnum {
closestText("현재 위치에서 가장 가까운 카페"),
closestSubText(""),
highRatedText("후기가 좋은 카페"),
highRatedSubText("리뷰수와 평점을 고려했어요"),
newlyOpenedText("새로 오픈한 카페"),
newlyOpenedSubText(""),
popularText("또 가고싶은 카페"),
popularSubText("많은 유저들이 즐겨찾기한 카페");
closestTitle("현재 위치에서 가장 가까운 카페"),
closestSubTitle(""),
highRatedTitle("후기가 좋은 카페"),
highRatedSubTitle("리뷰수와 평점을 고려했어요"),
newlyOpenedTitle("새로 오픈한 카페"),
newlyOpenedSubTitle(""),
popularTitle("또 가고싶은 카페"),
popularSubTitle("많은 유저들이 즐겨찾기한 카페");

final String text;
const RecommendTitleTextEnum(this.text);
Expand Down
37 changes: 16 additions & 21 deletions lib/screen/recommend_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import 'package:hipspot/component/Recommend/Recommend.dart';
import 'package:hipspot/const/recommend_title_text_enum.dart';
import 'package:hipspot/services/remote_service.dart';

import '../model/recommend_page/closest.dart';
import '../model/recommend_page/high_rated.dart';
import '../model/recommend_page/newly_opened.dart';
import '../../model/recommend_page/closest.dart';
import '../../model/recommend_page/high_rated.dart';
import '../../model/recommend_page/newly_opened.dart';

class RecommendScreen extends StatefulWidget {
const RecommendScreen({Key? key}) : super(key: key);
Expand Down Expand Up @@ -54,32 +54,27 @@ class _RecommendScreenState extends State<RecommendScreen> {
// map 해보기
// 3장만 받지 말고 있는 사진 다 가져오기
Recommend(
text: RecommendTitleTextEnum.closestText.toString(),
subtext: RecommendTitleTextEnum.closestSubText.toString(),
list: closestList?.map((e) => e.imageUrl[0]).toList() ?? [],
cafeName: closestList?.map((e) => e.cafeName).toList() ?? [],
title: RecommendTitleTextEnum.closestTitle.toString(),
subtitle: RecommendTitleTextEnum.closestSubTitle.toString(),
listType: closestList,
),
Recommend(
text: RecommendTitleTextEnum.highRatedText.toString(),
subtext: RecommendTitleTextEnum.highRatedSubText.toString(),
list: highRatedList?.map((e) => e.imageUrl[0]).toList() ?? [],
cafeName: highRatedList?.map((e) => e.cafeName).toList() ?? [],
title: RecommendTitleTextEnum.highRatedTitle.toString(),
subtitle: RecommendTitleTextEnum.highRatedSubTitle.toString(),
listType: highRatedList,
),
Recommend(
text: RecommendTitleTextEnum.newlyOpenedText.toString(),
subtext: RecommendTitleTextEnum.newlyOpenedSubText.toString(),
list: newlyOpenedList?.map((e) => e.imageUrl[0]).toList() ?? [],
cafeName:
newlyOpenedList?.map((e) => e.cafeName).toList() ?? [],
title: RecommendTitleTextEnum.newlyOpenedTitle.toString(),
subtitle: RecommendTitleTextEnum.newlyOpenedSubTitle.toString(),
listType: newlyOpenedList,
),
Recommend(
text: RecommendTitleTextEnum.popularText.toString(),
subtext: RecommendTitleTextEnum.popularSubText.toString(),
list: closestList?.map((e) => e.imageUrl[0]).toList() ?? [],
cafeName: closestList?.map((e) => e.cafeName).toList() ?? [],
title: RecommendTitleTextEnum.popularTitle.toString(),
subtitle: RecommendTitleTextEnum.popularSubTitle.toString(),
listType: closestList,
),
],
)),
);
}
}
}
Loading