File tree Expand file tree Collapse file tree 4 files changed +276
-146
lines changed Expand file tree Collapse file tree 4 files changed +276
-146
lines changed Original file line number Diff line number Diff line change 1+ import 'package:flutter/material.dart' ;
2+
3+ class TimeAgo extends StatelessWidget {
4+ final String text;
5+
6+ TimeAgo ({Key key, @required this .text}): super (key: key);
7+
8+ @override
9+ Widget build (BuildContext context) {
10+ return RichText (
11+ text: TextSpan (
12+ text: text,
13+ style: TextStyle (
14+ color: Colors .grey,
15+ fontSize: 14.0 ,
16+ )
17+ )
18+ );
19+ }
20+ }
21+
22+ class FeedCardTitle extends StatelessWidget {
23+ final String text;
24+ final bool urlOpened;
25+
26+ FeedCardTitle ({Key key, @required this .text, @required this .urlOpened}): super (key: key);
27+
28+ @override
29+ Widget build (BuildContext context) {
30+ return Align (
31+ alignment: Alignment .centerLeft,
32+ child: RichText (
33+ text: TextSpan (
34+ text: text,
35+ style: TextStyle (
36+ fontSize: 16.0 ,
37+ fontWeight: FontWeight .w500,
38+ color: urlOpened ? Colors .grey : Colors .black,
39+ decoration: urlOpened ? TextDecoration .lineThrough : null ,
40+ )
41+ )
42+ )
43+ );
44+ }
45+ }
46+
47+ class Domain extends StatelessWidget {
48+ final String text;
49+
50+ Domain ({Key key, this .text}): super (key: key);
51+
52+ @override
53+ Widget build (BuildContext context) {
54+ return Align (
55+ alignment: Alignment .centerLeft,
56+ child: Text (
57+ text ?? "" ,
58+ style: TextStyle (
59+ fontSize: 16.0 ,
60+ fontWeight: FontWeight .w300,
61+ color: Colors .black87,
62+ )
63+ )
64+ );
65+ }
66+ }
67+
68+
69+
Original file line number Diff line number Diff line change 1+ class FeedCard {
2+ int id;
3+ String title;
4+ int points;
5+ String user;
6+ String timeAgo;
7+ int commentsCount;
8+ String url;
9+ String domain;
10+
11+ FeedCard ({
12+ this .id,
13+ this .title,
14+ this .points,
15+ this .user,
16+ this .timeAgo,
17+ this .commentsCount,
18+ this .url,
19+ this .domain
20+ });
21+
22+ factory FeedCard .fromJSON (Map <String , dynamic > postJSON) {
23+ return FeedCard (
24+ id: postJSON["id" ] as int ,
25+ title: postJSON["title" ] as String ,
26+ points: postJSON["points" ] as int ,
27+ user: postJSON["user" ] as String ,
28+ timeAgo: postJSON["time_ago" ] as String ,
29+ commentsCount: postJSON["comments_count" ] as int ,
30+ url: postJSON["url" ] as String ,
31+ domain: postJSON["domain" ] as String ,
32+ );
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments