Skip to content

Commit

Permalink
Merge pull request #23 from DataScience-GT/development
Browse files Browse the repository at this point in the history
event deleted filter
  • Loading branch information
vicente6j authored Jan 28, 2024
2 parents ab13c9f + 258b44d commit 24ad997
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 78 deletions.
Binary file added assets/icon/hacklytics24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 4 additions & 6 deletions lib/App.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,13 @@ class _MyAppState extends State<MyApp> {
signUpForm: SignUpForm.custom(fields: [
SignUpFormField.email(required: true),
SignUpFormField.custom(
title: 'GT Email',
title: 'School Email',
attributeKey: const CognitoUserAttributeKey.custom('gtemail'),
hintText: "Enter your GaTech email",
hintText: "Enter your school email",
validator: ((value) {
// if value is not null
if (value != null && value.isNotEmpty) {
// if value is not a valid GT email
if (!value.contains('@gatech.edu')) {
return 'Please enter a valid GT email';
if (!value.contains('.edu')) {
return 'Please enter a valid school email';
}
}
})),
Expand Down
2 changes: 1 addition & 1 deletion lib/config.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Config {
/// The name of the app (appears at the top of Home page)
static const String appName = "Hacklytics 2023";
static const String appName = "Hacklytics 2024";

/// Whether to show the debug logs
static const bool isDebug = true;
Expand Down
162 changes: 91 additions & 71 deletions lib/view/Home.view.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:convert';

import 'package:amplify_api/amplify_api.dart';
import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
Expand Down Expand Up @@ -57,44 +59,44 @@ class _HomeViewState extends State<HomeView> {
: _buildBody(),
endDrawer: Drawer(
child: ListView(children: [
const DrawerHeader(
child: Text("Hacklytics"),
),
_loadingUser == false && _error.isEmpty && _user.hasAccess
? Column(children: [
ListTile(
title: const Text("General NFC"),
leading: const Icon(Icons.sensors),
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) {
return const NfcView();
}));
},
),
const Divider()
])
: const SizedBox(
width: 0,
height: 0,
),
ListTile(
title: const Text("Settings"),
leading: const Icon(Icons.settings),
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) {
return SettingsView(user: _user);
}));
},
),
const Divider(),
ListTile(
title: const Text("Logout"),
leading: const Icon(Icons.logout),
onTap: () {
Amplify.Auth.signOut();
},
)
const DrawerHeader(
child: Text("Hacklytics 2024"),
),
_loadingUser == false && _error.isEmpty && _user.hasAccess
? Column(children: [
ListTile(
title: const Text("General NFC"),
leading: const Icon(Icons.sensors),
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) {
return const NfcView();
}));
},
),
const Divider()
])
: const SizedBox(
width: 0,
height: 0,
),
ListTile(
title: const Text("Settings"),
leading: const Icon(Icons.settings),
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) {
return SettingsView(user: _user);
}));
},
),
const Divider(),
ListTile(
title: const Text("Logout"),
leading: const Icon(Icons.logout),
onTap: () {
Amplify.Auth.signOut();
},
)
])),
);
}
Expand Down Expand Up @@ -171,32 +173,15 @@ class _HomeViewState extends State<HomeView> {
: Colors.red.shade500,
),
title: Text(_events[index].name),
// title: Flexible(
// child: Row(children: [
// Padding(
// padding: const EdgeInsets.only(right: 8),
// child: Text(
// _events[index].name,
// ),
// ),
// Chip(
// label: _events[index].status == true
// ? const Text("open")
// : const Text("closed"),
// backgroundColor: _events[index].status == true
// ? Colors.green.shade500
// : Colors.red.shade500,
// )
// ]),
// ),
subtitle: _events[index].description != null &&
_events[index].description!.isNotEmpty
? Text(_events[index].description ?? "")
&& _events[index].start != null &&
_events[index].location != null
? Text("${_events[index].description ?? ""}\n"
"Location: ${_events[index].location ?? ""}\n")
: null,
// enabled: _events[index].status == true,
trailing: const Icon(Icons.chevron_right),
onTap: () {
// go to event page
// TODO: implement
Navigator.push(
context,
Expand Down Expand Up @@ -232,7 +217,6 @@ class _HomeViewState extends State<HomeView> {
callback(Status.withError(error: "No access token."));
return;
}

var attributes = await Amplify.Auth.fetchUserAttributes();

setState(() {
Expand All @@ -244,28 +228,64 @@ class _HomeViewState extends State<HomeView> {
} catch (err) {
return callback(Status.withError(error: err));
}
// return callback(Status.withSuccess(message: "Success!"));
}

getEvents(Function(Status) callback) async {
try {
final request = ModelQueries.list(Event.classType);
// final request = GraphQLRequest(
// document: req.document, apiName: "AMAZON_COGNITO_USER_POOLS", variables: );
// request.apiName = "hacklyticsportal2023_AMAZON_COGNITO_USER_POOLS";
final response = await Amplify.API.query(request: request).response;
var request = GraphQLRequest(document: '''
query ListEvents(
\$limit: Int
\$nextToken: String
) {
listEvents(
limit: \$limit
nextToken: \$nextToken
filter: {
_deleted: {
ne: true
}
}
) {
items {
id
name
description
status
requireRSVP
canRSVP
start
end
location
points
createdAt
updatedAt
_version
_deleted
_lastChangedAt
}
nextToken
startedAt
}
}
''');

var operation = Amplify.API.query(request: request);
var response = await operation.response;
if (response.errors.isNotEmpty) {
return callback(Status.withError(error: response.errors));
}
final events = response.data?.items;
var data = response.data;
var json = jsonDecode(data);
var eventsJson = json['listEvents']['items'];

if (events != null && events.isNotEmpty) {
if (eventsJson != null && eventsJson.isNotEmpty) {
List<Event> events = eventsJson.map<Event>((item) {
return Event.fromJson(item);
}).toList();
setState(() {
_events = events.map((x) => x as Event).toList();
_events = events;
});
}

// print('Events: $events');
return callback(Status.withSuccess(message: "Got events."));
} on ApiException catch (e) {
callback(Status.withError(error: e));
Expand Down

0 comments on commit 24ad997

Please sign in to comment.