Skip to content

Commit 3bf2b2d

Browse files
Merge pull request #7 from JohnRamberger/development
Development
2 parents 3845329 + 7acfbea commit 3bf2b2d

File tree

4 files changed

+196
-38
lines changed

4 files changed

+196
-38
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import 'package:amplify_flutter/amplify_flutter.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:flutter/src/widgets/container.dart';
4+
import 'package:flutter/src/widgets/framework.dart';
5+
import 'package:hacklytics_checkin_flutter/components/ListViewCard.component.dart';
6+
7+
import 'package:hacklytics_checkin_flutter/models/Event.dart';
8+
import 'package:intl/intl.dart';
9+
10+
class EventCard extends StatelessWidget {
11+
const EventCard({required this.event, super.key});
12+
13+
final Event event;
14+
15+
@override
16+
Widget build(BuildContext context) {
17+
// return Row(children: [
18+
// Expanded(
19+
// child: Card(
20+
// child: ListView(
21+
// shrinkWrap: true,
22+
// physics: const ClampingScrollPhysics(),
23+
// children: [
24+
// _buildListTile("Name", event.name),
25+
// _buildListTile("Description", event.description),
26+
// _buildListTile("Location", event.location),
27+
// _buildListTileDate("Start", event.start),
28+
// _buildListTileDate("End", event.end),
29+
// _buildListTileStatus("Status", event.status),
30+
// ],
31+
// )),
32+
// )
33+
// ]);
34+
return ListViewCard(children: [
35+
_buildListTile("Name", event.name),
36+
// const Divider(),
37+
_buildListTile("Description", event.description),
38+
// const Divider(),
39+
_buildListTile("Location", event.location),
40+
// const Divider(),
41+
_buildListTileDate("Start", event.start),
42+
// const Divider(),
43+
_buildListTileDate("End", event.end),
44+
// const Divider(),
45+
_buildListTileStatus("Status", event.status),
46+
]);
47+
}
48+
49+
_buildListTile(String title, String? subtitle) {
50+
return ListTile(
51+
title: Text(title),
52+
subtitle: subtitle != null && subtitle.isNotEmpty
53+
? Text(subtitle)
54+
: _buildRedText("Not set"),
55+
);
56+
}
57+
58+
_buildListTileStatus(String title, bool? status) {
59+
return ListTile(
60+
title: Text(title),
61+
subtitle: status != null && status == true
62+
? _buildGreenText("Open")
63+
: _buildRedText("Closed"),
64+
);
65+
}
66+
67+
_buildListTileDate(String title, TemporalDateTime? date) {
68+
final DateFormat formatter = DateFormat('MMM d, yyyy h:mm a');
69+
// format date
70+
// String formattedDate =
71+
// date != null ? formatter.format(date as DateTime) : "";
72+
String formattedDate = "";
73+
if (date != null) {
74+
var d = DateTime.parse(date.toString()).toLocal();
75+
formattedDate = formatter.format(d);
76+
}
77+
78+
return ListTile(
79+
title: Text(title),
80+
subtitle: formattedDate.isNotEmpty
81+
? Text(formattedDate)
82+
: _buildRedText("Not set"),
83+
);
84+
}
85+
86+
_buildRedText(String text) {
87+
return Text(text, style: const TextStyle(color: Colors.red));
88+
}
89+
90+
_buildGreenText(String text) {
91+
return Text(text, style: const TextStyle(color: Colors.green));
92+
}
93+
}

lib/view/Home.view.dart

Lines changed: 60 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:hacklytics_checkin_flutter/components/ListViewCard.component.dar
77

88
import 'package:hacklytics_checkin_flutter/components/statuscard.component.dart';
99
import 'package:hacklytics_checkin_flutter/models/ModelProvider.dart';
10+
import 'package:hacklytics_checkin_flutter/view/event.view.dart';
1011
import 'package:hacklytics_checkin_flutter/view/nfc.view.dart';
1112
import 'package:hacklytics_checkin_flutter/view/settings.view.dart';
1213

@@ -139,44 +140,66 @@ class _HomeViewState extends State<HomeView> {
139140

140141
return _error.isNotEmpty
141142
? StatusCard(message: _error, success: false)
142-
: SingleChildScrollView(
143-
child: ListViewCard(labelText: "Events", children: [
144-
ListView.separated(
145-
shrinkWrap: true,
146-
physics: const ClampingScrollPhysics(),
147-
itemCount: _events.length,
148-
itemBuilder: (context, index) {
149-
return ListTile(
150-
title: Row(children: [
151-
Padding(
152-
padding: const EdgeInsets.only(right: 8),
153-
child: Text(_events[index].name),
154-
),
155-
Chip(
156-
label: _events[index].status == true
157-
? const Text("open")
158-
: const Text("closed"),
159-
backgroundColor: _events[index].status == true
160-
? Colors.green.shade500
161-
: Colors.red.shade500,
162-
)
163-
]),
164-
subtitle: Text(_events[index].description ?? ""),
165-
enabled: _events[index].status == true,
166-
trailing: _events[index].status == true
167-
? const Icon(Icons.chevron_right)
168-
: null,
169-
onTap: () {
170-
// go to event page
171-
// TODO: implement
172-
print("event pressed ${_events[index].name}");
143+
: RefreshIndicator(
144+
// child: ListView(children: [
145+
// ListView.builder(
146+
// shrinkWrap: true,
147+
// physics: const ClampingScrollPhysics(),
148+
// itemBuilder: (context, index) {
149+
// return const ListTile(title: Text("Test Tile"));
150+
// },
151+
// itemCount: 12,
152+
// ),
153+
// ]),
154+
155+
child: ListView(children: [
156+
ListViewCard(labelText: "Events", children: [
157+
ListView.separated(
158+
shrinkWrap: true,
159+
physics: const ClampingScrollPhysics(),
160+
itemCount: _events.length,
161+
itemBuilder: (context, index) {
162+
return ListTile(
163+
title: Row(children: [
164+
Padding(
165+
padding: const EdgeInsets.only(right: 8),
166+
child: Text(_events[index].name),
167+
),
168+
Chip(
169+
label: _events[index].status == true
170+
? const Text("open")
171+
: const Text("closed"),
172+
backgroundColor: _events[index].status == true
173+
? Colors.green.shade500
174+
: Colors.red.shade500,
175+
)
176+
]),
177+
subtitle: Text(_events[index].description ?? ""),
178+
// enabled: _events[index].status == true,
179+
trailing: const Icon(Icons.chevron_right),
180+
onTap: () {
181+
// go to event page
182+
// TODO: implement
183+
Navigator.push(
184+
context,
185+
MaterialPageRoute(
186+
builder: (context) =>
187+
EventView(event: _events[index])));
188+
},
189+
);
173190
},
174-
);
175-
},
176-
separatorBuilder: (context, index) {
177-
return const Divider();
178-
})
179-
]));
191+
separatorBuilder: (context, index) {
192+
return const Divider();
193+
})
194+
])
195+
]),
196+
onRefresh: () async {
197+
setState(() {
198+
_loadingEvents = true;
199+
_error = "";
200+
_events = [];
201+
});
202+
});
180203
}
181204

182205
getUserInfo(Function(Status) callback) async {

lib/view/event.view.dart

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:hacklytics_checkin_flutter/components/EventCard.component.dart';
3+
import 'package:hacklytics_checkin_flutter/components/ListViewCard.component.dart';
4+
5+
import 'package:hacklytics_checkin_flutter/models/Event.dart';
6+
7+
class EventView extends StatelessWidget {
8+
const EventView({required this.event, super.key});
9+
10+
final Event event;
11+
12+
@override
13+
Widget build(BuildContext context) {
14+
return Scaffold(
15+
appBar: AppBar(
16+
title: Text(event.name),
17+
),
18+
body: ListView(
19+
children: [
20+
EventCard(event: event),
21+
ListViewCard(children: [
22+
ListTile(
23+
title: const Text("View users checked in for this event"),
24+
trailing: const Icon(Icons.ballot),
25+
onTap: () {
26+
print("View users checked in for this event");
27+
},
28+
),
29+
const Divider(),
30+
ListTile(
31+
title: const Text("Check users in for this event"),
32+
trailing: const Icon(Icons.beenhere),
33+
onTap: () {
34+
print("navigate to event check in page");
35+
},
36+
enabled: event.status == true,
37+
)
38+
])
39+
],
40+
));
41+
}
42+
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1717
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
1818
# In Windows, build-name is used as the major, minor, and patch parts
1919
# of the product and file versions while build-number is used as the build suffix.
20-
version: 1.0.31
20+
version: 1.0.32
2121

2222
environment:
2323
sdk: '>=2.18.5 <3.0.0'

0 commit comments

Comments
 (0)