create folder modern dialog

This commit is contained in:
NicKoehler 2023-02-27 09:44:52 +01:00
parent 459bed1a68
commit c18c6d72bd
No known key found for this signature in database
GPG Key ID: BAE01394EB51AC58
2 changed files with 119 additions and 48 deletions

View File

@ -168,6 +168,22 @@ class MyTheme {
brightness: Brightness.light, brightness: Brightness.light,
hoverColor: Color.fromARGB(255, 224, 224, 224), hoverColor: Color.fromARGB(255, 224, 224, 224),
scaffoldBackgroundColor: Color(0xFFFFFFFF), scaffoldBackgroundColor: Color(0xFFFFFFFF),
dialogBackgroundColor: Color(0xFFFFFFFF),
dialogTheme: DialogTheme(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
),
inputDecorationTheme: InputDecorationTheme(
fillColor: Color(0xFFEEEEEE),
filled: true,
isDense: true,
contentPadding: EdgeInsets.all(15),
border: UnderlineInputBorder(
borderRadius: BorderRadius.circular(18),
borderSide: BorderSide.none,
),
),
textTheme: const TextTheme( textTheme: const TextTheme(
titleLarge: TextStyle(fontSize: 19, color: Colors.black87), titleLarge: TextStyle(fontSize: 19, color: Colors.black87),
titleSmall: TextStyle(fontSize: 14, color: Colors.black87), titleSmall: TextStyle(fontSize: 14, color: Colors.black87),
@ -205,6 +221,22 @@ class MyTheme {
brightness: Brightness.dark, brightness: Brightness.dark,
hoverColor: Color.fromARGB(255, 45, 46, 53), hoverColor: Color.fromARGB(255, 45, 46, 53),
scaffoldBackgroundColor: Color(0xFF18191E), scaffoldBackgroundColor: Color(0xFF18191E),
dialogBackgroundColor: Color(0xFF18191E),
dialogTheme: DialogTheme(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
),
inputDecorationTheme: InputDecorationTheme(
fillColor: Color(0xFF24252B),
filled: true,
isDense: true,
contentPadding: EdgeInsets.all(15),
border: UnderlineInputBorder(
borderRadius: BorderRadius.circular(18),
borderSide: BorderSide.none,
),
),
textTheme: const TextTheme( textTheme: const TextTheme(
titleLarge: TextStyle(fontSize: 19), titleLarge: TextStyle(fontSize: 19),
titleSmall: TextStyle(fontSize: 14), titleSmall: TextStyle(fontSize: 14),
@ -681,18 +713,19 @@ class CustomAlertDialog extends StatelessWidget {
scrollable: true, scrollable: true,
title: title, title: title,
titlePadding: EdgeInsets.fromLTRB(padding, 24, padding, 0), titlePadding: EdgeInsets.fromLTRB(padding, 24, padding, 0),
contentPadding: EdgeInsets.fromLTRB(contentPadding ?? padding, 25, contentPadding: EdgeInsets.fromLTRB(
contentPadding ?? padding, actions is List ? 10 : padding), contentPadding ?? padding,
25,
contentPadding ?? padding,
actions is List ? 10 : padding,
),
content: ConstrainedBox( content: ConstrainedBox(
constraints: contentBoxConstraints, constraints: contentBoxConstraints,
child: Theme( child: content,
data: Theme.of(context).copyWith(
inputDecorationTheme: InputDecorationTheme(
isDense: true, contentPadding: EdgeInsets.all(15))),
child: content),
), ),
actions: actions, actions: actions,
actionsPadding: EdgeInsets.fromLTRB(padding, 0, padding, padding), actionsPadding: EdgeInsets.fromLTRB(padding, 0, padding, padding),
actionsAlignment: MainAxisAlignment.center,
), ),
); );
} }

View File

@ -49,6 +49,11 @@ enum MouseFocusScope {
none none
} }
final buttonShape =
MaterialStateProperty.all<RoundedRectangleBorder>(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
));
class FileManagerPage extends StatefulWidget { class FileManagerPage extends StatefulWidget {
const FileManagerPage({Key? key, required this.id, this.forceRelay}) const FileManagerPage({Key? key, required this.id, this.forceRelay})
: super(key: key); : super(key: key);
@ -300,14 +305,13 @@ class _FileManagerPageState extends State<FileManagerPage>
} }
skipCount = index + 1; skipCount = index + 1;
} }
var searchResult = entries var searchResult = entries.skip(skipCount).where(
.skip(skipCount) (element) => element.name.toLowerCase().startsWith(buffer));
.where((element) => element.name.toLowerCase().startsWith(buffer));
if (searchResult.isEmpty) { if (searchResult.isEmpty) {
// cannot find next, lets restart search from head // cannot find next, lets restart search from head
debugPrint("restart search from head"); debugPrint("restart search from head");
searchResult = searchResult = entries.where(
entries.where((element) => element.name.toLowerCase().startsWith(buffer)); (element) => element.name.toLowerCase().startsWith(buffer));
} }
if (searchResult.isEmpty) { if (searchResult.isEmpty) {
setState(() { setState(() {
@ -321,8 +325,8 @@ class _FileManagerPageState extends State<FileManagerPage>
onSearch: (buffer) { onSearch: (buffer) {
debugPrint("searching for $buffer"); debugPrint("searching for $buffer");
final selectedEntries = getSelectedItems(isLocal); final selectedEntries = getSelectedItems(isLocal);
final searchResult = final searchResult = entries.where(
entries.where((element) => element.name.toLowerCase().startsWith(buffer)); (element) => element.name.toLowerCase().startsWith(buffer));
selectedEntries.clear(); selectedEntries.clear();
if (searchResult.isEmpty) { if (searchResult.isEmpty) {
setState(() { setState(() {
@ -504,8 +508,7 @@ class _FileManagerPageState extends State<FileManagerPage>
debugPrint("entry is not valid: ${entry.path}"); debugPrint("entry is not valid: ${entry.path}");
} }
final selectedEntries = getSelectedItems(isLocal); final selectedEntries = getSelectedItems(isLocal);
final searchResult = final searchResult = entries.where((element) => element == entry);
entries.where((element) => element == entry);
selectedEntries.clear(); selectedEntries.clear();
if (searchResult.isEmpty) { if (searchResult.isEmpty) {
return; return;
@ -976,25 +979,66 @@ class _FileManagerPageState extends State<FileManagerPage>
cancel() => close(false); cancel() => close(false);
return CustomAlertDialog( return CustomAlertDialog(
title: Text(translate("Create Folder")), title: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset("assets/folder_new.svg",
color: MyTheme.accent),
Text(
translate("Create Folder"),
).paddingOnly(
left: 10,
),
],
),
content: Column( content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [
Column(
children: [ children: [
TextFormField( TextFormField(
decoration: InputDecoration( decoration: InputDecoration(
labelText: translate( labelText: translate(
"Please enter the folder name"), "Please enter the folder name",
),
), ),
controller: name, controller: name,
autofocus: true, autofocus: true,
), ),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
ElevatedButton.icon(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(
MyTheme.accent,
),
shape: buttonShape,
),
icon: Icon(Icons.close_rounded),
label: Text(translate("Cancel")),
onPressed: cancel,
),
ElevatedButton.icon(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(
MyTheme.accent,
),
shape: buttonShape,
),
icon: Icon(Icons.done_rounded),
label: Text(translate("Ok")),
onPressed: submit,
),
],
).paddingOnly(top: 20)
], ],
), ),
actions: [
dialogButton("Cancel",
onPressed: cancel, isOutline: true),
dialogButton("OK", onPressed: submit)
], ],
),
onSubmit: submit, onSubmit: submit,
onCancel: cancel, onCancel: cancel,
); );
@ -1036,11 +1080,7 @@ class _FileManagerPageState extends State<FileManagerPage>
? MyTheme.accent80 ? MyTheme.accent80
: MyTheme.accent, : MyTheme.accent,
), ),
shape: MaterialStateProperty.all<RoundedRectangleBorder>( shape: buttonShape,
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
),
), ),
onPressed: validItems(selectedItems) onPressed: validItems(selectedItems)
? () { ? () {
@ -1467,10 +1507,8 @@ class _FileManagerPageState extends State<FileManagerPage>
axis: Axis.vertical, axis: Axis.vertical,
onPointerMove: (dx) { onPointerMove: (dx) {
nameColWidth.value += dx; nameColWidth.value += dx;
nameColWidth.value = min( nameColWidth.value = min(kDesktopFileTransferMaximumWidth,
kDesktopFileTransferMaximumWidth, max(kDesktopFileTransferMinimumWidth, nameColWidth.value));
max(kDesktopFileTransferMinimumWidth,
nameColWidth.value));
}, },
padding: padding, padding: padding,
), ),