This repository was archived by the owner on Aug 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathdetail_view.dart
171 lines (168 loc) · 6.46 KB
/
detail_view.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:restaurantour/Modules/Details/view/widgets/review_card.dart';
import 'package:restaurantour/Modules/Details/viewmodel/detail_state.dart';
import 'package:restaurantour/Modules/Details/viewmodel/detail_viewmodel.dart';
import 'package:restaurantour/Modules/Home/tabs/widgets/categorie_text.dart';
import 'package:restaurantour/Modules/Home/tabs/widgets/is_open_label.dart';
import 'package:restaurantour/Modules/Home/tabs/widgets/price_text.dart';
class DetailView extends StatelessWidget {
const DetailView({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final DetailViewmodel detailViewmodel =
BlocProvider.of<DetailViewmodel>(context);
return Scaffold(
appBar: AppBar(
title: Center(
child: Text(
detailViewmodel.restaurant.name!,
overflow: TextOverflow.ellipsis,
),
),
actions: [
BlocBuilder<DetailViewmodel, DetailState>(
builder: (context, state) {
return IconButton(
onPressed: () async {
await detailViewmodel.invertFavoriteValue();
await detailViewmodel.addtoFavorites();
},
icon: (detailViewmodel.restaurant.isFavorite)
? const Icon(Icons.favorite)
: const Icon(Icons.favorite_outline),
);
},
),
],
),
body: SingleChildScrollView(
child: Column(
children: [
SizedBox(
width: double.infinity,
height: 300,
child: detailViewmodel.restaurant.photos != null
? Image.network(
detailViewmodel.restaurant.photos!.first,
fit: BoxFit.cover,
)
: const Text('no photo'),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
PriceText(
text: detailViewmodel.restaurant.price,
// text: 'homeViewmodel.restaurants.restaurants![index].price',
),
CategorieText(
text: detailViewmodel.restaurant.categories?[0].title,
),
const Expanded(
child: IsOpenLabel(
isOpen: true,
),
),
// 'text: homeViewmodel.restaurants.restaurants![index].categories?[0].title')
],
),
const SizedBox(height: 32),
Container(
width: double.infinity,
height: 1,
color: Colors.grey.withOpacity(0.2),
),
const SizedBox(height: 32),
const Text('Adress'),
const SizedBox(height: 32),
Text(
detailViewmodel.restaurant.location?.formattedAddress ?? '',
style: const TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(height: 32),
Container(
width: double.infinity,
height: 1,
color: Colors.grey.withOpacity(0.2),
),
const SizedBox(height: 32),
const Text('Overall Rating'),
const SizedBox(height: 18),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
detailViewmodel.restaurant.rating.toString(),
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 32,
),
),
const Padding(
padding: EdgeInsets.only(bottom: 6),
child: Icon(
Icons.star,
size: 14,
color: Color.fromARGB(255, 255, 205, 40),
),
),
],
),
const SizedBox(height: 32),
Container(
width: double.infinity,
height: 1,
color: Colors.grey.withOpacity(0.2),
),
const SizedBox(height: 32),
Text(
detailViewmodel.restaurant.reviews!.length.toString() +
(detailViewmodel.restaurant.reviews!.length > 1
? ' Reviews'
: 'Review'),
),
const SizedBox(height: 32),
SizedBox(
height: (200.toInt() *
detailViewmodel.restaurant.reviews!.length)
.toDouble(),
child: ListView.builder(
primary: false,
shrinkWrap: true,
itemCount: detailViewmodel.restaurant.reviews?.length,
padding: const EdgeInsets.only(top: 10),
itemBuilder: (BuildContext context, int index) {
return Column(
children: [
ReviewCard(
review:
detailViewmodel.restaurant.reviews![index],
),
const SizedBox(height: 18),
Container(
width: double.infinity,
height: 1,
color: Colors.grey.withOpacity(0.2),
),
const SizedBox(height: 32),
],
);
},
),
),
],
),
),
],
),
),
);
}
}