|
1 | 1 | import 'package:flutter/material.dart'; |
| 2 | +import 'package:habr_app/stores/app_settings.dart'; |
2 | 3 | import 'package:habr_app/utils/date_to_text.dart'; |
3 | 4 | import 'package:habr_app/models/post_preview.dart'; |
| 5 | +import 'package:habr_app/widgets/html_view.dart'; |
| 6 | +import 'package:provider/provider.dart'; |
4 | 7 |
|
5 | 8 | import 'small_author_preview.dart'; |
6 | 9 | import 'statistics_icons.dart'; |
7 | 10 |
|
8 | 11 | class ArticlePreview extends StatelessWidget { |
9 | 12 | final PostPreview postPreview; |
| 13 | + final bool showHtml; |
10 | 14 | final Function(String articleId) onPressed; |
11 | 15 |
|
12 | | - ArticlePreview({Key key, @required this.postPreview, this.onPressed}) |
13 | | - : super(key: key); |
| 16 | + ArticlePreview({ |
| 17 | + Key key, |
| 18 | + @required this.postPreview, |
| 19 | + this.showHtml, |
| 20 | + this.onPressed, |
| 21 | + }) : super(key: key); |
14 | 22 |
|
15 | 23 | @override |
16 | 24 | Widget build(BuildContext context) { |
| 25 | + final needShowHtml = |
| 26 | + showHtml ?? context.watch<AppSettings>().showPreviewText; |
17 | 27 | final upIconTextStyle = const TextStyle(fontSize: 15); |
18 | 28 | final statisticIconTextStyle = const TextStyle(fontSize: 15); |
19 | 29 | return InkWell( |
@@ -45,13 +55,20 @@ class ArticlePreview extends StatelessWidget { |
45 | 55 | const SizedBox( |
46 | 56 | height: 10, |
47 | 57 | ), |
| 58 | + if (needShowHtml && postPreview.htmlPreview != null) ...[ |
| 59 | + HtmlView.unparsed(postPreview.htmlPreview), |
| 60 | + const SizedBox( |
| 61 | + height: 20, |
| 62 | + ), |
| 63 | + ], |
48 | 64 | Text( |
49 | | - postPreview.tags |
50 | | - .where((String el) => !el.startsWith('Блог компании')) |
51 | | - .join(', '), |
52 | | - style: const TextStyle(fontSize: 15), |
53 | | - overflow: TextOverflow.ellipsis, |
54 | | - textAlign: TextAlign.left), |
| 65 | + postPreview.flows |
| 66 | + .where((String el) => !el.startsWith('Блог компании')) |
| 67 | + .join(', '), |
| 68 | + style: const TextStyle(fontSize: 15), |
| 69 | + overflow: TextOverflow.ellipsis, |
| 70 | + textAlign: TextAlign.left, |
| 71 | + ), |
55 | 72 | const SizedBox( |
56 | 73 | height: 5, |
57 | 74 | ), |
|
0 commit comments