Merge pull request #1214 from GetStream/hotfix/filePicker

fix(ui): request permission only when showing the picker
This commit is contained in:
Salvatore Giordano
2022-06-20 11:51:50 +02:00
committed by GitHub
2 changed files with 20 additions and 18 deletions
@@ -9,6 +9,7 @@
- [[#996]](https://github.com/GetStream/stream-chat-flutter/issues/996) Videos break bottom photo - [[#996]](https://github.com/GetStream/stream-chat-flutter/issues/996) Videos break bottom photo
carousal. carousal.
- Fix: URLs with path and/or query params are not enriched. - Fix: URLs with path and/or query params are not enriched.
- [[#1194]](https://github.com/GetStream/stream-chat-flutter/issues/1194) Request permission to access gallery when opening the file picker.
✅ Added ✅ Added
@@ -282,25 +282,26 @@ class _StreamAttachmentPickerState extends State<StreamAttachmentPicker> {
.iconBuilder(context, _filePickerIndex == i + 1), .iconBuilder(context, _filePickerIndex == i + 1),
), ),
const Spacer(), const Spacer(),
FutureBuilder( if (widget.isOpen)
future: PhotoManager.requestPermissionExtend(), FutureBuilder(
builder: (context, snapshot) { future: PhotoManager.requestPermissionExtend(),
if (snapshot.hasData && builder: (context, snapshot) {
snapshot.data == PermissionState.limited) { if (snapshot.hasData &&
return TextButton( snapshot.data == PermissionState.limited) {
child: Text(context.translations.viewLibrary), return TextButton(
onPressed: () async { child: Text(context.translations.viewLibrary),
await PhotoManager.presentLimited(); onPressed: () async {
_mediaListViewController.updateMedia( await PhotoManager.presentLimited();
newValue: true, _mediaListViewController.updateMedia(
); newValue: true,
}, );
); },
} );
}
return const SizedBox.shrink(); return const SizedBox.shrink();
}, },
), ),
], ],
), ),
DecoratedBox( DecoratedBox(