grant_permissions_widget.dart 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import 'package:flutter/material.dart';
  2. import 'package:logging/logging.dart';
  3. import 'package:photo_manager/photo_manager.dart';
  4. import 'package:photos/services/sync_service.dart';
  5. class GrantPermissionsWidget extends StatelessWidget {
  6. final _logger = Logger("GrantPermissionsWidget");
  7. @override
  8. Widget build(BuildContext context) {
  9. return Center(
  10. child: Column(
  11. mainAxisAlignment: MainAxisAlignment.center,
  12. crossAxisAlignment: CrossAxisAlignment.center,
  13. children: [
  14. Padding(
  15. padding: const EdgeInsets.all(32),
  16. child: Text(
  17. "ente needs your permission to display your gallery",
  18. textAlign: TextAlign.center,
  19. style: TextStyle(
  20. fontSize: 16,
  21. height: 1.4,
  22. ),
  23. ),
  24. ),
  25. Container(
  26. width: double.infinity,
  27. height: 64,
  28. padding: const EdgeInsets.fromLTRB(80, 0, 80, 0),
  29. child: RaisedButton(
  30. child: Text(
  31. "grant permission",
  32. style: TextStyle(
  33. fontWeight: FontWeight.bold,
  34. fontSize: 18,
  35. letterSpacing: 1.0,
  36. ),
  37. textAlign: TextAlign.center,
  38. ),
  39. onPressed: () async {
  40. final granted = await PhotoManager.requestPermission();
  41. if (granted) {
  42. SyncService.instance.onPermissionGranted();
  43. }
  44. },
  45. shape: RoundedRectangleBorder(
  46. borderRadius: BorderRadius.circular(10.0),
  47. ),
  48. ),
  49. ),
  50. ],
  51. ),
  52. );
  53. }
  54. }