mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-24 18:38:48 +01:00
Refactoring: extract dialog scaffold
This commit is contained in:
parent
bc3c06cd51
commit
a20becfec5
2 changed files with 51 additions and 27 deletions
37
lib/widget/dialog_scaffold.dart
Normal file
37
lib/widget/dialog_scaffold.dart
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
/// A Scaffold that can be used with dialogs
|
||||||
|
///
|
||||||
|
/// Scaffold is needed for [SnackBar] to show correctly on top of a dialog
|
||||||
|
class DialogScaffold extends StatelessWidget {
|
||||||
|
const DialogScaffold({
|
||||||
|
Key? key,
|
||||||
|
required this.body,
|
||||||
|
this.canPop = true,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
build(BuildContext context) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
if (canPop) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: WillPopScope(
|
||||||
|
onWillPop: () => Future.value(canPop),
|
||||||
|
child: Scaffold(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
body: GestureDetector(
|
||||||
|
onTap: () {},
|
||||||
|
child: body,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Widget body;
|
||||||
|
final bool canPop;
|
||||||
|
}
|
|
@ -23,6 +23,7 @@ import 'package:nc_photos/theme.dart';
|
||||||
import 'package:nc_photos/use_case/share_album_with_user.dart';
|
import 'package:nc_photos/use_case/share_album_with_user.dart';
|
||||||
import 'package:nc_photos/use_case/unshare_album_with_user.dart';
|
import 'package:nc_photos/use_case/unshare_album_with_user.dart';
|
||||||
import 'package:nc_photos/widget/album_share_outlier_browser.dart';
|
import 'package:nc_photos/widget/album_share_outlier_browser.dart';
|
||||||
|
import 'package:nc_photos/widget/dialog_scaffold.dart';
|
||||||
|
|
||||||
class ShareAlbumDialog extends StatefulWidget {
|
class ShareAlbumDialog extends StatefulWidget {
|
||||||
ShareAlbumDialog({
|
ShareAlbumDialog({
|
||||||
|
@ -54,18 +55,9 @@ class _ShareAlbumDialogState extends State<ShareAlbumDialog> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
build(BuildContext context) {
|
build(BuildContext context) {
|
||||||
final canPop = _processingSharee.isEmpty;
|
|
||||||
return AppTheme(
|
return AppTheme(
|
||||||
child: GestureDetector(
|
child: DialogScaffold(
|
||||||
onTap: () {
|
canPop: _processingSharee.isEmpty,
|
||||||
if (canPop) {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: WillPopScope(
|
|
||||||
onWillPop: () => Future.value(canPop),
|
|
||||||
child: Scaffold(
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
body: BlocListener<ListShareeBloc, ListShareeBlocState>(
|
body: BlocListener<ListShareeBloc, ListShareeBlocState>(
|
||||||
bloc: _shareeBloc,
|
bloc: _shareeBloc,
|
||||||
listener: _onShareeStateChange,
|
listener: _onShareeStateChange,
|
||||||
|
@ -74,21 +66,16 @@ class _ShareAlbumDialogState extends State<ShareAlbumDialog> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildContent(BuildContext context) {
|
Widget _buildContent(BuildContext context) {
|
||||||
return GestureDetector(
|
return SimpleDialog(
|
||||||
onTap: () {},
|
|
||||||
child: SimpleDialog(
|
|
||||||
title: Text(L10n.global().shareAlbumDialogTitle),
|
title: Text(L10n.global().shareAlbumDialogTitle),
|
||||||
children: [
|
children: [
|
||||||
..._items.map((i) => _buildItem(context, i)),
|
..._items.map((i) => _buildItem(context, i)),
|
||||||
_buildCreateShareItem(context),
|
_buildCreateShareItem(context),
|
||||||
],
|
],
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue