diff --git a/lib/pages/app.dart b/lib/pages/app.dart index 33dac64..78772cb 100644 --- a/lib/pages/app.dart +++ b/lib/pages/app.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:obtainium/providers/apps_provider.dart'; +import 'package:obtainium/providers/settings_provider.dart'; +import 'package:url_launcher/url_launcher_string.dart'; import 'package:webview_flutter/webview_flutter.dart'; import 'package:provider/provider.dart'; @@ -17,6 +19,7 @@ class _AppPageState extends State { @override Widget build(BuildContext context) { var appsProvider = context.watch(); + var settingsProvider = context.watch(); AppInMemory? app = appsProvider.apps[widget.appId]; if (app?.app.installedVersion != null) { appsProvider.getUpdate(app!.app.id); @@ -25,10 +28,58 @@ class _AppPageState extends State { appBar: AppBar( title: Text('${app?.app.author}/${app?.app.name}'), ), - body: WebView( - initialUrl: app?.app.url, - javascriptMode: JavascriptMode.unrestricted, - ), + body: settingsProvider.showAppWebpage + ? WebView( + initialUrl: app?.app.url, + javascriptMode: JavascriptMode.unrestricted, + ) + : Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + app?.app.name ?? 'App', + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.headline1, + ), + Text( + 'By ${app?.app.author ?? 'Unknown'}', + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.headline4, + ), + const SizedBox( + height: 32, + ), + GestureDetector( + onTap: () { + if (app?.app.url != null) { + launchUrlString(app?.app.url ?? '', + mode: LaunchMode.externalApplication); + } + }, + child: Text( + app?.app.url ?? '', + textAlign: TextAlign.center, + style: const TextStyle( + decoration: TextDecoration.underline, + fontStyle: FontStyle.italic, + fontSize: 12), + )), + const SizedBox( + height: 32, + ), + Text( + 'Latest Version: ${app?.app.latestVersion ?? 'Unknown'}', + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.bodyLarge, + ), + Text( + 'Installed Version: ${app?.app.installedVersion ?? 'None'}', + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.bodyLarge, + ), + ], + ), bottomSheet: Padding( padding: EdgeInsets.fromLTRB( 0, 0, 0, MediaQuery.of(context).padding.bottom), diff --git a/lib/pages/settings.dart b/lib/pages/settings.dart index 4bfbd72..c0bd204 100644 --- a/lib/pages/settings.dart +++ b/lib/pages/settings.dart @@ -109,6 +109,20 @@ class _SettingsPageState extends State { settingsProvider.updateInterval = value; } }), + const SizedBox( + height: 16, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text('Show Source Webpage in App View'), + Switch( + value: settingsProvider.showAppWebpage, + onChanged: (value) { + settingsProvider.showAppWebpage = value; + }) + ], + ), const SizedBox( height: 32, ), @@ -127,7 +141,7 @@ class _SettingsPageState extends State { ); }); }, - child: const Text('Export Apps')), + child: const Text('Export App List')), ElevatedButton( onPressed: () { HapticFeedback.lightImpact(); @@ -140,7 +154,7 @@ class _SettingsPageState extends State { return AlertDialog( scrollable: true, - title: const Text('Import Apps'), + title: const Text('Import App List'), content: Column(children: [ const Text( 'Copy the contents of the Obtainium export file and paste them into the field below:'), @@ -193,7 +207,7 @@ class _SettingsPageState extends State { .showSnackBar( SnackBar( content: Text( - '$value Apps Imported')), + '$value App${value == 1 ? '' : 's'} Imported')), ); }).catchError((e) { ScaffoldMessenger.of(context) @@ -212,7 +226,7 @@ class _SettingsPageState extends State { ); }); }, - child: const Text('Import Apps')) + child: const Text('Import App List')) ], ), const Spacer(), diff --git a/lib/providers/settings_provider.dart b/lib/providers/settings_provider.dart index ed78fc7..d52c67d 100644 --- a/lib/providers/settings_provider.dart +++ b/lib/providers/settings_provider.dart @@ -69,4 +69,13 @@ class SettingsProvider with ChangeNotifier { } } } + + bool get showAppWebpage { + return prefs?.getBool('showAppWebpage') ?? true; + } + + set showAppWebpage(bool show) { + prefs?.setBool('showAppWebpage', show); + notifyListeners(); + } }