From fe4dda12370e45d2cc375c20df9d76e75791880a Mon Sep 17 00:00:00 2001 From: ashilkn Date: Mon, 13 Jun 2022 20:43:29 +0530 Subject: [PATCH] made the 'grand permission' button a FAB and made the content above it scrollable --- lib/ui/grant_permissions_widget.dart | 221 ++++++++++++++------------- 1 file changed, 112 insertions(+), 109 deletions(-) diff --git a/lib/ui/grant_permissions_widget.dart b/lib/ui/grant_permissions_widget.dart index 45270c32d..5a288240c 100644 --- a/lib/ui/grant_permissions_widget.dart +++ b/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') - ], - ), - ), - ), - ], - ), - 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(); - } - }, - ), - ], - ); - - showDialog( - context: context, - builder: (BuildContext context) { - return alert; - }, - barrierColor: Colors.black12, - ); - } - }, + ], + ), + ), ), - ), - ], - ), + 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'), + ], + ), + ), + ), + ], + ), + ], ), ), + 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, + ); + } + }, + ), + ), + floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, ); } }