From 4ab4f58f6544ff8cc3203fea02e5aa7cf0476e28 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Fri, 19 Jan 2024 20:35:44 -0500 Subject: [PATCH] Cleaner 'add app' page --- lib/pages/add_app.dart | 82 ++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 35 deletions(-) diff --git a/lib/pages/add_app.dart b/lib/pages/add_app.dart index d504901..c756d92 100644 --- a/lib/pages/add_app.dart +++ b/lib/pages/add_app.dart @@ -496,36 +496,59 @@ class AddAppPageState extends State { ], ); - Widget getSourcesListWidget() => Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, + Widget getSourcesListWidget() => Padding( + padding: const EdgeInsets.all(16), + child: Row( children: [ - Text( - tr('supportedSources'), - style: const TextStyle(fontWeight: FontWeight.bold), - ), - const SizedBox( - height: 16, - ), - ...sourceProvider.sources.map((e) => GestureDetector( - onTap: e.hosts.isNotEmpty - ? () { - launchUrlString('https://${e.hosts[0]}', - mode: LaunchMode.externalApplication); - } - : null, + GestureDetector( + onTap: () { + showDialog( + context: context, + builder: (context) { + return GeneratedFormModal( + title: tr('supportedSources'), + items: const [], + additionalWidgets: [ + ...sourceProvider.sources.map( + (e) => Padding( + padding: EdgeInsets.symmetric(vertical: 4), + child: GestureDetector( + onTap: e.hosts.isNotEmpty + ? () { + launchUrlString( + 'https://${e.hosts[0]}', + mode: LaunchMode + .externalApplication); + } + : null, + child: Text( + '${e.name}${e.enforceTrackOnly ? ' ${tr('trackOnlyInBrackets')}' : ''}${e.canSearch ? ' ${tr('searchableInBrackets')}' : ''}', + style: TextStyle( + decoration: e.hosts.isNotEmpty + ? TextDecoration.underline + : TextDecoration.none), + ))), + ) + ], + ); + }, + ); + }, child: Text( - '${e.name}${e.enforceTrackOnly ? ' ${tr('trackOnlyInBrackets')}' : ''}${e.canSearch ? ' ${tr('searchableInBrackets')}' : ''}', - style: TextStyle( - decoration: e.hosts.isNotEmpty - ? TextDecoration.underline - : TextDecoration.none, + tr('supportedSources'), + style: const TextStyle( + fontWeight: FontWeight.bold, + decoration: TextDecoration.underline, fontStyle: FontStyle.italic), - ))) - ]); + )) + ], + ), + ); return Scaffold( backgroundColor: Theme.of(context).colorScheme.surface, + bottomNavigationBar: + pickedSource == null ? getSourcesListWidget() : null, body: CustomScrollView(shrinkWrap: true, slivers: [ CustomAppBar(title: tr('addApp')), SliverToBoxAdapter( @@ -557,18 +580,7 @@ class AddAppPageState extends State { : const SizedBox(); }, future: pickedSource?.getSourceNote()), - SizedBox( - height: pickedSource != null ? 16 : 96, - ), if (pickedSource != null) getAdditionalOptsCol(), - if (pickedSource == null) - const Divider( - height: 48, - ), - if (pickedSource == null) getSourcesListWidget(), - SizedBox( - height: pickedSource != null ? 8 : 2, - ), ])), ) ]));