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/unshare_album_with_user.dart';
|
||||
import 'package:nc_photos/widget/album_share_outlier_browser.dart';
|
||||
import 'package:nc_photos/widget/dialog_scaffold.dart';
|
||||
|
||||
class ShareAlbumDialog extends StatefulWidget {
|
||||
ShareAlbumDialog({
|
||||
|
@ -54,18 +55,9 @@ class _ShareAlbumDialogState extends State<ShareAlbumDialog> {
|
|||
|
||||
@override
|
||||
build(BuildContext context) {
|
||||
final canPop = _processingSharee.isEmpty;
|
||||
return AppTheme(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (canPop) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
child: WillPopScope(
|
||||
onWillPop: () => Future.value(canPop),
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
child: DialogScaffold(
|
||||
canPop: _processingSharee.isEmpty,
|
||||
body: BlocListener<ListShareeBloc, ListShareeBlocState>(
|
||||
bloc: _shareeBloc,
|
||||
listener: _onShareeStateChange,
|
||||
|
@ -74,21 +66,16 @@ class _ShareAlbumDialogState extends State<ShareAlbumDialog> {
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContent(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {},
|
||||
child: SimpleDialog(
|
||||
return SimpleDialog(
|
||||
title: Text(L10n.global().shareAlbumDialogTitle),
|
||||
children: [
|
||||
..._items.map((i) => _buildItem(context, i)),
|
||||
_buildCreateShareItem(context),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue