Skip to content

Commit 522fc07

Browse files
committed
(#111) Minor bug fixes on /example project
1 parent eed796e commit 522fc07

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

example/lib/screens/file_explorer/file_explorer_card.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class _FileExplorerCardState extends State<FileExplorerCard> {
113113
}
114114

115115
Widget _buildMimeTypeIconThumbnail(String mimeType, {double? size}) {
116-
if (mimeType == kDirectoryMime) {
116+
if (_isDirectory) {
117117
return Icon(Icons.folder, size: size, color: Colors.blueGrey);
118118
}
119119

example/lib/screens/granted_uris/granted_uri_card.dart

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,21 @@ class _GrantedUriCardState extends State<GrantedUriCard> {
6767
),
6868
),
6969
ActionButton(
70-
'Open tree here',
70+
'Open file picker here',
7171
onTap: () => openDocumentTree(initialUri: widget.permissionUri.uri),
7272
)
7373
];
7474
}
7575

76+
@override
77+
void didUpdateWidget(covariant GrantedUriCard oldWidget) {
78+
super.didUpdateWidget(oldWidget);
79+
80+
documentFile = null;
81+
loading = false;
82+
error = null;
83+
}
84+
7685
DocumentFile? documentFile;
7786
bool loading = false;
7887
String? error;
@@ -97,11 +106,17 @@ class _GrantedUriCardState extends State<GrantedUriCard> {
97106
}
98107
}
99108

109+
VoidCallback get _onTapHandler => widget.permissionUri.isTreeDocumentFile
110+
? _openListFilesPage
111+
: _showDocumentFileContents;
112+
100113
List<Widget> _getDocumentAvailableOptions() {
101114
return [
102115
ActionButton(
103-
'Open document',
104-
onTap: _showDocumentFileContents,
116+
widget.permissionUri.isTreeDocumentFile
117+
? 'Open folder'
118+
: 'Open document',
119+
onTap: _onTapHandler,
105120
),
106121
ActionButton(
107122
'Load extra document data linked to this permission',
@@ -114,9 +129,8 @@ class _GrantedUriCardState extends State<GrantedUriCard> {
114129
return Wrap(
115130
children: [
116131
if (widget.permissionUri.isTreeDocumentFile)
117-
..._getTreeAvailableOptions()
118-
else
119-
..._getDocumentAvailableOptions(),
132+
..._getTreeAvailableOptions(),
133+
..._getDocumentAvailableOptions(),
120134
Padding(padding: k2dp.all),
121135
DangerButton(
122136
'Revoke',
@@ -143,9 +157,7 @@ class _GrantedUriCardState extends State<GrantedUriCard> {
143157
@override
144158
Widget build(BuildContext context) {
145159
return SimpleCard(
146-
onTap: widget.permissionUri.isTreeDocumentFile
147-
? _openListFilesPage
148-
: _showDocumentFileContents,
160+
onTap: _onTapHandler,
149161
children: [
150162
Padding(
151163
padding: k2dp.all.copyWith(top: k8dp, bottom: k8dp),

example/lib/screens/granted_uris/granted_uris_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class _GrantedUrisPageState extends State<GrantedUrisPage> {
6666
return Padding(
6767
padding: k8dp.all,
6868
child: const Center(
69-
child: LightText('No folders allowed yet'),
69+
child: LightText('No folders or files allowed yet'),
7070
),
7171
);
7272
}

0 commit comments

Comments
 (0)