diff --git a/lib/ui/common/card_container.dart b/lib/ui/common/card_container.dart index 13433db9d..15e8fcc49 100644 --- a/lib/ui/common/card_container.dart +++ b/lib/ui/common/card_container.dart @@ -132,7 +132,7 @@ class CardContainer extends StatelessWidget { // web cards are still sized with static values return Container( width: double.infinity, - constraints: BoxConstraints(minHeight: cardMinHeight, maxHeight: 340), + constraints: BoxConstraints(minHeight: cardMinHeight, maxHeight: 260), child: child(), ); } else if (titleText == "Parking") { diff --git a/lib/ui/employee_id/employee_id_card.dart b/lib/ui/employee_id/employee_id_card.dart index 9cc1c1f78..11cb0cb1b 100644 --- a/lib/ui/employee_id/employee_id_card.dart +++ b/lib/ui/employee_id/employee_id_card.dart @@ -1,4 +1,5 @@ import 'package:barcode_widget/barcode_widget.dart'; +import 'package:cached_network_image/cached_network_image.dart'; import 'package:campus_mobile_experimental/app_constants.dart'; import 'package:campus_mobile_experimental/app_styles.dart'; import 'package:campus_mobile_experimental/core/models/employee_id.dart'; @@ -8,30 +9,18 @@ import 'package:campus_mobile_experimental/core/utils/webview.dart'; import 'package:campus_mobile_experimental/ui/common/card_container.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:provider/provider.dart'; -class EmployeeIdCard extends StatefulWidget { - @override - _EmployeeIdCardState createState() => _EmployeeIdCardState(); -} - -class _EmployeeIdCardState extends State { - String cardId = "employee_id"; - final placeholderPhotoUrl = dotenv.get('PLACEHOLDER_PERSON_PHOTO'); - bool isValidId = false; +class EmployeeIdCard extends StatelessWidget { + final String cardId = "employee_id"; + final String placeholderPhotoUrl = + "https://mobile.ucsd.edu/replatform/v1/qa/webview/resources/img/placeholderPerson.png"; - @override Widget build(BuildContext context) { ScalingUtility().getCurrentMeasurements(context); EmployeeIdModel? employeeModel = Provider.of(context).employeeIdModel; - isValidId = employeeModel != null && - (employeeModel.barcode != null) && - (employeeModel.employeePreferredDisplayName != null && - employeeModel.employeeId != null); - return CardContainer( active: Provider.of(context).cardStates[cardId], hide: () => Provider.of(context, listen: false) @@ -41,7 +30,10 @@ class _EmployeeIdCardState extends State { isLoading: Provider.of(context).isLoading, titleText: CardTitleConstants.titleMap[cardId]!, errorText: Provider.of(context).error, - child: () => isValidId + child: () => (employeeModel != null && + (employeeModel.barcode != null) && + (employeeModel.employeePreferredDisplayName != null && + employeeModel.employeeId != null)) ? buildCardContent( Provider.of(context).employeeIdModel, context) @@ -59,7 +51,6 @@ class _EmployeeIdCardState extends State { bottom: 32.0, ), child: Column( - // mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Center( @@ -103,8 +94,8 @@ class _EmployeeIdCardState extends State { left: cardMargin * 1.5, right: cardMargin * 1.5)), Column( children: [ - Image.network( - employeeIdModel!.photo.contains("https") + CachedNetworkImage( + imageUrl: employeeIdModel!.photo.contains("https") ? employeeIdModel.photo : placeholderPhotoUrl, fit: BoxFit.contain, @@ -240,8 +231,8 @@ class _EmployeeIdCardState extends State { Container( child: Column( children: [ - Image.network( - employeeIdModel!.photo.contains("https") + CachedNetworkImage( + imageUrl: employeeIdModel!.photo.contains("https") ? employeeIdModel.photo : placeholderPhotoUrl, fit: BoxFit.contain, @@ -266,7 +257,7 @@ class _EmployeeIdCardState extends State { employeeIdModel.employeePreferredDisplayName, style: TextStyle( fontWeight: FontWeight.bold, - fontSize: tabletFontSize( + fontSize: tabletFontSize(context, employeeIdModel.employeePreferredDisplayName, "name")), textAlign: TextAlign.left, @@ -283,7 +274,7 @@ class _EmployeeIdCardState extends State { style: TextStyle( color: Colors.grey, fontSize: - tabletFontSize(employeeIdModel.department, "")), + tabletFontSize(context, employeeIdModel.department, "")), textAlign: TextAlign.left, softWrap: false, maxLines: 1, @@ -295,7 +286,7 @@ class _EmployeeIdCardState extends State { child: Text( "Employee ID " + employeeIdModel.employeeId, style: TextStyle( - fontSize: tabletFontSize( + fontSize: tabletFontSize(context, "Employee ID " + employeeIdModel.employeeId, "")), textAlign: TextAlign.left, softWrap: false, @@ -443,8 +434,8 @@ class _EmployeeIdCardState extends State { cardNumber, style: TextStyle( color: Colors.black, - fontSize: fontSizeForTablet(), - letterSpacing: letterSpacingForTablet()), + fontSize: fontSizeForTablet(context), + letterSpacing: letterSpacingForTablet(context)), ) ], ), @@ -472,14 +463,14 @@ class _EmployeeIdCardState extends State { } } - double letterSpacingForTablet() { + double letterSpacingForTablet(BuildContext context) { if (MediaQuery.of(context).orientation == Orientation.landscape) { return ScalingUtility.horizontalSafeBlock * 1; } return ScalingUtility.horizontalSafeBlock * 3; } - double fontSizeForTablet() { + double fontSizeForTablet(BuildContext context) { if (MediaQuery.of(context).orientation == Orientation.landscape) { return ScalingUtility.horizontalSafeBlock * 2; } @@ -539,8 +530,8 @@ class _EmployeeIdCardState extends State { cardNumber, style: TextStyle( color: Colors.black, - fontSize: getRotatedPopUpFontSize(), - letterSpacing: letterSpacing()), + fontSize: getRotatedPopUpFontSize(context), + letterSpacing: letterSpacing(context)), ) ], ), @@ -574,12 +565,12 @@ class _EmployeeIdCardState extends State { } } - double letterSpacing() => + double letterSpacing(BuildContext context) => MediaQuery.of(context).orientation == Orientation.landscape ? SizeConfig.safeBlockHorizontal * 1 : SizeConfig.safeBlockHorizontal * 3; - double getRotatedPopUpFontSize() => + double getRotatedPopUpFontSize(BuildContext context) => MediaQuery.of(context).orientation == Orientation.landscape ? SizeConfig.safeBlockHorizontal * 2 : SizeConfig.safeBlockHorizontal * 4; @@ -603,9 +594,9 @@ class _EmployeeIdCardState extends State { return base; } - double tabletFontSize(String input, String textField) { + double tabletFontSize(BuildContext context, String input, String textField) { /// Base font size - double base = letterSpacingForTablet(); + double base = letterSpacingForTablet(context); /// If threshold is passed, shrink text // if (input.length >= 21) { diff --git a/lib/ui/events/event_tile.dart b/lib/ui/events/event_tile.dart index f29dcd9c5..b910021de 100644 --- a/lib/ui/events/event_tile.dart +++ b/lib/ui/events/event_tile.dart @@ -1,3 +1,4 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:campus_mobile_experimental/app_constants.dart'; import 'package:campus_mobile_experimental/core/models/events.dart'; import 'package:campus_mobile_experimental/core/providers/events.dart'; @@ -23,7 +24,7 @@ class EventTile extends StatelessWidget Widget buildEventTile(BuildContext context) { return Container( width: tileWidth, - height: 300, + height: 285, margin: EdgeInsets.zero, child: InkWell( onTap: () { @@ -79,28 +80,24 @@ class EventTile extends StatelessWidget ? Container( child: Image( image: AssetImage('assets/images/UCSDMobile_sharp.png'), - height: 150, + height: 125, width: tileWidth, fit: BoxFit.fill, )) - : Image.network( - url, - loadingBuilder: (BuildContext context, Widget child, - ImageChunkEvent? loadingProgress) { - if (loadingProgress == null) return child; + : CachedNetworkImage( + imageUrl: url, + height: 125, + width: tileWidth, + fit: BoxFit.fill, + progressIndicatorBuilder: (context, url, downloadProgress) { return Center( child: CircularProgressIndicator( color: Theme.of(context).colorScheme.secondary, - value: loadingProgress.expectedTotalBytes != null - ? loadingProgress.cumulativeBytesLoaded / - loadingProgress.expectedTotalBytes! - : null, + value: downloadProgress.progress, ), ); }, - fit: BoxFit.fill, - height: 150, - width: tileWidth, + errorWidget: (context, url, error) => Icon(Icons.error), ); } diff --git a/lib/ui/events/events_list.dart b/lib/ui/events/events_list.dart index 2002efa33..e4cc91d6c 100644 --- a/lib/ui/events/events_list.dart +++ b/lib/ui/events/events_list.dart @@ -59,9 +59,5 @@ class EventsList extends StatelessWidget { : EventsAll(), ); } - // ListView( - // children: - // ListTile.divideTiles(tiles: eventTiles, context: context) - // .toList(), } } diff --git a/lib/ui/events/events_view_all.dart b/lib/ui/events/events_view_all.dart index a896e73d4..3ca8b7b69 100644 --- a/lib/ui/events/events_view_all.dart +++ b/lib/ui/events/events_view_all.dart @@ -29,11 +29,9 @@ class EventsAll extends StatelessWidget { if (listOfEvents.length > 0) { return GridView.count( crossAxisCount: 2, - crossAxisSpacing: 1, - mainAxisSpacing: 8, children: eventTiles, childAspectRatio: MediaQuery.of(context).size.width / - (MediaQuery.of(context).size.height / 1.4), + (MediaQuery.of(context).size.height / 1.6), ); } else { return ContainerView( diff --git a/lib/ui/finals/finals_card.dart b/lib/ui/finals/finals_card.dart index c4458cac5..d3c929d87 100644 --- a/lib/ui/finals/finals_card.dart +++ b/lib/ui/finals/finals_card.dart @@ -64,6 +64,7 @@ class FinalsCard extends StatelessWidget { Widget buildFinalsCard(Map> finalsData, DateTime lastUpdated, String? nextDayWithClasses, BuildContext context) { try { + // Flatten the data into a single list of ListTile widgets List listToReturn = []; finalsData.forEach((key, value) { for (SectionData data in value) { @@ -81,6 +82,7 @@ class FinalsCard extends StatelessWidget { )); } }); + listToReturn = ListTile.divideTiles(tiles: listToReturn, context: context).toList(); listToReturn.add( @@ -89,9 +91,13 @@ class FinalsCard extends StatelessWidget { child: LastUpdatedWidget(time: lastUpdated), ), ); - return ListView( + + return ListView.builder( physics: NeverScrollableScrollPhysics(), - children: listToReturn, + itemCount: listToReturn.length, + itemBuilder: (context, index) { + return listToReturn[index]; + }, shrinkWrap: true, ); } catch (e) { diff --git a/lib/ui/mystudentchart/mystudentchart_card.dart b/lib/ui/mystudentchart/mystudentchart_card.dart index 798711ca7..4a7396b17 100644 --- a/lib/ui/mystudentchart/mystudentchart_card.dart +++ b/lib/ui/mystudentchart/mystudentchart_card.dart @@ -1,3 +1,4 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:campus_mobile_experimental/app_constants.dart'; import 'package:campus_mobile_experimental/core/providers/cards.dart'; import 'package:campus_mobile_experimental/ui/common/card_container.dart'; diff --git a/lib/ui/parking/parking_card.dart b/lib/ui/parking/parking_card.dart index ae24d0638..880ffb781 100644 --- a/lib/ui/parking/parking_card.dart +++ b/lib/ui/parking/parking_card.dart @@ -77,9 +77,12 @@ class _ParkingCardState extends State { return Column( children: [ Expanded( - child: PageView( + child: PageView.builder( controller: _controller, - children: selectedLotsViews, + itemCount: selectedLotsViews.length, + itemBuilder: (context, index) { + return selectedLotsViews[index]; + }, ), ), DotsIndicator( diff --git a/lib/ui/scanner/native_scanner_card.dart b/lib/ui/scanner/native_scanner_card.dart index d754e11bd..0e1f1bfdc 100644 --- a/lib/ui/scanner/native_scanner_card.dart +++ b/lib/ui/scanner/native_scanner_card.dart @@ -39,8 +39,8 @@ class NativeScannerCard extends StatelessWidget child: Row( children: [ Container( - child: Image.asset( - 'assets/images/QRScanIcon.png', + child: Image( + image: AssetImage('assets/images/QRScanIcon.png'), fit: BoxFit.contain, height: 56, ), diff --git a/lib/ui/shuttle/shuttle_display.dart b/lib/ui/shuttle/shuttle_display.dart index a40d2537e..0b8752c33 100644 --- a/lib/ui/shuttle/shuttle_display.dart +++ b/lib/ui/shuttle/shuttle_display.dart @@ -159,7 +159,7 @@ class ShuttleDisplay extends StatelessWidget { Widget whetherNextArrivals() { if (arrivingShuttles!.length <= 1) { - return Text(""); + return Text("No future arrivals."); } else { return Row( mainAxisAlignment: MainAxisAlignment.start, diff --git a/lib/ui/wifi/wifi_card.dart b/lib/ui/wifi/wifi_card.dart index 210173368..6b666fcdd 100644 --- a/lib/ui/wifi/wifi_card.dart +++ b/lib/ui/wifi/wifi_card.dart @@ -4,7 +4,6 @@ import 'package:campus_mobile_experimental/app_constants.dart'; import 'package:campus_mobile_experimental/app_styles.dart'; import 'package:campus_mobile_experimental/core/providers/cards.dart'; import 'package:campus_mobile_experimental/core/providers/speed_test.dart'; -import 'package:campus_mobile_experimental/core/providers/user.dart'; import 'package:campus_mobile_experimental/ui/common/card_container.dart'; import 'package:flutter/material.dart'; import 'package:liquid_progress_indicator_v2/liquid_progress_indicator.dart'; @@ -23,7 +22,6 @@ class _WiFiCardState extends State with AutomaticKeepAliveClientMixin late bool goodSpeed; bool timedOut = false; SpeedTestProvider _speedTestProvider = SpeedTestProvider(); - UserDataProvider? _userDataProvider; bool _buttonEnabled = true; Timer? buttonTimer; static const int SPEED_TEST_TIMEOUT_CONST = 30; @@ -502,7 +500,7 @@ class _WiFiCardState extends State with AutomaticKeepAliveClientMixin child: Text( "Connect to a UCSD Network", style: TextStyle( - fontSize: 25, + fontSize: 22, ), textAlign: TextAlign.center, ), @@ -511,7 +509,7 @@ class _WiFiCardState extends State with AutomaticKeepAliveClientMixin padding: EdgeInsets.all(4.0), elevation: 0.0, onPressed: () => tryAgain(), - minWidth: 350, + minWidth: 300, height: 40, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(5.0),