-
Notifications
You must be signed in to change notification settings - Fork 0
/
event_ui.dart
182 lines (173 loc) · 5.32 KB
/
event_ui.dart
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
import 'package:aus/utils/color_utils.dart';
import 'package:flutter/material.dart';
import '../../controllers/event_controller.dart';
import 'package:intl/intl.dart';
//determine color of category button, default color is blue
String buttonColor(String eventCategory) {
if (eventCategory == "Seminar" || eventCategory == "Webinar") {
return "#56bed2"; //mint
} else if (eventCategory == "Competition") {
return "#ef8632"; //orange
} else if (eventCategory == "Workshop") {
return "#4ca98f"; //green
} else if (eventCategory == "Party") {
return "8d65f2"; //purple
}
return "#4ba7f8"; //blue
}
//determine thumbnail image of events, default image is seminar
String eventImage(String eventCategory) {
if (eventCategory == "Webinar") {
return 'assets/imgs/event_webinar.png';
} else if (eventCategory == "Workshop") {
return 'assets/imgs/event_workshop.png';
} else if (eventCategory == "Party") {
return 'assets/imgs/event_party.png';
}
return 'assets/imgs/event_seminar.png';
}
//event photo
Widget eventPhoto(BuildContext context, EventController controller) {
return Container(
width: 180,
height: 110,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(eventImage(controller.event.category)),
fit: BoxFit.cover,
),
borderRadius: BorderRadius.circular(5)),
);
}
//category button
Widget categoryButton(BuildContext context, EventController controller) {
return Padding(
padding: const EdgeInsetsDirectional.fromSTEB(5, 10, 5, 0),
child: Container(
decoration: BoxDecoration(
color: hexStringToColor("#3E3E3E"),
borderRadius: BorderRadius.circular(5),
border: Border.all(
color: hexStringToColor(buttonColor(controller.event.category))),
),
child: Container(
padding: const EdgeInsetsDirectional.fromSTEB(8, 3, 8, 3),
child: Text(
controller.event.category,
style: Theme.of(context).textTheme.bodyText2?.copyWith(
fontFamily: 'Outfit',
color: hexStringToColor(buttonColor(controller.event.category)),
fontSize: 11,
fontWeight: FontWeight.bold,
),
),
),
),
);
}
//event title
Widget eventTitle(BuildContext context, EventController controller) {
return Padding(
padding: const EdgeInsetsDirectional.fromSTEB(5, 10, 5, 0),
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
child: Text(
controller.event.title,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.titleLarge?.copyWith(
fontFamily: 'Outfit',
color: Colors.white,
fontSize: 16,
),
),
),
],
),
);
}
//event date
Widget eventDate(BuildContext context, EventController controller) {
return Padding(
padding: const EdgeInsetsDirectional.fromSTEB(5, 10, 5, 0),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
DateFormat('dd.MM.yyyy').format(controller.event.uploadTime),
style: Theme.of(context).textTheme.bodyText2?.copyWith(
fontFamily: 'Outfit',
color: hexStringToColor("#AAAAAA"),
fontSize: 12,
fontWeight: FontWeight.normal,
),
),
],
),
);
}
//event hashtag
Widget eventHashTag(BuildContext context, EventController controller) {
return Padding(
padding: const EdgeInsetsDirectional.fromSTEB(5, 10, 5, 6),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
child: Text(
"#${controller.event.tag}",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodyText2?.copyWith(
fontFamily: 'Outfit',
color: hexStringToColor("#AAAAAA"),
fontSize: 12,
fontWeight: FontWeight.normal,
),
),
),
],
),
);
}
Widget contentUI(BuildContext context, EventController controller) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
categoryButton(context, controller),
eventTitle(context, controller),
eventDate(context, controller),
eventHashTag(context, controller),
],
);
}
Widget eventUI(BuildContext context, EventController controller,
{Function? setState}) {
return Padding(
padding: const EdgeInsetsDirectional.fromSTEB(8, 12, 6, 0),
child: SizedBox(
width: 176,
child: Padding(
padding: const EdgeInsetsDirectional.fromSTEB(6, 8, 6, 4),
child: GestureDetector(
onTap: () {
Navigator.pushNamed(context, 'event_detail',
arguments: {'event': controller.event});
},
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [
eventPhoto(context, controller),
contentUI(context, controller)
],
),
),
),
),
);
}