update onboarding; add missing safe areas
This commit is contained in:
@@ -18,11 +18,14 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mozilla_components/flutter_mozilla_components.dart'
|
||||
show GeckoBrowserService;
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:skeletonizer/skeletonizer.dart';
|
||||
import 'package:weblibre/features/onboarding/presentation/pages/abstract/i_form_page.dart';
|
||||
import 'package:weblibre/presentation/hooks/cached_future.dart';
|
||||
import 'package:weblibre/presentation/widgets/browser_page.dart';
|
||||
|
||||
class PermissionsPage extends HookConsumerWidget implements IFormPage {
|
||||
@override
|
||||
@@ -38,44 +41,79 @@ class PermissionsPage extends HookConsumerWidget implements IFormPage {
|
||||
() => Permission.notification.isGranted,
|
||||
);
|
||||
|
||||
return Form(
|
||||
key: formKey,
|
||||
child: ListView(
|
||||
children: [
|
||||
const SizedBox(height: 24),
|
||||
Center(
|
||||
child: Text('Permissions', style: theme.textTheme.headlineMedium),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
// child: const Text('WebLibre requires following permissions'),
|
||||
// ),
|
||||
// const SizedBox(height: 24),
|
||||
Skeletonizer(
|
||||
enabled: !notificationPermissionEnabled.hasData,
|
||||
child: FormField(
|
||||
initialValue: true,
|
||||
onSaved: (newValue) async {
|
||||
if (newValue == true) {
|
||||
await Permission.notification.request();
|
||||
}
|
||||
},
|
||||
builder: (field) => SwitchListTile(
|
||||
value: field.value ?? true,
|
||||
title: const Text('Notifications'),
|
||||
subtitle: const Text(
|
||||
'Required to inform about download status',
|
||||
final isDefaultBrowser = useCachedFuture(
|
||||
() => GeckoBrowserService().isDefaultBrowser(),
|
||||
);
|
||||
|
||||
final isCurrentDefaultBrowser = isDefaultBrowser.data == true;
|
||||
|
||||
return BrowserPage(
|
||||
child: BrowserPageContent(
|
||||
child: Form(
|
||||
key: formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 24),
|
||||
Center(
|
||||
child: Text(
|
||||
'Permissions',
|
||||
style: theme.textTheme.headlineMedium,
|
||||
),
|
||||
onChanged: (notificationPermissionEnabled.data == true)
|
||||
? null
|
||||
: (value) {
|
||||
field.didChange(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Skeletonizer(
|
||||
enabled: !notificationPermissionEnabled.hasData,
|
||||
child: FormField(
|
||||
initialValue: true,
|
||||
onSaved: (newValue) async {
|
||||
if (newValue == true &&
|
||||
notificationPermissionEnabled.data != true) {
|
||||
await Permission.notification.request();
|
||||
}
|
||||
},
|
||||
builder: (field) => SwitchListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
value: field.value ?? true,
|
||||
title: const Text('Notifications'),
|
||||
subtitle: const Text(
|
||||
'Required to inform about download status',
|
||||
),
|
||||
onChanged: (notificationPermissionEnabled.data == true)
|
||||
? null
|
||||
: (value) {
|
||||
field.didChange(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Skeletonizer(
|
||||
enabled: !isDefaultBrowser.hasData,
|
||||
child: FormField(
|
||||
key: ValueKey(isDefaultBrowser.data),
|
||||
initialValue: isCurrentDefaultBrowser,
|
||||
onSaved: (newValue) async {
|
||||
if (newValue == true && isDefaultBrowser.data == false) {
|
||||
await GeckoBrowserService().requestDefaultBrowser();
|
||||
}
|
||||
},
|
||||
builder: (field) => SwitchListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
value: field.value ?? isCurrentDefaultBrowser,
|
||||
title: const Text('Default Browser'),
|
||||
subtitle: const Text(
|
||||
'Set WebLibre as your default browser',
|
||||
),
|
||||
onChanged: isCurrentDefaultBrowser
|
||||
? null
|
||||
: (value) {
|
||||
field.didChange(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user