mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-25 10:58:50 +01:00
Fix NPE pressing edit before album initialized
This commit is contained in:
parent
1c476be689
commit
7321c04dc1
3 changed files with 34 additions and 23 deletions
|
@ -97,6 +97,9 @@ class _AlbumViewerState extends State<AlbumViewer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
get canEdit => _album != null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
enterEditMode() {
|
enterEditMode() {
|
||||||
super.enterEditMode();
|
super.enterEditMode();
|
||||||
|
|
|
@ -56,31 +56,33 @@ mixin AlbumViewerMixin<T extends StatefulWidget>
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
...(actions ?? []),
|
...(actions ?? []),
|
||||||
PopupMenuButton<int>(
|
if (menuItemBuilder != null || canEdit)
|
||||||
tooltip: MaterialLocalizations.of(context).moreButtonTooltip,
|
PopupMenuButton<int>(
|
||||||
itemBuilder: (context) => [
|
tooltip: MaterialLocalizations.of(context).moreButtonTooltip,
|
||||||
PopupMenuItem(
|
itemBuilder: (context) => [
|
||||||
value: -1,
|
if (canEdit)
|
||||||
child: Text(L10n.of(context).editAlbumMenuLabel),
|
PopupMenuItem(
|
||||||
),
|
value: -1,
|
||||||
...(menuItemBuilder?.call(context) ?? []),
|
child: Text(L10n.of(context).editAlbumMenuLabel),
|
||||||
],
|
),
|
||||||
onSelected: (option) {
|
...(menuItemBuilder?.call(context) ?? []),
|
||||||
if (option >= 0) {
|
],
|
||||||
onSelectedMenuItem?.call(option);
|
onSelected: (option) {
|
||||||
} else {
|
if (option >= 0) {
|
||||||
switch (option) {
|
onSelectedMenuItem?.call(option);
|
||||||
case _menuValueEdit:
|
} else {
|
||||||
_onAppBarEditPressed(context, album);
|
switch (option) {
|
||||||
break;
|
case _menuValueEdit:
|
||||||
|
_onAppBarEditPressed(context, album);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
_log.shout("[buildNormalAppBar] Unknown value: $option");
|
_log.shout("[buildNormalAppBar] Unknown value: $option");
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -127,6 +129,9 @@ mixin AlbumViewerMixin<T extends StatefulWidget>
|
||||||
@protected
|
@protected
|
||||||
bool get isEditMode => _isEditMode;
|
bool get isEditMode => _isEditMode;
|
||||||
|
|
||||||
|
@protected
|
||||||
|
bool get canEdit => true;
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
@mustCallSuper
|
@mustCallSuper
|
||||||
void enterEditMode() {}
|
void enterEditMode() {}
|
||||||
|
|
|
@ -98,6 +98,9 @@ class _DynamicAlbumViewerState extends State<DynamicAlbumViewer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
get canEdit => _album != null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
enterEditMode() {
|
enterEditMode() {
|
||||||
super.enterEditMode();
|
super.enterEditMode();
|
||||||
|
|
Loading…
Reference in a new issue