Skip to content

Commit

Permalink
Merge pull request #1993 from MaximPodgore/barcode
Browse files Browse the repository at this point in the history
Update Barcode Source (#1988)
  • Loading branch information
c3bryant authored Nov 29, 2023
2 parents 6abf872 + c150868 commit add4de5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 81 deletions.
32 changes: 0 additions & 32 deletions lib/core/models/student_id_barcode.dart

This file was deleted.

17 changes: 0 additions & 17 deletions lib/core/providers/student_id.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:campus_mobile_experimental/core/models/student_id_barcode.dart';
import 'package:campus_mobile_experimental/core/models/student_id_name.dart';
import 'package:campus_mobile_experimental/core/models/student_id_photo.dart';
import 'package:campus_mobile_experimental/core/models/student_id_profile.dart';
Expand All @@ -22,7 +21,6 @@ class StudentIdDataProvider extends ChangeNotifier {
int? _selectedCourse;

///MODELS
StudentIdBarcodeModel? _studentIdBarcodeModel;
StudentIdNameModel? _studentIdNameModel;
StudentIdPhotoModel? _studentIdPhotoModel;
StudentIdProfileModel? _studentIdProfileModel;
Expand All @@ -47,20 +45,6 @@ class StudentIdDataProvider extends ChangeNotifier {
'Bearer ${_userDataProvider.authenticationModel?.accessToken}'
};

/// Fetch Barcode
if (await _studentIdService.fetchStudentIdBarcode(header) &&
_studentIdService.studentIdBarcodeModel.barCode != null) {
_studentIdBarcodeModel = _studentIdService.studentIdBarcodeModel;
} else {
/// Error Handling
_error = _studentIdService.error.toString();
_isLoading = false;
notifyListeners();

/// Short Circuit
return;
}

/// Fetch Name
if (await _studentIdService.fetchStudentIdName(header) &&
_studentIdService.studentIdNameModel.firstName != null &&
Expand Down Expand Up @@ -117,7 +101,6 @@ class StudentIdDataProvider extends ChangeNotifier {
bool? get isLoading => _isLoading;
String? get error => _error;
DateTime? get lastUpdated => _lastUpdated;
StudentIdBarcodeModel? get studentIdBarcodeModel => _studentIdBarcodeModel;
StudentIdNameModel? get studentIdNameModel => _studentIdNameModel;
StudentIdPhotoModel? get studentIdPhotoModel => _studentIdPhotoModel;
StudentIdProfileModel? get studentIdProfileModel => _studentIdProfileModel;
Expand Down
22 changes: 0 additions & 22 deletions lib/core/services/student_id.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:async';

import 'package:campus_mobile_experimental/app_networking.dart';
import 'package:campus_mobile_experimental/core/models/student_id_barcode.dart';
import 'package:campus_mobile_experimental/core/models/student_id_name.dart';
import 'package:campus_mobile_experimental/core/models/student_id_photo.dart';
import 'package:campus_mobile_experimental/core/models/student_id_profile.dart';
Expand All @@ -15,32 +14,12 @@ class StudentIdService {
bool _isLoading = false;
DateTime? _lastUpdated;
String? _error;
StudentIdBarcodeModel _studentIdBarcodeModel = StudentIdBarcodeModel();
StudentIdNameModel _studentIdNameModel = StudentIdNameModel();
StudentIdPhotoModel _studentIdPhotoModel = StudentIdPhotoModel();
StudentIdProfileModel _studentIdProfileModel = StudentIdProfileModel();

final NetworkHelper _networkHelper = NetworkHelper();

//Removed term (not used)
Future<bool> fetchStudentIdBarcode(Map<String, String> headers) async {
_error = null;
_isLoading = true;
try {
/// fetch data
String _response = await _networkHelper.authorizedFetch(
myStudentContactApiUrl + '/barcode', headers);

/// parse data
_studentIdBarcodeModel = studentIdBarcodeModelFromJson(_response);
_isLoading = false;
return true;
} catch (e) {
_error = e.toString();
_isLoading = false;
return false;
}
}

//Removed term (not used)
Future<bool> fetchStudentIdName(Map<String, String> headers) async {
Expand Down Expand Up @@ -102,7 +81,6 @@ class StudentIdService {
}

String? get error => _error;
StudentIdBarcodeModel get studentIdBarcodeModel => _studentIdBarcodeModel;
StudentIdNameModel get studentIdNameModel => _studentIdNameModel;
StudentIdPhotoModel get studentIdPhotoModel => _studentIdPhotoModel;
StudentIdProfileModel get studentIdProfileModel => _studentIdProfileModel;
Expand Down
17 changes: 7 additions & 10 deletions lib/ui/student_id/student_id_card.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:barcode_widget/barcode_widget.dart';
import 'package:campus_mobile_experimental/app_constants.dart';
import 'package:campus_mobile_experimental/app_styles.dart';
import 'package:campus_mobile_experimental/core/models/student_id_barcode.dart';
import 'package:campus_mobile_experimental/core/models/student_id_name.dart';
import 'package:campus_mobile_experimental/core/models/student_id_photo.dart';
import 'package:campus_mobile_experimental/core/models/student_id_profile.dart';
Expand Down Expand Up @@ -71,7 +70,6 @@ class _StudentIdCardState extends State<StudentIdCard> {
titleText: CardTitleConstants.titleMap[cardId],
errorText: Provider.of<StudentIdDataProvider>(context).error,
child: () => buildCardContent(
Provider.of<StudentIdDataProvider>(context).studentIdBarcodeModel,
Provider.of<StudentIdDataProvider>(context).studentIdNameModel,
Provider.of<StudentIdDataProvider>(context).studentIdPhotoModel,
Provider.of<StudentIdDataProvider>(context).studentIdProfileModel,
Expand All @@ -90,7 +88,6 @@ class _StudentIdCardState extends State<StudentIdCard> {
}

Widget buildCardContent(
StudentIdBarcodeModel? barcodeModel,
StudentIdNameModel? nameModel,
StudentIdPhotoModel? photoModel,
StudentIdProfileModel? profileModel,
Expand Down Expand Up @@ -197,17 +194,17 @@ class _StudentIdCardState extends State<StudentIdCard> {
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
child: returnBarcodeContainer(
barcodeModel!.barCode.toString(),
profileModel.barcode.toString(),
false,
context),
onPressed: () {
createAlertDialog(
context,
returnBarcodeContainer(
barcodeModel.barCode.toString(),
profileModel.barcode.toString(),
true,
context),
barcodeModel.toString(),
profileModel.toString(),
true);
},
),
Expand Down Expand Up @@ -236,7 +233,7 @@ class _StudentIdCardState extends State<StudentIdCard> {
(ScalingUtility.horizontalSafeBlock * 11.225) +
realignText(Theme.of(context))),
child: Text(
barcodeModel.barCode.toString(),
profileModel.barcode.toString(),
style: TextStyle(
fontSize: ScalingUtility.horizontalSafeBlock * 3,
letterSpacing:
Expand Down Expand Up @@ -332,13 +329,13 @@ class _StudentIdCardState extends State<StudentIdCard> {
padding: EdgeInsets.all(0),
),
child: returnBarcodeContainerTablet(
barcodeModel!.barCode.toString(), false, context),
profileModel!.barcode.toString(), false, context),
onPressed: () {
createAlertDialog(
context,
returnBarcodeContainer(
barcodeModel.barCode.toString(), true, context),
barcodeModel.barCode.toString(),
profileModel!.barcode.toString(), true, context),
profileModel.barcode.toString(),
true);
},
),
Expand Down

0 comments on commit add4de5

Please sign in to comment.