Fakultas Ilmu Komputer UI

detailpost.dart 7.67 KB
Newer Older
Fakhira Devina's avatar
Fakhira Devina committed
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:ppl_disabilitas/component/ImageHolder.dart';
import 'package:ppl_disabilitas/component/bisago_appbar.dart';
import 'package:ppl_disabilitas/config/strings.dart';
import 'package:ppl_disabilitas/config/styles.dart';
import 'package:ppl_disabilitas/model/komentar.dart';

class DetailPostPage extends StatefulWidget {
  final KomentarModel komentar;
  DetailPostPage({@required this.komentar});
  @override
  _DetailPostPageState createState() => _DetailPostPageState();
}

class _DetailPostPageState extends State<DetailPostPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: BisaGoAppBar(
        title: widget.komentar.nama_lokasi,
        key: Key('appbar-text-${widget.komentar.nama_lokasi}'),
      ),
      body: Container(
        margin: EdgeInsets.all(doubleSpace),
        child: SingleChildScrollView(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              ImageHolder(url: widget.komentar.image),
              Wrap(
                alignment: WrapAlignment.start,
                direction: Axis.horizontal,
                crossAxisAlignment: WrapCrossAlignment.start,
                children: widget.komentar.tag
                    .map<Widget>((tag) => _createTagContainer(getTag(tag)))
                    .toList(),
              ),
              Container(
                key: Key('desc'),
                decoration: BoxDecoration(
                  color: Colors.white,
                    boxShadow: regularShadow,
                    border: Border.all(color: greenPale),
                    borderRadius: regularBorderRadius),
                padding: EdgeInsets.all(doubleSpace),
                margin: EdgeInsets.symmetric(vertical: regularSpace),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text(
                      'Informasi',
                      style:
                          TextStyle(fontSize: 20, fontWeight: FontWeight.w800),
                    ),
                    Container(
                      margin: EdgeInsets.symmetric(vertical: regularSpace),
                      child: Text(
                        widget.komentar.deskripsi,
                        style: TextStyle(fontSize: 18),
                      ),
                    ),
                    Container(
                      margin: EdgeInsets.symmetric(vertical: regularSpace),
                      child: Text(
                        'Diposting oleh',
                        style: TextStyle(fontSize: 18),
                      ),
                    ),
                    Text(
                      '${widget.komentar.creator}',
                      key: Key('creator-${widget.komentar.creator}'),
                    ),
                    Text(
                      '${DateFormat('dd MMMM yyy hh:mm').format(widget.komentar.date_time)}',
                      style: TextStyle(color: grayPrimary, fontSize: 16),
                      key: Key('timestamp'),
                    ),
                    Row(
                      mainAxisSize: MainAxisSize.max,
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: <Widget>[
                        Expanded(
                          child: Container(
                            key: Key('like'),
                            decoration: BoxDecoration(
                                color: greenPrimary,
                                borderRadius: regularBorderRadius,
                                boxShadow: regularShadow),
                            padding: EdgeInsets.all(smallSpace),
                            margin: EdgeInsets.symmetric(horizontal: smallSpace),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: <Widget>[
                                Icon(
                                  Icons.thumb_up,
                                  color: Colors.white,
                                ),
                                Text(
                                  '${widget.komentar.like} Suka',
                                  style: TextStyle(
                                      fontWeight: FontWeight.w700,
                                      color: Colors.white,
                                      fontSize: 16),
                                ),
                              ],
                            ),
                          ),
                        ),
                        Expanded(
                          child: Container(
                            key: Key('dislike'),
                            decoration: BoxDecoration(
                                color: redPrimary,
                                borderRadius: regularBorderRadius,
                                boxShadow: regularShadow),
                            padding: EdgeInsets.all(smallSpace),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: <Widget>[
                                Icon(
                                  Icons.thumb_down,
                                  color: Colors.white,
                                ),
                                Text(
                                  '${widget.komentar.dislike} Tidak Suka',
                                  style: TextStyle(
                                      fontWeight: FontWeight.w700,
                                      color: Colors.white,
                                      fontSize: 16),
                                ),
                              ],
                            ),
                          ),
                        )
                      ],
                    )
                  ],
                ),
              ),
              Container(
                key: Key('rating'),
                decoration: BoxDecoration(
                  color: Colors.white,
                    boxShadow: regularShadow,
                    border: Border.all(color: greenPale),
                    borderRadius: regularBorderRadius),
                padding: EdgeInsets.all(doubleSpace),
                child: Column(
                  children: <Widget>[
                    Text(
                      'Rating',
                      style: TextStyle(
                        fontWeight: FontWeight.w800,
                      ),
                    ),
                    Row(
                      children: <Widget>[
                        Text('${widget.komentar.rating}/5'),
                        ...List<Widget>.generate(
                            widget.komentar.rating,
                            (number) => Icon(
                                  Icons.star,
                                  color: Colors.yellow,
                                ))
                      ],
                    )
                  ],
                ),
              )
            ],
          ),
        ),
      ),
    );
  }

  _createTagContainer(String tag) {
    return Container(
      key: Key('tag-$tag'),
      padding: EdgeInsets.all(smallSpace),
      margin: EdgeInsets.all(smallSpace),
      decoration: BoxDecoration(
        color: Colors.white,
          borderRadius: regularBorderRadius,
          border: Border.all(color: greenPale),
          boxShadow: regularShadow),
      child: Text(
        '#$tag',
        style: TextStyle(
            fontWeight: FontWeight.w800, fontSize: 16, color: greenPrimary),
      ),
    );
  }
}