Browse Source

made the 'grand permission' button a FAB and made the content above it scrollable

ashilkn 3 years ago
parent
commit
fe4dda1237
1 changed files with 107 additions and 104 deletions
  1. 107 104
      lib/ui/grant_permissions_widget.dart

+ 107 - 104
lib/ui/grant_permissions_widget.dart

@@ -12,120 +12,123 @@ class GrantPermissionsWidget extends StatelessWidget {
         MediaQuery.of(context).platformBrightness == Brightness.light;
     return Scaffold(
       body: SingleChildScrollView(
-        physics: NeverScrollableScrollPhysics(),
-        child: SizedBox(
-          height: MediaQuery.of(context).size.height,
-          child: Column(
-            crossAxisAlignment: CrossAxisAlignment.start,
-            mainAxisAlignment: MainAxisAlignment.spaceBetween,
-            children: [
-              Column(
-                children: [
-                  Center(
-                    child: Padding(
-                      padding: const EdgeInsets.fromLTRB(0, 100, 0, 50),
-                      child: Stack(
-                        alignment: Alignment.center,
-                        children: [
-                          isLightMode
-                              ? Image.asset(
-                                  'assets/loading_photos_light.png',
-                                  color: Colors.white.withOpacity(0.4),
-                                  colorBlendMode: BlendMode.modulate,
-                                )
-                              : Image.asset('assets/loading_photos_dark.png'),
-                          Center(
-                            child: Image.asset(
-                              "assets/gallery.png",
-                              height: 160,
-                            ),
+        child: Column(
+          crossAxisAlignment: CrossAxisAlignment.start,
+          mainAxisAlignment: MainAxisAlignment.spaceBetween,
+          children: [
+            Column(
+              children: [
+                Center(
+                  child: Padding(
+                    padding: const EdgeInsets.fromLTRB(0, 100, 0, 50),
+                    child: Stack(
+                      alignment: Alignment.center,
+                      children: [
+                        isLightMode
+                            ? Image.asset(
+                                'assets/loading_photos_light.png',
+                                color: Colors.white.withOpacity(0.4),
+                                colorBlendMode: BlendMode.modulate,
+                              )
+                            : Image.asset('assets/loading_photos_dark.png'),
+                        Center(
+                          child: Image.asset(
+                            "assets/gallery.png",
+                            height: 160,
                           ),
-                        ],
-                      ),
+                        ),
+                      ],
                     ),
                   ),
-                  Padding(
-                    padding: const EdgeInsets.symmetric(horizontal: 40),
-                    child: RichText(
-                      text: TextSpan(
-                        style: Theme.of(context)
-                            .textTheme
-                            .headline5
-                            .copyWith(fontWeight: FontWeight.w700),
-                        children: [
-                          TextSpan(text: 'ente '),
-                          TextSpan(
-                            text: "needs permission to ",
-                            style: Theme.of(context)
-                                .textTheme
-                                .headline5
-                                .copyWith(fontWeight: FontWeight.w400),
-                          ),
-                          TextSpan(text: 'preserve your photos')
-                        ],
-                      ),
+                ),
+                Padding(
+                  padding: const EdgeInsets.symmetric(horizontal: 40),
+                  child: RichText(
+                    text: TextSpan(
+                      style: Theme.of(context)
+                          .textTheme
+                          .headline5
+                          .copyWith(fontWeight: FontWeight.w700),
+                      children: [
+                        TextSpan(text: 'ente '),
+                        TextSpan(
+                          text: "needs permission to ",
+                          style: Theme.of(context)
+                              .textTheme
+                              .headline5
+                              .copyWith(fontWeight: FontWeight.w400),
+                        ),
+                        TextSpan(text: 'preserve your photos'),
+                      ],
                     ),
                   ),
-                ],
-              ),
-              Container(
-                width: double.infinity,
-                padding: EdgeInsets.only(
-                  left: 20,
-                  right: 20,
-                  bottom: Platform.isIOS ? 84 : 60,
                 ),
-                child: OutlinedButton(
-                  child: Text("Grant permission"),
-                  onPressed: () async {
-                    final state = await PhotoManager.requestPermissionExtend();
-                    if (state == PermissionState.authorized ||
-                        state == PermissionState.limited) {
-                      await SyncService.instance.onPermissionGranted(state);
-                    } else if (state == PermissionState.denied) {
-                      AlertDialog alert = AlertDialog(
-                        title: Text("Please grant permissions"),
-                        content: Text(
-                          "ente can encrypt and preserve files only if you grant access to them",
-                        ),
-                        actions: [
-                          TextButton(
-                            child: Text(
-                              "OK",
-                              style: Theme.of(context)
-                                  .textTheme
-                                  .subtitle1
-                                  .copyWith(
-                                    fontSize: 14,
-                                    fontWeight: FontWeight.w700,
-                                  ),
-                            ),
-                            onPressed: () {
-                              Navigator.of(context, rootNavigator: true)
-                                  .pop('dialog');
-                              if (Platform.isIOS) {
-                                PhotoManager.openSetting();
-                              }
-                            },
+              ],
+            ),
+          ],
+        ),
+      ),
+      floatingActionButton: Container(
+        decoration: BoxDecoration(
+          boxShadow: [
+            BoxShadow(
+              color: Theme.of(context).backgroundColor,
+              spreadRadius: 200,
+              blurRadius: 100,
+              offset: Offset(0, 160),
+            )
+          ],
+        ),
+        width: double.infinity,
+        padding: EdgeInsets.only(
+          left: 20,
+          right: 20,
+          bottom: Platform.isIOS ? 40 : 16,
+        ),
+        child: OutlinedButton(
+          child: Text("Grant permission"),
+          onPressed: () async {
+            final state = await PhotoManager.requestPermissionExtend();
+            if (state == PermissionState.authorized ||
+                state == PermissionState.limited) {
+              await SyncService.instance.onPermissionGranted(state);
+            } else if (state == PermissionState.denied) {
+              AlertDialog alert = AlertDialog(
+                title: Text("Please grant permissions"),
+                content: Text(
+                  "ente can encrypt and preserve files only if you grant access to them",
+                ),
+                actions: [
+                  TextButton(
+                    child: Text(
+                      "OK",
+                      style: Theme.of(context).textTheme.subtitle1.copyWith(
+                            fontSize: 14,
+                            fontWeight: FontWeight.w700,
                           ),
-                        ],
-                      );
+                    ),
+                    onPressed: () {
+                      Navigator.of(context, rootNavigator: true).pop('dialog');
+                      if (Platform.isIOS) {
+                        PhotoManager.openSetting();
+                      }
+                    },
+                  ),
+                ],
+              );
 
-                      showDialog(
-                        context: context,
-                        builder: (BuildContext context) {
-                          return alert;
-                        },
-                        barrierColor: Colors.black12,
-                      );
-                    }
-                  },
-                ),
-              ),
-            ],
-          ),
+              showDialog(
+                context: context,
+                builder: (BuildContext context) {
+                  return alert;
+                },
+                barrierColor: Colors.black12,
+              );
+            }
+          },
         ),
       ),
+      floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
     );
   }
 }