Fakultas Ilmu Komputer UI

homekycUnregsitered.dart 20.6 KB
Newer Older
Habel Christiando Tobing's avatar
Habel Christiando Tobing 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:fundex_app/api/api.dart';
import 'package:fundex_app/pages/business/cardsListOnHome.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:percent_indicator/percent_indicator.dart';

import 'EquityOfferings.dart';
import 'Ukm.dart';
import 'exploreBusiness.dart';

class HomeKYCUnregistered extends StatefulWidget {
  @override
  _HomeKYCUnregisteredState createState() => _HomeKYCUnregisteredState();
}

class _HomeKYCUnregisteredState extends State<HomeKYCUnregistered> {
  Future<EquityOfferings> futureEquities;
  void initState() {
    super.initState();
    futureEquities = Api().getEquities();
  }

  Widget buildUkmCarousel(BuildContext context,
      AsyncSnapshot<EquityOfferings> snapshot, int index) {
    List<Ukm> ukmList = snapshot.data.getUkmList();
    return new Container(
      alignment: Alignment.center,
      margin: EdgeInsets.fromLTRB(0.0, 24.0, 0.0, 0.0),
      child:
          ListView(key: Key('listViewCarousel'), shrinkWrap: true, children: <
              Widget>[
        CarouselSlider.builder(
          key: Key('carouselSlider'),
          options: CarouselOptions(
            height: 400.0,
            viewportFraction: 0.8,
            aspectRatio: 16 / 9,
            reverse: true,
            initialPage: 0,
            enlargeCenterPage: true,
            enableInfiniteScroll: false,
            scrollDirection: Axis.horizontal,
          ),
          itemCount: ukmList.length,
          itemBuilder: (context, index, int idx) {
            return Column(
              children: [
                Expanded(
                  flex: 7,
                  child: Container(
                    key: Key('containerForWholeCarousel'),
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.only(
                        topLeft: Radius.circular(8.0),
                        topRight: Radius.circular(8.0),
                      ),
                      image: DecorationImage(
                        image: NetworkImage(ukmList[index].bannerImg),
                        fit: BoxFit.cover,
                      ),
                    ),
                  ),
                ),
                Expanded(
                  flex: 10,
                  child: Container(
                      key: Key('containerForWholeCarouselInformation'),
                      margin: EdgeInsets.fromLTRB(0, 0, 0, 8.0),
                      decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.only(
                          bottomLeft: Radius.circular(8.0),
                          bottomRight: Radius.circular(8.0),
                        ),
                        boxShadow: [
                          BoxShadow(
                            color: Colors.grey.withOpacity(0.5),
                            spreadRadius: 0,
                            blurRadius: 8,
                            offset: Offset(0, 0), // changes position of shadow
                          ),
                        ],
                      ),
                      alignment: Alignment.center,
                      child: Column(
                        key: Key('columnForUKMInformation'),
                        children: <Widget>[
                          Expanded(
                            flex: 2,
                            child: Row(
                              key: Key('rowInfoHeader'),
                              children: <Widget>[
                                Expanded(
                                  flex: 2,
                                  child: Container(
                                    margin: EdgeInsets.fromLTRB(8, 0, 8, 0),
                                    child: Image.network(
                                      ukmList[index].logoUrl,
                                      key: Key('ukmLogo'),
                                    ),
                                  ),
                                ),
                                Expanded(
                                  flex: 8,
                                  child: Text(
                                    ukmList[index].equityName,
                                    key: Key('ukmName'),
                                    style: GoogleFonts.inter(
                                      color: Color.fromRGBO(74, 74, 74, 1.0),
                                      fontSize: 16.0,
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                ),
                              ],
                            ),
                          ),
                          Expanded(
                            flex: 4,
                            child: Row(
                              key: Key('ukmInfoRow'),
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: <Widget>[
                                Expanded(
                                  flex: 1,
                                  child: Container(),
                                ),
                                Expanded(
                                  flex: 2,
                                  child: Column(
                                      key: Key('ukmInfoLeftColumn'),
                                      mainAxisAlignment:
                                          MainAxisAlignment.start,
                                      crossAxisAlignment:
                                          CrossAxisAlignment.start,
                                      children: <Widget>[
                                        Text(
                                          'Target Pendanaan',
                                          key: Key('fundTargetString'),
                                          style: GoogleFonts.notoSans(
                                            color:
                                                Color.fromRGBO(51, 51, 51, 1.0),
                                            fontSize: 10.0,
                                            fontWeight: FontWeight.w500,
                                          ),
                                        ),
                                        SizedBox(
                                          key: Key(
                                              'spaceBetweenFundTargetStringAndValue'),
                                          height: 4.0,
                                        ),
                                        Text(
                                          ukmList[index].beautifyFundTarget,
                                          key: Key('fundTargetValue'),
                                          style: GoogleFonts.roboto(
                                            color:
                                                Color.fromRGBO(47, 47, 47, 1.0),
                                            fontSize: 12.0,
                                            fontWeight: FontWeight.w500,
                                          ),
                                        ),
                                        SizedBox(
                                          key: Key(
                                              'spaceBetweenFundTargetValueAndMinInvestString'),
                                          height: 8.0,
                                        ),
                                        Text(
                                          'Min. Investasi',
                                          key: Key('minInvestString'),
                                          style: GoogleFonts.notoSans(
                                            color:
                                                Color.fromRGBO(51, 51, 51, 1.0),
                                            fontSize: 10.0,
                                            fontWeight: FontWeight.w500,
                                          ),
                                        ),
                                        SizedBox(
                                          key: Key(
                                              'spaceBetweenMinInvestStringAndValue'),
                                          height: 4.0,
                                        ),
                                        Text(
                                          ukmList[index].beautifyMinInvest,
                                          key: Key('minInvestValue'),
                                          style: GoogleFonts.roboto(
                                            color:
                                                Color.fromRGBO(47, 47, 47, 1.0),
                                            fontSize: 12.0,
                                            fontWeight: FontWeight.w500,
                                          ),
                                        ),
                                      ]),
                                ),
                                Expanded(
                                  flex: 1,
                                  child: Container(),
                                ),
                                Expanded(
                                  flex: 2,
                                  child: Column(
                                    key: Key('ukmInfoRightColumn'),
                                    mainAxisAlignment: MainAxisAlignment.start,
                                    crossAxisAlignment:
                                        CrossAxisAlignment.start,
                                    children: <Widget>[
                                      Text(
                                        'Harga Satuan',
                                        key: Key('unitPriceString'),
                                        style: GoogleFonts.notoSans(
                                          color:
                                              Color.fromRGBO(51, 51, 51, 1.0),
                                          fontSize: 10.0,
                                          fontWeight: FontWeight.w500,
                                        ),
                                      ),
                                      SizedBox(
                                        key: Key(
                                            'spaceBetweenUnitPriceStringAndValue'),
                                        height: 4.0,
                                      ),
                                      Text(
                                        ukmList[index].beautifyPrice,
                                        key: Key('unitPriceValue'),
                                        style: GoogleFonts.roboto(
                                          color:
                                              Color.fromRGBO(47, 47, 47, 1.0),
                                          fontSize: 12.0,
                                          fontWeight: FontWeight.w500,
                                        ),
                                      ),
                                      SizedBox(
                                        key: Key(
                                            'spaceBetweenUnitPriceValueAndRemainingTimeString'),
                                        height: 8.0,
                                      ),
                                      Text(
                                        'Waktu Tersisa',
                                        key: Key('remainingTimeString'),
                                        style: GoogleFonts.notoSans(
                                          color:
                                              Color.fromRGBO(51, 51, 51, 1.0),
                                          fontSize: 10.0,
                                          fontWeight: FontWeight.w500,
                                        ),
                                      ),
                                      SizedBox(
                                        key: Key(
                                            'spaceBetweenRemainingTimeStringAndValue'),
                                        height: 4.0,
                                      ),
                                      Text(
                                        ukmList[index].beautifyTime,
                                        key: Key('remainingTimeValue'),
                                        style: GoogleFonts.roboto(
                                          color:
                                              Color.fromRGBO(217, 52, 52, 1.0),
                                          fontSize: 12.0,
                                          fontWeight: FontWeight.w500,
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                                Expanded(
                                  flex: 1,
                                  child: Container(),
                                ),
                              ],
                            ),
                          ),
                          Expanded(
                            flex: 3,
                            child: Column(
                              key: Key('fundProgressColumn'),
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: <Widget>[
                                Container(
                                  child: RichText(
                                      key: Key('fundprogressString'),
                                      text: TextSpan(
                                          text: 'Telah terkumpul ',
                                          style: GoogleFonts.notoSans(
                                            color:
                                                Color.fromRGBO(51, 51, 51, 1.0),
                                            fontSize: 10.0,
                                            fontWeight: FontWeight.w500,
                                          ),
                                          children: <TextSpan>[
                                            TextSpan(
                                              text: ukmList[index]
                                                      .beautifyProgress +
                                                  '% dana ',
                                              style: GoogleFonts.notoSans(
                                                color: Color.fromRGBO(
                                                    47, 47, 47, 1.0),
                                                fontSize: 10.0,
                                                fontWeight: FontWeight.bold,
                                              ),
                                            ),
                                            TextSpan(
                                              text: 'dari ',
                                              style: GoogleFonts.notoSans(
                                                color: Color.fromRGBO(
                                                    51, 51, 51, 1.0),
                                                fontSize: 10.0,
                                                fontWeight: FontWeight.w500,
                                              ),
                                            ),
                                            TextSpan(
                                              text: ukmList[index]
                                                      .totalInvestor
                                                      .toString() +
                                                  ' investor.',
                                              style: GoogleFonts.notoSans(
                                                color: Color.fromRGBO(
                                                    47, 47, 47, 1.0),
                                                fontSize: 10.0,
                                                fontWeight: FontWeight.bold,
                                              ),
                                            ),
                                          ])),
                                ),
                                Container(
                                    margin: EdgeInsets.only(top: 4.0),
                                    width: double.infinity,
                                    padding:
                                        EdgeInsets.symmetric(horizontal: 24.0),
                                    child: LinearPercentIndicator(
                                      key: Key('fundprogressBar'),
                                      progressColor:
                                          Color.fromRGBO(14, 39, 115, 1.0),
                                      backgroundColor:
                                          Color.fromRGBO(223, 223, 223, 1.0),
                                      lineHeight: 24.0,
                                      percent: double.parse(
                                              ukmList[index].progress) /
                                          100,
                                    )),
                              ],
                            ),
                          ),
                        ],
                      )),
                ),
              ],
            );
          },
        )
      ]),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      resizeToAvoidBottomInset: false,
      appBar: AppBar(
        backgroundColor: Colors.white,
        title: Image.asset(
          'assets/images/fundex.png',
          key: Key('logoFundex'),
        ),
      ),
      body: SafeArea(
        child: SingleChildScrollView(
          child: Column(
            key: Key('wholePageColumn'),
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              unregisteredUser(context),
              Container(
                alignment: Alignment.center,
                key: Key('containerPenawaranAndLihatSemua'),
                margin: EdgeInsets.fromLTRB(24.0, 0.0, 24.0, 0.0),
                child: Row(
                    key: Key('rowPenawaranAndLihatSemua'),
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text(
                        'Penawaran',
                        key: Key('stringPenawaran'),
                        style: GoogleFonts.inter(
                          color: Color.fromRGBO(0, 0, 0, 1.0),
                          fontSize: 16.0,
                        ),
                      ),
                      RichText(
                          key: Key('stringLihatSemua'),
                          text: TextSpan(
                              text: 'Lihat Semua >>',
                              style: GoogleFonts.inter(
                                color: Color.fromRGBO(189, 189, 189, 1.0),
                                fontSize: 12.0,
                              ),
                              recognizer: TapGestureRecognizer()
                                ..onTap = () {
                                  Navigator.push(context,
                                      MaterialPageRoute(builder: (context) {
                                    return MaterialApp(home: ExploreBusiness());
                                  }));
                                })),
                    ]),
              ),
              Container(
                alignment: Alignment.center,
                margin: EdgeInsets.fromLTRB(0.0, 24.0, 0.0, 0.0),
                child: FutureBuilder<EquityOfferings>(
                    future: futureEquities,
                    builder: (context, snapshot) {
                      if (snapshot.hasData) {
                        return buildUkmCarousel(context, snapshot,
                            snapshot.data.getUkmList().length);

                        // SingleChildScrollView(
                        //     scrollDirection: Axis.vertical,
                        //     child: buildUkmCard(context, snapshot));
                      } else if (snapshot.hasError) {
                        print('${snapshot.error}');
                        return Container(child: Text('${snapshot.error}'));
                      } else {
                        return Container(
                          width: 0,
                          height: 0,
                        );
                      }
                    }),
              ),
            ],
          ),
        ),
      ),
    );
  }
}