ente/lib/ui/grant_permissions_widget.dart

92 lines
2.9 KiB
Dart
Raw Normal View History

2021-03-12 08:40:36 +00:00
import 'package:flutter/material.dart';
import 'package:photo_manager/photo_manager.dart';
import 'package:photos/services/sync_service.dart';
2021-05-12 15:23:22 +00:00
import 'package:photos/ui/common_elements.dart';
import 'package:photos/utils/toast_util.dart';
2021-05-09 18:44:05 +00:00
2021-05-29 17:01:59 +00:00
class GrantPermissionsWidget extends StatelessWidget {
2021-03-12 08:40:36 +00:00
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
2021-05-23 14:15:59 +00:00
Image.asset(
"assets/gallery.png",
height: 160,
),
Padding(padding: EdgeInsets.all(24)),
2021-05-12 15:23:22 +00:00
Text.rich(
TextSpan(
children: <TextSpan>[
TextSpan(
text: "ente",
style: TextStyle(
fontWeight: FontWeight.bold,
fontFamily: 'Montserrat',
fontSize: 16,
),
),
TextSpan(
text: " needs your permission",
style: TextStyle(
fontSize: 16,
),
),
],
2021-03-12 08:40:36 +00:00
),
2021-05-12 15:23:22 +00:00
textAlign: TextAlign.center,
),
Padding(padding: EdgeInsets.all(2)),
Text(
"to access your gallery",
style: TextStyle(fontSize: 16),
2021-03-12 08:40:36 +00:00
),
2021-05-23 14:15:59 +00:00
Padding(padding: const EdgeInsets.all(24)),
2021-03-12 08:40:36 +00:00
Container(
width: double.infinity,
height: 64,
2021-05-13 21:36:38 +00:00
padding: const EdgeInsets.fromLTRB(64, 0, 64, 0),
2021-05-12 15:23:22 +00:00
child: button(
"grant permission",
fontSize: 16,
2021-03-12 08:40:36 +00:00
onPressed: () async {
final state = await PhotoManager.requestPermissionExtend();
if (state == PermissionState.authorized ||
state == PermissionState.limited) {
await SyncService.instance.onPermissionGranted(state);
} else if (state == PermissionState.denied) {
showToast("please grant permissions to access the gallery");
PhotoManager.openSetting();
2021-03-12 08:40:36 +00:00
}
},
2021-05-12 15:23:22 +00:00
),
),
Padding(padding: const EdgeInsets.all(50)),
Text(
"we value your privacy",
style: TextStyle(
color: Colors.white30,
),
),
Padding(padding: const EdgeInsets.all(12)),
Text(
2021-06-12 09:12:41 +00:00
"all the files you choose to back up",
2021-05-12 15:23:22 +00:00
style: TextStyle(
color: Colors.white30,
),
),
Padding(padding: const EdgeInsets.all(2)),
Text(
2021-06-12 09:12:41 +00:00
"will be end-to-end encrypted",
2021-05-12 15:23:22 +00:00
style: TextStyle(
color: Colors.white30,
2021-03-12 08:40:36 +00:00
),
),
],
),
);
}
}