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/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<AppPage> {
@override
Widget build(BuildContext context) {
var appsProvider = context.watch<AppsProvider>();
var settingsProvider = context.watch<SettingsProvider>();
AppInMemory? app = appsProvider.apps[widget.appId];
if (app?.app.installedVersion != null) {
appsProvider.getUpdate(app!.app.id);
@@ -25,10 +28,58 @@ class _AppPageState extends State<AppPage> {
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),

View File

@@ -109,6 +109,20 @@ class _SettingsPageState extends State<SettingsPage> {
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<SettingsPage> {
);
});
},
child: const Text('Export Apps')),
child: const Text('Export App List')),
ElevatedButton(
onPressed: () {
HapticFeedback.lightImpact();
@@ -140,7 +154,7 @@ class _SettingsPageState extends State<SettingsPage> {
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<SettingsPage> {
.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<SettingsPage> {
);
});
},
child: const Text('Import Apps'))
child: const Text('Import App List'))
],
),
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();
}
}