From 02bce8318af08a342c77ecffd139f74edfa6c649 Mon Sep 17 00:00:00 2001 From: drake Date: Wed, 26 Jun 2024 16:01:37 -0500 Subject: [PATCH] more fixes 2 --- fbla_ui/lib/main.dart | 20 ++++++++--- fbla_ui/lib/pages/business_detail.dart | 40 ++++++++++++++++++---- fbla_ui/lib/pages/create_edit_listing.dart | 9 ++--- 3 files changed, 54 insertions(+), 15 deletions(-) diff --git a/fbla_ui/lib/main.dart b/fbla_ui/lib/main.dart index e3b06ea..945a69c 100644 --- a/fbla_ui/lib/main.dart +++ b/fbla_ui/lib/main.dart @@ -86,7 +86,13 @@ class _MainAppState extends State { filled: true, fillColor: Colors.grey.withOpacity(0.1), labelStyle: const TextStyle(color: Colors.grey), - floatingLabelStyle: TextStyle(color: Colors.blue.shade700), + floatingLabelStyle: WidgetStateTextStyle.resolveWith((states) { + if (states.contains(WidgetState.focused) && + !states.contains(WidgetState.hovered)) { + return TextStyle(color: Colors.blue.shade700); + } + return const TextStyle(color: Colors.grey); + }), ), dropdownMenuTheme: const DropdownMenuThemeData( inputDecorationTheme: InputDecorationTheme( @@ -110,9 +116,15 @@ class _MainAppState extends State { inputDecorationTheme: InputDecorationTheme( // border: OutlineInputBorder(), filled: true, - fillColor: Colors.blue.withOpacity(0.1), - labelStyle: const TextStyle(color: Colors.grey), - floatingLabelStyle: TextStyle(color: Colors.blue.shade700), + fillColor: Colors.grey.withOpacity(0.25), + labelStyle: TextStyle(color: Colors.grey.shade700), + floatingLabelStyle: WidgetStateTextStyle.resolveWith((states) { + if (states.contains(WidgetState.focused) && + !states.contains(WidgetState.hovered)) { + return TextStyle(color: Colors.blue.shade700); + } + return TextStyle(color: Colors.grey.shade700); + }), ), dropdownMenuTheme: const DropdownMenuThemeData( inputDecorationTheme: InputDecorationTheme( diff --git a/fbla_ui/lib/pages/business_detail.dart b/fbla_ui/lib/pages/business_detail.dart index 0fe6214..45db76e 100644 --- a/fbla_ui/lib/pages/business_detail.dart +++ b/fbla_ui/lib/pages/business_detail.dart @@ -175,7 +175,7 @@ class _CreateBusinessDetailState extends State { ), ), // Available positions - if (business.listings != null) + if (business.listings != null || loggedIn) Card( clipBehavior: Clip.antiAlias, child: Column( @@ -184,7 +184,32 @@ class _CreateBusinessDetailState extends State { Padding( padding: const EdgeInsets.only(left: 16, top: 4), child: _GetListingsTitle(business)), - _JobList(business: business) + if (business.listings != null) + _JobList(business: business) + else + Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Padding( + padding: EdgeInsets.only(left: 16.0), + child: Text('No job listings exist.'), + ), + TextButton( + child: const Text('add one?'), + onPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => + CreateEditJobListing( + inputBusiness: business, + ))); + }, + ) + ], + ), + ) ]), ), // Contact info @@ -210,7 +235,6 @@ class _CreateBusinessDetailState extends State { ListTile( leading: const Icon(Icons.phone), title: Text(business.contactPhone!), - // maybe replace ! with ?? ''. same is true for below onTap: () { showDialog( context: context, @@ -421,14 +445,16 @@ class _GetListingsTitle extends StatelessWidget { @override Widget build(BuildContext context) { if (!loggedIn) { - return const Text('Available Postitions', - style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)); + return Text( + 'Available Postitions (${fromBusiness.listings?.length ?? '0'})', + style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold)); } else { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const Text('Available Postitions', - style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)), + Text('Available Postitions (${fromBusiness.listings?.length ?? '0'})', + style: + const TextStyle(fontSize: 20, fontWeight: FontWeight.bold)), Padding( padding: const EdgeInsets.only(right: 24.0), child: IconButton( diff --git a/fbla_ui/lib/pages/create_edit_listing.dart b/fbla_ui/lib/pages/create_edit_listing.dart index d1ca11b..a8eb16f 100644 --- a/fbla_ui/lib/pages/create_edit_listing.dart +++ b/fbla_ui/lib/pages/create_edit_listing.dart @@ -216,7 +216,7 @@ class _CreateEditJobListingState extends State { padding: const EdgeInsets.only( left: 8.0, right: 8.0, - bottom: 16.0, + bottom: 8.0, top: 8.0), child: DropdownMenu( menuHeight: 300, @@ -265,7 +265,7 @@ class _CreateEditJobListingState extends State { padding: const EdgeInsets.only( left: 8.0, right: 8.0, - bottom: 8.0, + bottom: 16.0, top: 8.0), child: DropdownMenu( initialSelection: @@ -338,7 +338,7 @@ class _CreateEditJobListingState extends State { bottom: 8.0), child: TextFormField( controller: _nameController, - maxLength: 30, + maxLength: 40, onChanged: (inputName) { setState(() { listing.name = inputName; @@ -432,8 +432,9 @@ class _CreateEditJobListingState extends State { listing.link = 'https://${listing.link}'; } + } else { + listing.link = null; } - listing.link = null; }, validator: (value) { if (value != null &&