Skip to content

Commit e5f8eb6

Browse files
committed
Fix saved page
1 parent b0418ef commit e5f8eb6

File tree

1 file changed

+140
-125
lines changed

1 file changed

+140
-125
lines changed

lib/pages/saved/saved_page.dart

Lines changed: 140 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ class _SavedPageState extends State<SavedPage> {
9191
),
9292
),
9393
body: SafeArea(
94-
child: StreamBuilder<SavedListState>(
94+
child: Container(
95+
constraints: BoxConstraints.expand(),
96+
color: Colors.white,
97+
child: StreamBuilder<SavedListState>(
9598
stream: _savedBloc.savedListState$,
9699
initialData: _savedBloc.savedListState$.value,
97100
builder: (context, snapshot) {
@@ -150,26 +153,29 @@ class _SavedPageState extends State<SavedPage> {
150153
);
151154
},
152155
);
153-
}),
156+
},
157+
),
158+
),
154159
),
155160
);
156161
}
157162

158163
static EdgeInsets _getItemPadding(int length, int index) {
159164
EdgeInsets padding;
165+
const margin = 6.0;
160166
if (length > 1) {
161167
if (index == 0) {
162-
padding = const EdgeInsets.fromLTRB(4, 4, 4, 2);
168+
padding = const EdgeInsets.fromLTRB(margin, margin, margin, margin / 2);
163169
} else if (index == length - 1) {
164-
padding = const EdgeInsets.fromLTRB(4, 2, 4, 4);
170+
padding = const EdgeInsets.fromLTRB(margin, 2, margin, margin);
165171
} else {
166172
padding = const EdgeInsets.symmetric(
167-
vertical: 2,
168-
horizontal: 4,
173+
vertical: margin / 2,
174+
horizontal: margin,
169175
);
170176
}
171177
} else {
172-
padding = const EdgeInsets.all(4);
178+
padding = const EdgeInsets.all(margin);
173179
}
174180
return padding;
175181
}
@@ -252,163 +258,172 @@ class _SavedRoomListItemState extends State<SavedRoomListItem>
252258
final currentLocale =
253259
BlocProvider.of<LocaleBloc>(context).locale$.value.languageCode;
254260

261+
final textRemoved = Text(
262+
s.removed,
263+
style: themeData.textTheme.title.copyWith(fontSize: 14),
264+
);
255265
final background = Container(
256266
child: Padding(
257267
padding: const EdgeInsets.all(8.0),
258268
child: Row(
259269
mainAxisAlignment: MainAxisAlignment.end,
260270
children: <Widget>[
261-
SizedBox(width: 16.0),
262-
Icon(
271+
const SizedBox(width: 16.0),
272+
const Icon(
263273
Icons.delete,
264274
size: 28.0,
275+
color: Colors.black54,
265276
),
266-
Text(
267-
s.removed,
268-
style: themeData.textTheme.subhead,
269-
),
270-
Spacer(),
271-
Text(
272-
s.removed,
273-
style: themeData.textTheme.subhead,
274-
),
275-
SizedBox(width: 16.0),
276-
Icon(
277+
const SizedBox(width: 16.0),
278+
textRemoved,
279+
const Spacer(),
280+
textRemoved,
281+
const SizedBox(width: 16.0),
282+
const Icon(
277283
Icons.delete,
278284
size: 28.0,
285+
color: Colors.black54,
279286
),
287+
const SizedBox(width: 16.0),
280288
],
281289
),
282290
),
283291
);
284292

293+
const radius = 6.0;
294+
const sizedBox = SizedBox(height: 4);
295+
final dateFormat = DateFormat.yMMMMd(currentLocale).add_Hms();
296+
285297
final content = Container(
286298
margin: widget.margin,
287299
decoration: BoxDecoration(
288-
borderRadius: BorderRadius.circular(4),
300+
borderRadius: BorderRadius.circular(radius),
289301
color: Colors.white,
290302
boxShadow: [
291303
BoxShadow(
292-
color: Colors.grey.shade300,
304+
color: Colors.grey.shade400,
293305
blurRadius: 10,
294-
spreadRadius: 2,
306+
offset: Offset(2, 2),
295307
)
296308
],
297309
),
298-
child: Row(
299-
children: <Widget>[
300-
ClipRRect(
301-
borderRadius: BorderRadius.only(
302-
topLeft: Radius.circular(4),
303-
bottomLeft: Radius.circular(4),
304-
),
305-
child: CachedNetworkImage(
306-
width: 128,
307-
height: 128,
308-
fit: BoxFit.cover,
309-
imageUrl: item.image,
310-
placeholder: (context, url) {
311-
return Center(
312-
child: CircularProgressIndicator(
313-
strokeWidth: 2,
314-
),
315-
);
316-
},
317-
errorWidget: (context, url, error) {
318-
return Container(
319-
color: Colors.black12,
320-
width: 128,
321-
height: 128,
322-
child: Center(
323-
child: Icon(
324-
Icons.image,
325-
color: Theme.of(context).accentColor,
326-
size: 32,
327-
),
328-
),
329-
);
330-
},
331-
),
332-
),
333-
SizedBox(width: 4),
334-
Expanded(
335-
child: Column(
336-
mainAxisSize: MainAxisSize.min,
337-
mainAxisAlignment: MainAxisAlignment.center,
310+
child: ClipRRect(
311+
borderRadius: BorderRadius.circular(radius),
312+
child: Material(
313+
child: InkWell(
314+
onTap: () {
315+
Navigator.of(context).pushNamed(
316+
'/room_detail',
317+
arguments: item.id,
318+
);
319+
},
320+
child: Row(
338321
children: <Widget>[
339-
Text(
340-
item.title,
341-
maxLines: 2,
342-
overflow: TextOverflow.ellipsis,
343-
style: themeData.textTheme.subtitle.copyWith(
344-
fontSize: 14,
345-
fontFamily: 'SF-Pro-Text',
346-
fontWeight: FontWeight.w600,
322+
ClipRRect(
323+
borderRadius: BorderRadius.only(
324+
topLeft: Radius.circular(radius),
325+
bottomLeft: Radius.circular(radius),
347326
),
348-
),
349-
Text(
350-
item.price,
351-
textAlign: TextAlign.left,
352-
maxLines: 1,
353-
overflow: TextOverflow.fade,
354-
style: themeData.textTheme.subtitle.copyWith(
355-
color: themeData.accentColor,
356-
fontSize: 12.0,
357-
fontFamily: 'SF-Pro-Text',
358-
fontWeight: FontWeight.w400,
359-
),
360-
),
361-
Text(
362-
item.address,
363-
textAlign: TextAlign.left,
364-
maxLines: 1,
365-
overflow: TextOverflow.ellipsis,
366-
style: themeData.textTheme.subtitle.copyWith(
367-
color: Colors.black87,
368-
fontSize: 12,
369-
fontFamily: 'SF-Pro-Text',
370-
fontWeight: FontWeight.w400,
371-
),
372-
),
373-
Text(
374-
item.districtName,
375-
maxLines: 1,
376-
textAlign: TextAlign.left,
377-
overflow: TextOverflow.ellipsis,
378-
style: themeData.textTheme.subtitle.copyWith(
379-
color: Colors.black87,
380-
fontSize: 12,
381-
fontFamily: 'SF-Pro-Text',
382-
fontWeight: FontWeight.w400,
327+
child: CachedNetworkImage(
328+
width: 128,
329+
height: 128,
330+
fit: BoxFit.cover,
331+
imageUrl: item.image,
332+
placeholder: (context, url) {
333+
return Center(
334+
child: CircularProgressIndicator(
335+
strokeWidth: 2,
336+
),
337+
);
338+
},
339+
errorWidget: (context, url, error) {
340+
return Container(
341+
color: Colors.black12,
342+
width: 128,
343+
height: 128,
344+
child: Center(
345+
child: Icon(
346+
Icons.image,
347+
color: Theme.of(context).accentColor,
348+
size: 32,
349+
),
350+
),
351+
);
352+
},
383353
),
384354
),
385-
Row(
386-
mainAxisSize: MainAxisSize.max,
387-
mainAxisAlignment: MainAxisAlignment.center,
388-
children: <Widget>[
389-
Expanded(
390-
child: Text(
391-
DateFormat.yMMMMd(currentLocale)
392-
.add_Hms()
393-
.format(item.savedTime),
394-
maxLines: 1,
395-
textAlign: TextAlign.left,
355+
const SizedBox(width: 8),
356+
Expanded(
357+
child: Column(
358+
mainAxisSize: MainAxisSize.max,
359+
crossAxisAlignment: CrossAxisAlignment.center,
360+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
361+
children: <Widget>[
362+
sizedBox,
363+
Text(
364+
item.title,
365+
maxLines: 2,
396366
overflow: TextOverflow.ellipsis,
367+
style: themeData.textTheme.title.copyWith(
368+
fontSize: 14,
369+
fontWeight: FontWeight.w600,
370+
),
371+
),
372+
sizedBox,
373+
Text(
374+
item.price,
375+
textAlign: TextAlign.left,
376+
maxLines: 1,
377+
overflow: TextOverflow.fade,
397378
style: themeData.textTheme.subtitle.copyWith(
398-
color: Colors.black54,
399-
fontSize: 12,
400-
fontFamily: 'SF-Pro-Text',
401-
fontWeight: FontWeight.w400,
379+
color: themeData.accentColor,
380+
fontSize: 15,
381+
fontWeight: FontWeight.w600,
402382
),
403383
),
404-
),
405-
Icon(Icons.bookmark),
406-
],
384+
sizedBox,
385+
Text(
386+
'${item.address} - ${item.districtName}' * 5,
387+
textAlign: TextAlign.left,
388+
maxLines: 2,
389+
overflow: TextOverflow.ellipsis,
390+
style:
391+
themeData.textTheme.subtitle.copyWith(fontSize: 12),
392+
),
393+
const SizedBox(height: 12),
394+
Row(
395+
mainAxisSize: MainAxisSize.max,
396+
mainAxisAlignment: MainAxisAlignment.center,
397+
children: <Widget>[
398+
Expanded(
399+
child: Text(
400+
dateFormat.format(item.savedTime),
401+
maxLines: 1,
402+
textAlign: TextAlign.right,
403+
overflow: TextOverflow.ellipsis,
404+
style: themeData.textTheme.subtitle.copyWith(
405+
fontSize: 12,
406+
fontStyle: FontStyle.italic,
407+
fontWeight: FontWeight.w300,
408+
),
409+
),
410+
),
411+
const SizedBox(width: 4),
412+
Icon(
413+
Icons.bookmark,
414+
color: Theme.of(context).accentColor,
415+
),
416+
],
417+
),
418+
sizedBox,
419+
],
420+
),
407421
),
422+
const SizedBox(width: 8),
408423
],
409424
),
410425
),
411-
],
426+
),
412427
),
413428
);
414429

0 commit comments

Comments
 (0)