From fd94dbf20d503453328daaf601590f056f3df256 Mon Sep 17 00:00:00 2001 From: drake Date: Wed, 26 Jun 2024 13:06:03 -0500 Subject: [PATCH] fixes --- fbla_ui/lib/home.dart | 77 --------------------- fbla_ui/lib/main.dart | 3 +- fbla_ui/lib/pages/businesses_overview.dart | 2 + fbla_ui/lib/pages/create_edit_business.dart | 24 ++----- fbla_ui/lib/pages/create_edit_listing.dart | 10 +-- fbla_ui/lib/pages/listing_detail.dart | 4 +- fbla_ui/lib/pages/listings_overview.dart | 10 +-- fbla_ui/lib/shared/api_logic.dart | 17 ----- 8 files changed, 23 insertions(+), 124 deletions(-) diff --git a/fbla_ui/lib/home.dart b/fbla_ui/lib/home.dart index 27f8f12..c6b0d38 100644 --- a/fbla_ui/lib/home.dart +++ b/fbla_ui/lib/home.dart @@ -99,8 +99,6 @@ class _HomeState extends State { Widget build(BuildContext context) { bool widescreen = MediaQuery.sizeOf(context).width >= widescreenWidth; return Scaffold( - // floatingActionButton: _getFAB(widescreen, scrollControllerBusinesses, - // scrollControllerJobs, currentPageIndex), bottomNavigationBar: _getNavigationBar(widescreen), body: RefreshIndicator( edgeOffset: 145, @@ -173,13 +171,6 @@ class _HomeState extends State { color: Theme.of(context).colorScheme.onSurface, ), label: 'Job Listings'), - // NavigationDestination( - // icon: const Icon(Icons.description_outlined), - // selectedIcon: Icon( - // Icons.description, - // color: Theme.of(context).colorScheme.onSurface, - // ), - // label: 'Export Data') ], ); } @@ -264,51 +255,11 @@ class _HomeState extends State { color: Theme.of(context).colorScheme.onSurface, ), label: const Text('Job Listings')), - // NavigationRailDestination( - // icon: const Icon(Icons.description_outlined), - // selectedIcon: Icon( - // Icons.description, - // color: Theme.of(context).colorScheme.onSurface, - // ), - // label: const Text('Export Data')) ], ), - // children.first ], ); - // } - // return children.first; } - -// Widget _contentPane() { -// return IndexedStack( -// index: currentPageIndex, -// children: [ -// BusinessesOverview( -// searchQuery: searchQuery, -// refreshBusinessDataOverviewFuture: -// refreshBusinessDataOverviewBusinessFuture, -// updateBusinessesCallback: _updateOverviewBusinessesBusinessCallback, -// themeCallback: widget.themeCallback, -// updateLoggedIn: _updateLoggedIn, -// ), -// JobsOverview( -// searchQuery: searchQuery, -// refreshJobDataOverviewFuture: refreshBusinessDataOverviewJobFuture, -// updateBusinessesCallback: _updateOverviewBusinessesJobsCallback, -// themeCallback: widget.themeCallback, updateLoggedIn: _updateLoggedIn), -// ExportData( -// searchQuery: searchQuery, -// refreshBusinessDataOverviewFuture: -// refreshBusinessDataOverviewBusinessFuture, -// updateBusinessesWithJobCallback: -// _updateOverviewBusinessesJobsCallback, -// themeCallback: widget.themeCallback, -// refreshJobDataOverviewFuture: refreshBusinessDataOverviewJobFuture, -// updateBusinessesCallback: _updateOverviewBusinessesBusinessCallback) -// ], -// ); -// } } class _ContentPane extends StatelessWidget { @@ -354,35 +305,7 @@ class _ContentPane extends StatelessWidget { themeCallback: themeCallback, updateLoggedIn: updateLoggedIn, ), - // ExportData( - // searchQuery: searchQuery, - // refreshBusinessDataOverviewFuture: - // refreshBusinessDataOverviewBusinessFuture, - // updateBusinessesWithJobCallback: - // updateOverviewBusinessesJobsCallback, - // themeCallback: themeCallback, - // refreshJobDataOverviewFuture: refreshBusinessDataOverviewJobFuture, - // updateBusinessesCallback: updateOverviewBusinessesBusinessCallback) ], ); } } - -// class FABAnimator extends FloatingActionButtonAnimator { -// @override -// Offset getOffset({Offset begin, Offset end, double progress}) { -// return end; -// } -// -// @override -// Animation getRotationAnimation({required Animation parent}) { -// return Tween(begin: 0.0, end: 1.0).animate(parent); -// throw UnimplementedError(); -// } -// -// @override -// Animation getScaleAnimation({required Animation parent}) { -// return Tween(begin: 0.0, end: 1.0).animate(parent); -// throw UnimplementedError(); -// } -// } diff --git a/fbla_ui/lib/main.dart b/fbla_ui/lib/main.dart index 8daadd0..e3b06ea 100644 --- a/fbla_ui/lib/main.dart +++ b/fbla_ui/lib/main.dart @@ -83,10 +83,10 @@ class _MainAppState extends State { iconTheme: const IconThemeData(color: Colors.white), useMaterial3: true, inputDecorationTheme: InputDecorationTheme( - // border: OutlineInputBorder(), filled: true, fillColor: Colors.grey.withOpacity(0.1), labelStyle: const TextStyle(color: Colors.grey), + floatingLabelStyle: TextStyle(color: Colors.blue.shade700), ), dropdownMenuTheme: const DropdownMenuThemeData( inputDecorationTheme: InputDecorationTheme( @@ -112,6 +112,7 @@ class _MainAppState extends State { filled: true, fillColor: Colors.blue.withOpacity(0.1), labelStyle: const TextStyle(color: Colors.grey), + floatingLabelStyle: TextStyle(color: Colors.blue.shade700), ), dropdownMenuTheme: const DropdownMenuThemeData( inputDecorationTheme: InputDecorationTheme( diff --git a/fbla_ui/lib/pages/businesses_overview.dart b/fbla_ui/lib/pages/businesses_overview.dart index bc0b4a6..e485930 100644 --- a/fbla_ui/lib/pages/businesses_overview.dart +++ b/fbla_ui/lib/pages/businesses_overview.dart @@ -450,6 +450,7 @@ class _BusinessHeaderState extends State<_BusinessHeader> { } } + /// A desktop widget that displays basic info about a business Widget _businessTile(Business business, BusinessType jobType) { return MouseRegion( cursor: SystemMouseCursors.click, @@ -573,6 +574,7 @@ class _BusinessHeaderState extends State<_BusinessHeader> { ); } + /// A mobile widget that displays basic info about a business Widget _businessListItem(Business business, BusinessType? jobType) { return Card( child: ListTile( diff --git a/fbla_ui/lib/pages/create_edit_business.dart b/fbla_ui/lib/pages/create_edit_business.dart index 553fba3..b6ec954 100644 --- a/fbla_ui/lib/pages/create_edit_business.dart +++ b/fbla_ui/lib/pages/create_edit_business.dart @@ -91,6 +91,7 @@ class _CreateEditBusinessState extends State { ), floatingActionButton: !widescreen ? FloatingActionButton.extended( + heroTag: 'saveBusiness', label: const Text('Save'), icon: _isLoading ? const SizedBox( @@ -171,8 +172,6 @@ class _CreateEditBusinessState extends State { right: 8.0), child: TextFormField( controller: _nameController, - autovalidateMode: - AutovalidateMode.onUserInteraction, maxLength: 30, onChanged: (inputName) { setState(() { @@ -198,8 +197,6 @@ class _CreateEditBusinessState extends State { bottom: 8.0, left: 8.0, right: 8.0), child: TextFormField( controller: _descriptionController, - autovalidateMode: - AutovalidateMode.onUserInteraction, maxLength: 500, maxLines: null, onChanged: (inputDesc) { @@ -227,8 +224,6 @@ class _CreateEditBusinessState extends State { left: 8.0, right: 8.0, bottom: 16.0), child: TextFormField( controller: _websiteController, - autovalidateMode: - AutovalidateMode.onUserInteraction, keyboardType: TextInputType.url, onChanged: (inputUrl) { business.website = Uri.encodeFull(inputUrl); @@ -267,7 +262,12 @@ class _CreateEditBusinessState extends State { left: 8.0, right: 8.0, bottom: 16.0), child: DropdownMenu( initialSelection: business.type, - // width: 776, + width: (MediaQuery.sizeOf(context).width - + 24) < + 776 + ? MediaQuery.sizeOf(context).width - 24 + : 776, + menuHeight: 300, label: const Text('Business Type'), errorText: dropDownErrorText, dropdownMenuEntries: [ @@ -375,8 +375,6 @@ class _CreateEditBusinessState extends State { labelText: 'Contact Information Name (required)', ), - autovalidateMode: - AutovalidateMode.onUserInteraction, validator: (value) { if (value == null || value.trim().isEmpty) { return 'Contact name is required'; @@ -392,8 +390,6 @@ class _CreateEditBusinessState extends State { controller: _contactPhoneController, inputFormatters: [PhoneFormatter()], keyboardType: TextInputType.phone, - autovalidateMode: - AutovalidateMode.onUserInteraction, onChanged: (inputText) { if (inputText.trim().isEmpty) { business.contactPhone = null; @@ -432,8 +428,6 @@ class _CreateEditBusinessState extends State { business.contactEmail = inputText.trim(); } }, - autovalidateMode: - AutovalidateMode.onUserInteraction, onTapOutside: (PointerDownEvent event) { FocusScope.of(context).unfocus(); }, @@ -472,8 +466,6 @@ class _CreateEditBusinessState extends State { business.locationName = inputName.trim(); }); }, - autovalidateMode: - AutovalidateMode.onUserInteraction, onTapOutside: (PointerDownEvent event) { FocusScope.of(context).unfocus(); }, @@ -498,8 +490,6 @@ class _CreateEditBusinessState extends State { business.locationAddress = inputAddr; }); }, - autovalidateMode: - AutovalidateMode.onUserInteraction, onTapOutside: (PointerDownEvent event) { FocusScope.of(context).unfocus(); }, diff --git a/fbla_ui/lib/pages/create_edit_listing.dart b/fbla_ui/lib/pages/create_edit_listing.dart index a19a4c9..141e9c9 100644 --- a/fbla_ui/lib/pages/create_edit_listing.dart +++ b/fbla_ui/lib/pages/create_edit_listing.dart @@ -83,6 +83,7 @@ class _CreateEditJobListingState extends State { ), floatingActionButton: !widescreen ? FloatingActionButton.extended( + heroTag: 'saveListing', label: const Text('Save'), icon: _isLoading ? const SizedBox( @@ -227,6 +228,7 @@ class _CreateEditJobListingState extends State { typeDropdownErrorText, width: calculateDropdownWidth( context), + menuHeight: 300, dropdownMenuEntries: [ for (JobType type in JobType.values) @@ -336,8 +338,6 @@ class _CreateEditJobListingState extends State { bottom: 8.0), child: TextFormField( controller: _nameController, - autovalidateMode: AutovalidateMode - .onUserInteraction, maxLength: 30, onChanged: (inputName) { setState(() { @@ -368,8 +368,6 @@ class _CreateEditJobListingState extends State { bottom: 8.0), child: TextFormField( controller: _descriptionController, - autovalidateMode: AutovalidateMode - .onUserInteraction, maxLength: 500, maxLines: null, onChanged: (inputDesc) { @@ -422,8 +420,6 @@ class _CreateEditJobListingState extends State { bottom: 16.0), child: TextFormField( controller: _linkController, - autovalidateMode: AutovalidateMode - .onUserInteraction, keyboardType: TextInputType.url, onChanged: (inputUrl) { if (inputUrl != '') { @@ -475,7 +471,7 @@ class _CreateEditJobListingState extends State { mainAxisSize: MainAxisSize.min, children: [ Padding( - padding: EdgeInsets.only( + padding: const EdgeInsets.only( top: 8.0, right: 8.0, bottom: 8.0), diff --git a/fbla_ui/lib/pages/listing_detail.dart b/fbla_ui/lib/pages/listing_detail.dart index dcd4672..84b40eb 100644 --- a/fbla_ui/lib/pages/listing_detail.dart +++ b/fbla_ui/lib/pages/listing_detail.dart @@ -258,7 +258,9 @@ class _CreateBusinessDetailState extends State { Navigator.pushReplacement( context, MaterialPageRoute( - builder: (context) => const MainApp())); + builder: (context) => const MainApp( + initialPage: 1, + ))); } }), ], diff --git a/fbla_ui/lib/pages/listings_overview.dart b/fbla_ui/lib/pages/listings_overview.dart index b216cff..e254a97 100644 --- a/fbla_ui/lib/pages/listings_overview.dart +++ b/fbla_ui/lib/pages/listings_overview.dart @@ -491,7 +491,7 @@ class _JobHeaderState extends State<_JobHeader> { delegate: SliverChildBuilderDelegate( childCount: businesses.length, (BuildContext context, int index) { - return _businessTile( + return _jobBusinessTile( businesses[index], widget.jobType, ); @@ -504,7 +504,7 @@ class _JobHeaderState extends State<_JobHeader> { delegate: SliverChildBuilderDelegate( childCount: businesses.length, (BuildContext context, int index) { - return _businessListItem( + return _jobBusinessListItem( businesses[index], widget.jobType, ); @@ -514,7 +514,8 @@ class _JobHeaderState extends State<_JobHeader> { } } - Widget _businessTile(Business business, JobType jobType) { + /// A desktop widget that displays basic info about a job + Widget _jobBusinessTile(Business business, JobType jobType) { return MouseRegion( cursor: SystemMouseCursors.click, child: GestureDetector( @@ -653,7 +654,8 @@ class _JobHeaderState extends State<_JobHeader> { ); } - Widget _businessListItem(Business business, JobType? jobType) { + /// A mobile widget that displays basic info about a job + Widget _jobBusinessListItem(Business business, JobType? jobType) { return Card( child: ListTile( leading: Badge( diff --git a/fbla_ui/lib/shared/api_logic.dart b/fbla_ui/lib/shared/api_logic.dart index a692b95..a598e0b 100644 --- a/fbla_ui/lib/shared/api_logic.dart +++ b/fbla_ui/lib/shared/api_logic.dart @@ -87,20 +87,6 @@ Future fetchBusinessDataOverviewJobs( } return groupedBusinesses; - // Map> groupedBusinesses = {}; - // - // for (String stringType in decodedResponse.keys) { - // List businesses = []; - // - // for (Map map in decodedResponse[stringType]) { - // Business business = Business.fromJson(map); - // businesses.add(business); - // } - // - // groupedBusinesses - // .addAll({JobType.values.byName(stringType): businesses}); - // } - // return groupedBusinesses; } else { return 'Error ${response.statusCode}! Please try again later!'; } @@ -394,9 +380,6 @@ Future marinoDevLogo() async { Uri.parse('$apiAddress/marinodev'), ); - // File logo = File ('${getTemporaryDirectory().toString()}/marinodev.svg'); - // logo.writeAsBytes(response.bodyBytes); - return response.bodyBytes; }