Fakultas Ilmu Komputer UI

donation_dialog.dart 3.9 KB
Newer Older
1
import 'package:flutter/material.dart';
2
3
import 'package:home_industry/Component/router.dart';
import 'package:home_industry/Pages/Program/model/program.dart';
4
5

class ChooseDonationDialog extends StatelessWidget {
6
7
8
9
  final Program program;
  const ChooseDonationDialog({Key key, @required this.program})
      : assert(program != null),
        super(key: key);
10
11
12
13
14
15
16

  @override
  Widget build(BuildContext context) {
    return Dialog(
      child: Container(
        width: MediaQuery.of(context).size.width,
        height: 190,
17
        color: const Color.fromRGBO(250, 250, 250, 1),
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
        child: Padding(
          padding: const EdgeInsets.only(top: 10, right: 20),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Padding(
                padding: const EdgeInsets.only(left: 10.0, bottom: 6.0),
                child: Text('Pilihan Donasi',
                    style: Theme.of(context).textTheme.bodyText1.copyWith(
                        fontSize: 18,
                        fontWeight: FontWeight.bold,
                        letterSpacing: 1.2)),
              ),
              Divider(
                color: Colors.black,
                height: 0.2,
              ),
35
              _ChooseDonation(program: program)
36
37
38
39
40
41
42
43
            ],
          ),
        ),
      ),
    );
  }
}

44
class _ChooseDonation extends StatefulWidget {
45
  final Program program;
46
47
//  const _ChooseDonation(this.program);
  const _ChooseDonation({Key key, @required this.program}) : super(key: key);
48

49
  @override
50
  __ChooseDonationState createState() => __ChooseDonationState();
51
52
}

53
class __ChooseDonationState extends State<_ChooseDonation> {
54
55
  bool uangValue = false;
  bool barangValue = false;
56

57
58
59
60
61
62
63
64
65
66
67
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        CheckboxListTile(
            dense: true,
            controlAffinity: ListTileControlAffinity.leading,
            value: uangValue,
            title: Text(
              'Uang',
              style:
68
                  Theme.of(context).textTheme.bodyText1.copyWith(fontSize: 18),
69
70
71
72
73
74
75
76
77
78
79
80
            ),
            onChanged: (val) {
              setState(() {
                uangValue = !uangValue;
                barangValue = false;
              });
            }),
        CheckboxListTile(
          dense: true,
          controlAffinity: ListTileControlAffinity.leading,
          title: Text('Barang',
              style:
81
                  Theme.of(context).textTheme.bodyText1.copyWith(fontSize: 18)),
82
83
84
85
86
87
88
89
          value: barangValue,
          onChanged: (val) {
            setState(() {
              uangValue = false;
              barangValue = !barangValue;
            });
          },
        ),
90
91
92
93
        GestureDetector(
          onTap: () {
            if (uangValue) {
              Navigator.of(context).pushNamed(Router.donationPage,
94
                  arguments: {'program': widget.program});
95
96
            } else if (barangValue) {
              Navigator.of(context).pushNamed(Router.goodsDonationPage,
97
                  arguments: {'program': widget.program});
98
99
100
101
102
103
104
105
106
107
            }
          },
          child: Row(
            mainAxisAlignment: MainAxisAlignment.end,
            children: [
              Container(
                  width: 100,
                  height: 37,
                  decoration: BoxDecoration(
                      border: Border.all(
108
                          color: const Color.fromRGBO(60, 141, 188,
109
110
111
112
113
114
                              1)), //new Color.fromRGBO(255, 0, 0, 0.0),
                      borderRadius: BorderRadius.circular(50)),
                  child: Center(
                    child: Text(
                      'OK',
                      style: Theme.of(context).textTheme.bodyText1.copyWith(
115
                          fontSize: 18, color: const Color.fromRGBO(60, 141, 188, 1)),
116
117
118
119
                    ),
                  )),
            ],
          ),
120
121
122
123
124
        ),
      ],
    );
  }
}