Added option to not show App webpage + wording tweak

This commit is contained in:
Imran Remtulla
2022-09-03 17:06:46 -04:00
parent c30c692d87
commit f63da4b538
3 changed files with 82 additions and 8 deletions

View File

@@ -1,6 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:obtainium/providers/apps_provider.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:webview_flutter/webview_flutter.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -17,6 +19,7 @@ class _AppPageState extends State<AppPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var appsProvider = context.watch<AppsProvider>(); var appsProvider = context.watch<AppsProvider>();
var settingsProvider = context.watch<SettingsProvider>();
AppInMemory? app = appsProvider.apps[widget.appId]; AppInMemory? app = appsProvider.apps[widget.appId];
if (app?.app.installedVersion != null) { if (app?.app.installedVersion != null) {
appsProvider.getUpdate(app!.app.id); appsProvider.getUpdate(app!.app.id);
@@ -25,10 +28,58 @@ class _AppPageState extends State<AppPage> {
appBar: AppBar( appBar: AppBar(
title: Text('${app?.app.author}/${app?.app.name}'), title: Text('${app?.app.author}/${app?.app.name}'),
), ),
body: WebView( body: settingsProvider.showAppWebpage
initialUrl: app?.app.url, ? WebView(
javascriptMode: JavascriptMode.unrestricted, 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( bottomSheet: Padding(
padding: EdgeInsets.fromLTRB( padding: EdgeInsets.fromLTRB(
0, 0, 0, MediaQuery.of(context).padding.bottom), 0, 0, 0, MediaQuery.of(context).padding.bottom),

View File

@@ -109,6 +109,20 @@ class _SettingsPageState extends State<SettingsPage> {
settingsProvider.updateInterval = value; 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( const SizedBox(
height: 32, height: 32,
), ),
@@ -127,7 +141,7 @@ class _SettingsPageState extends State<SettingsPage> {
); );
}); });
}, },
child: const Text('Export Apps')), child: const Text('Export App List')),
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
HapticFeedback.lightImpact(); HapticFeedback.lightImpact();
@@ -140,7 +154,7 @@ class _SettingsPageState extends State<SettingsPage> {
return AlertDialog( return AlertDialog(
scrollable: true, scrollable: true,
title: const Text('Import Apps'), title: const Text('Import App List'),
content: Column(children: [ content: Column(children: [
const Text( const Text(
'Copy the contents of the Obtainium export file and paste them into the field below:'), 'Copy the contents of the Obtainium export file and paste them into the field below:'),
@@ -193,7 +207,7 @@ class _SettingsPageState extends State<SettingsPage> {
.showSnackBar( .showSnackBar(
SnackBar( SnackBar(
content: Text( content: Text(
'$value Apps Imported')), '$value App${value == 1 ? '' : 's'} Imported')),
); );
}).catchError((e) { }).catchError((e) {
ScaffoldMessenger.of(context) ScaffoldMessenger.of(context)
@@ -212,7 +226,7 @@ class _SettingsPageState extends State<SettingsPage> {
); );
}); });
}, },
child: const Text('Import Apps')) child: const Text('Import App List'))
], ],
), ),
const Spacer(), const Spacer(),

View File

@@ -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();
}
} }