Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triton media #1910

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
418d828
changes from http to dio. Some trouble still
Nov 13, 2022
0261bd7
http updates for authorized fetch. Authorized post still needs fixing
Nov 18, 2022
2e80e98
http package has been integrated for app_networking.dart. Next step i…
Nov 22, 2022
77a2afe
http package has been integrated for app_networking.dart. Next step i…
Nov 22, 2022
15ab8f1
pubspec
Nov 22, 2022
e9e814a
Flutter upgrade
Nov 22, 2022
0df1221
http changes for provider speed_test.dart
Nov 24, 2022
8d2b8e5
http update
Dec 1, 2022
c4b2ae0
working on copying event cards for skeleton for triton media card
Dec 14, 2022
4ea2f2b
working on copying event cards for skeleton for triton media card
Dec 14, 2022
11369be
triton media changes
Dec 16, 2022
1c63254
triton media name changes
Dec 16, 2022
0471185
triton media added to home ui
Dec 16, 2022
9f7ce83
Adding pause/play, forward/backward 10sec, and sliding bar. forward/b…
Dec 20, 2022
dd836c2
test mp3 file added to assets and pubspec
Dec 20, 2022
a6a0e2e
Changes to icons for triton media
Dec 20, 2022
a983a49
icon adjustments triton media
Dec 20, 2022
6ab54b6
+-10 second functionality added. Problem: stopping audio when popping…
Dec 21, 2022
d8e0bb4
Improvement for functionality of +-10 sec and pause/play buttons
Dec 21, 2022
7b94c2f
disposing audio when triton media detailed view card is popped off
Dec 21, 2022
38d80d7
Merge remote-tracking branch 'upstream/experimental' into experimental
Dec 21, 2022
f1b4fbb
Merge branch 'experimental' into triton_media
Dec 21, 2022
d5a1fa8
Adding stream playing. Problem: With stream playing, you can only pau…
Dec 21, 2022
435cc19
removing video player edits
Jan 6, 2023
48acbd7
checkout changes
Jan 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/theme_01.mp3
Binary file not shown.
14 changes: 10 additions & 4 deletions lib/app_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ class RoutePaths {

static const String NewsViewAll = 'news/newslist';
static const String EventsViewAll = 'events/eventslist';
static const String EventsAll = 'events/events_view_all';
static const String EventsAll = 'triton_media/triton_media_view_all';
static const String MediaViewAll = 'triton_media/triton_media_list';
static const String MediaAll = 'triton_media/triton_media_view_all';
static const String NewsDetailView = 'news/news_detail_view';
static const String EventDetailView = 'events/event_detail_view';
static const String MediaDetailView = 'triton_media/triton_media_detail_view';
static const String LinksViewAll = 'links/links_list';
static const String ClassScheduleViewAll = 'class/classList';
static const String ManageAvailabilityView =
Expand Down Expand Up @@ -53,6 +56,8 @@ class RouteTitles {
'news/news_detail_view': 'News',
'events/eventslist': 'Events',
'events/event_detail_view': 'Events',
'triton_media/triton_media_list': 'Triton Media',
'triton_media/triton_media_detail_view': 'Triton Media',
'class/classList': 'Class Schedule',
'availability/manage_locations_view': 'Manage Locations',
'shuttle/manage_shuttle_view': 'Manage Shuttle Stops',
Expand Down Expand Up @@ -95,11 +100,11 @@ class ErrorConstants {
static const authorizedPutErrors = 'Failed to update data: ';
static const invalidBearerToken = 'Invalid bearer token';
static const notAcceptable =
'DioError [DioErrorType.response]: Http status error [406]';
'HttpError [HttpErrorType.response]: Http status error [406]';
static const duplicateRecord =
'DioError [DioErrorType.response]: Http status error [409]';
'HttpError [HttpErrorType.response]: Http status error [409]';
static const invalidMedia =
'DioError [DioErrorType.response]: Http status error [415]';
'HttpError [HttpErrorType.response]: Http status error [415]';
static const silentLoginFailed = "Silent login failed";
static const locationFailed = "Location was not available";
}
Expand Down Expand Up @@ -179,6 +184,7 @@ class CardTitleConstants {
'dining': 'Dining',
'availability': 'Busyness',
'events': 'Events',
'triton_media': 'Triton Media',
'news': 'News',
'parking': 'Parking',
'weather': 'Weather',
Expand Down
67 changes: 21 additions & 46 deletions lib/app_networking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:async';

import 'package:campus_mobile_experimental/app_constants.dart';
import 'package:campus_mobile_experimental/app_styles.dart';
import 'package:dio/dio.dart';
import 'package:http/http.dart' as http;
import 'package:flutter/material.dart';
import 'package:get/get.dart';

Expand All @@ -16,40 +16,29 @@ class NetworkHelper {
static const int SSO_REFRESH_RETRY_MULTIPLIER = 3;

Future<dynamic> fetchData(String url) async {
Dio dio = new Dio();
dio.options.connectTimeout = 20000;
dio.options.receiveTimeout = 20000;
dio.options.responseType = ResponseType.plain;
final _response = await dio.get(url);
final _response = await http.get(Uri.parse(url));

if (_response.statusCode == 200) {
// If server returns an OK response, return the body
return _response.data;
return _response.body;
} else {
///TODO: log this as a bug because the response was bad
// If that response was not OK, throw an error.
throw Exception('Failed to fetch data: ' + _response.data);
throw Exception('Failed to fetch data: ' + _response.body);
}
}

Future<dynamic> authorizedFetch(
String url, Map<String, String> headers) async {
Dio dio = new Dio();
dio.options.connectTimeout = 20000;
dio.options.receiveTimeout = 20000;
dio.options.responseType = ResponseType.plain;
dio.options.headers = headers;
final _response = await dio.get(
url,
);
final _response = await http.get(Uri.parse(url), headers: headers);
if (_response.statusCode == 200) {
// If server returns an OK response, return the body
return _response.data;
return _response.body;
} else {
///TODO: log this as a bug because the response was bad
// If that response was not OK, throw an error.

throw Exception('Failed to fetch data: ' + _response.data);
throw Exception('Failed to fetch data: ' + _response.body);
}
}

Expand Down Expand Up @@ -110,29 +99,24 @@ class NetworkHelper {

Future<dynamic> authorizedPost(
String url, Map<String, String>? headers, dynamic body) async {
Dio dio = new Dio();
dio.options.connectTimeout = 20000;
dio.options.receiveTimeout = 20000;
dio.options.headers = headers;
final _response = await dio.post(url, data: body);
final _response = await http.post(Uri.parse(url), headers: headers, body: body);
if (_response.statusCode == 200 || _response.statusCode == 201) {
// If server returns an OK response, return the body
return _response.data;
return _response.body;
} else if (_response.statusCode == 400) {
// If that response was not OK, throw an error.
String message = _response.data['message'] ?? '';
String message = _response.body;
throw Exception(ErrorConstants.authorizedPostErrors + message);
} else if (_response.statusCode == 401) {
throw Exception(ErrorConstants.authorizedPostErrors +
ErrorConstants.invalidBearerToken);
} else if (_response.statusCode == 404) {
String message = _response.data['message'] ?? '';
String message = _response.body;
throw Exception(ErrorConstants.authorizedPostErrors + message);
} else if (_response.statusCode == 500) {
String message = _response.data['message'] ?? '';
String message = _response.body;
throw Exception(ErrorConstants.authorizedPostErrors + message);
} else if (_response.statusCode == 409) {
String message = _response.data['message'] ?? '';
String message = _response.body;
throw Exception(ErrorConstants.duplicateRecord + message);
} else {
throw Exception(ErrorConstants.authorizedPostErrors + 'unknown error');
Expand All @@ -141,27 +125,22 @@ class NetworkHelper {

Future<dynamic> authorizedPut(
String url, Map<String, String> headers, dynamic body) async {
Dio dio = new Dio();
dio.options.connectTimeout = 20000;
dio.options.receiveTimeout = 20000;
dio.options.headers = headers;
final _response = await dio.put(url, data: body);

final _response = await http.put(Uri.parse(url), headers: headers, body: body);
if (_response.statusCode == 200 || _response.statusCode == 201) {
// If server returns an OK response, return the body
return _response.data;
return _response.body;
} else if (_response.statusCode == 400) {
// If that response was not OK, throw an error.
String message = _response.data['message'] ?? '';
String message = _response.body;
throw Exception(ErrorConstants.authorizedPutErrors + message);
} else if (_response.statusCode == 401) {
throw Exception(ErrorConstants.authorizedPutErrors +
ErrorConstants.invalidBearerToken);
} else if (_response.statusCode == 404) {
String message = _response.data['message'] ?? '';
String message = _response.body;
throw Exception(ErrorConstants.authorizedPutErrors + message);
} else if (_response.statusCode == 500) {
String message = _response.data['message'] ?? '';
String message = _response.body;
throw Exception(ErrorConstants.authorizedPutErrors + message);
} else {
throw Exception(ErrorConstants.authorizedPutErrors + 'unknown error');
Expand All @@ -170,19 +149,15 @@ class NetworkHelper {

Future<dynamic> authorizedDelete(
String url, Map<String, String> headers) async {
Dio dio = new Dio();
dio.options.connectTimeout = 20000;
dio.options.receiveTimeout = 20000;
dio.options.headers = headers;
try {
final _response = await dio.delete(url);
final _response = await http.delete(Uri.parse(url), headers: headers);
if (_response.statusCode == 200) {
// If server returns an OK response, return the body
return _response.data;
return _response.body;
} else {
///TODO: log this as a bug because the response was bad
// If that response was not OK, throw an error.
throw Exception('Failed to delete data: ' + _response.data);
throw Exception('Failed to delete data: ' + _response.body);
}
} on TimeoutException catch (err) {
print(err);
Expand Down
8 changes: 8 additions & 0 deletions lib/app_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import 'package:campus_mobile_experimental/core/providers/speed_test.dart';
import 'package:campus_mobile_experimental/core/providers/student_id.dart';
import 'package:campus_mobile_experimental/core/providers/user.dart';
import 'package:campus_mobile_experimental/core/providers/weather.dart';
import 'package:campus_mobile_experimental/core/providers/triton_media.dart';
import 'package:campus_mobile_experimental/ui/navigator/top.dart';
import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:firebase_analytics/observer.dart';
Expand Down Expand Up @@ -59,6 +60,13 @@ List<SingleChildWidget> independentServices = [
return _eventsDataProvider;
},
),
ChangeNotifierProvider<MediaDataProvider>(
create: (_) {
MediaDataProvider _mediaDataProvider = MediaDataProvider();
_mediaDataProvider.fetchMedia();
return _mediaDataProvider;
},
),
ChangeNotifierProvider<WeatherDataProvider>(
create: (_) {
WeatherDataProvider _weatherDataProvider = WeatherDataProvider();
Expand Down
21 changes: 21 additions & 0 deletions lib/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:campus_mobile_experimental/core/models/availability.dart';
import 'package:campus_mobile_experimental/core/models/dining.dart';
import 'package:campus_mobile_experimental/core/models/dining_menu.dart';
import 'package:campus_mobile_experimental/core/models/events.dart';
import 'package:campus_mobile_experimental/core/models/triton_media.dart';
import 'package:campus_mobile_experimental/core/models/news.dart';
import 'package:campus_mobile_experimental/ui/availability/availability_detail_view.dart';
import 'package:campus_mobile_experimental/ui/availability/manage_availability_view.dart';
Expand All @@ -13,6 +14,9 @@ import 'package:campus_mobile_experimental/ui/dining/nutrition_facts_view.dart';
import 'package:campus_mobile_experimental/ui/events/events_detail_view.dart';
import 'package:campus_mobile_experimental/ui/events/events_list.dart';
import 'package:campus_mobile_experimental/ui/events/events_view_all.dart';
import 'package:campus_mobile_experimental/ui/triton_media/triton_media_detail_view.dart';
import 'package:campus_mobile_experimental/ui/triton_media/triton_media_list.dart';
import 'package:campus_mobile_experimental/ui/triton_media/triton_media_view_all.dart';
import 'package:campus_mobile_experimental/ui/home/home.dart';
import 'package:campus_mobile_experimental/ui/map/map.dart' as prefix0;
import 'package:campus_mobile_experimental/ui/map/map_search_view.dart';
Expand Down Expand Up @@ -40,6 +44,7 @@ import 'package:campus_mobile_experimental/ui/shuttle/manage_shuttle_view.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';


class Router {
static Route<dynamic> generateRoute(RouteSettings settings) {
switch (settings.name) {
Expand Down Expand Up @@ -76,6 +81,11 @@ class Router {
Provider.of<CustomAppBar>(context).changeTitle(settings.name);
return EventsList();
});
case RoutePaths.MediaViewAll:
return MaterialPageRoute(builder: (context) {
Provider.of<CustomAppBar>(context).changeTitle(settings.name);
return MediaList();
});
case RoutePaths.NewsDetailView:
Item newsItem = settings.arguments as Item;
return MaterialPageRoute(builder: (_) {
Expand All @@ -93,6 +103,17 @@ class Router {
Provider.of<CustomAppBar>(context).changeTitle(settings.name);
return EventsAll();
});
case RoutePaths.MediaDetailView:
MediaModel data = settings.arguments as MediaModel;
return MaterialPageRoute(builder: (_) {
Provider.of<CustomAppBar>(_).changeTitle(settings.name);
return MediaDetailView(data: data);
});
case RoutePaths.MediaAll:
return MaterialPageRoute(builder: (context) {
Provider.of<CustomAppBar>(context).changeTitle(settings.name);
return MediaAll();
});
case RoutePaths.ManageAvailabilityView:
return MaterialPageRoute(builder: (_) {
Provider.of<CustomAppBar>(_).changeTitle(settings.name);
Expand Down
69 changes: 69 additions & 0 deletions lib/core/models/triton_media.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// To parse this JSON data, do
//
// final eventModel = eventModelFromJson(jsonString);

import 'dart:convert';

List<MediaModel> mediaModelFromJson(String str) =>
List<MediaModel>.from(json.decode(str).map((x) => MediaModel.fromJson(x)));

String mediaModelToJson(List<MediaModel> data) =>
json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

class MediaModel {
MediaModel({
this.title,
this.description,
this.startDate,
this.endDate,
this.imageHQ,
this.imageThumb,
this.link,
this.id,
this.tags,
this.location,
this.eventDate,
});

String? title;
String? description;
DateTime? startDate;
DateTime? endDate;
String? imageHQ;
String? imageThumb;
String? link;
String? id;
List<String>? tags;
String? location;
DateTime? eventDate;

factory MediaModel.fromJson(Map<String, dynamic> json) => MediaModel(
title: json["title"] == null ? null : json["title"],
description: json["description"] == null ? null : json["description"],
startDate: DateTime.tryParse(json["startDate"]),
endDate: DateTime.tryParse(json["endDate"]),
eventDate: DateTime.tryParse(json["eventdate"]),
imageHQ: json["imageHQ"] == null ? null : json["imageHQ"],
imageThumb: json["imageThumb"] == null ? null : json["imageThumb"],
link: json["link"] == null ? null : json["link"],
id: json["id"] == null ? null : json["id"],
tags: json["tags"] == null
? null
: List<String>.from(json["tags"].map((x) => x)),
location: json["location"] == null ? null : json["location"],
);

Map<String, dynamic> toJson() => {
"title": title == null ? null : title,
"description": description == null ? null : description,
"startDate": startDate == null ? null : startDate,
"endDate": endDate == null ? null : endDate,
"eventdate": eventDate == null ? null : eventDate,
"imageHQ": imageHQ == null ? null : imageHQ,
"imageThumb": imageThumb == null ? null : imageThumb,
"link": link == null ? null : link,
"id": id == null ? null : id,
"tags": tags == null ? null : List<dynamic>.from(tags!.map((x) => x)),
"location": location == null ? null : location,
};
}
1 change: 1 addition & 0 deletions lib/core/providers/cards.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class CardsDataProvider extends ChangeNotifier {
'availability',
'dining',
'events',
'triton_media',
'shuttle',
'parking',
'news',
Expand Down
Loading