added dialog to create a bookmark manually
This commit is contained in:
102
lib/widgets/create_bookmark_dialog.dart
Normal file
102
lib/widgets/create_bookmark_dialog.dart
Normal file
@@ -0,0 +1,102 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../model/bookmark.dart';
|
||||
|
||||
class CreateBookmarkDialog extends StatelessWidget {
|
||||
const CreateBookmarkDialog({
|
||||
super.key,
|
||||
required this.collectionId,
|
||||
required this.onSavePressed,
|
||||
this.selectedBookmark,
|
||||
});
|
||||
final void Function(Bookmark bookmark) onSavePressed;
|
||||
final int collectionId;
|
||||
final Bookmark? selectedBookmark;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final nameController = TextEditingController();
|
||||
final linkController = TextEditingController();
|
||||
final descriptionController = TextEditingController();
|
||||
|
||||
return AlertDialog(
|
||||
title: Text('Create Bookmark'),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(padding: EdgeInsetsGeometry.only(top: 10)),
|
||||
TextField(
|
||||
controller: nameController,
|
||||
autofocus: true,
|
||||
maxLines: 1,
|
||||
maxLength: 50,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(
|
||||
RegExp(r'[a-zA-Z0-9äöüÄÖÜß\s]'),
|
||||
),
|
||||
FilteringTextInputFormatter.deny(RegExp(r'\s\s+')),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Bookmark Title',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
controller: linkController,
|
||||
maxLines: 1,
|
||||
maxLength: 50,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(
|
||||
RegExp(r'[a-zA-Z0-9äöüÄÖÜß\s]'),
|
||||
),
|
||||
FilteringTextInputFormatter.deny(RegExp(r'\s\s+')),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Url',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
controller: descriptionController,
|
||||
maxLines: 3,
|
||||
maxLength: 300,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(
|
||||
RegExp(r'[a-zA-Z0-9äöüÄÖÜß\s]'),
|
||||
),
|
||||
FilteringTextInputFormatter.deny(RegExp(r'\s\s+')),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Description',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
FloatingActionButton(
|
||||
onPressed: () {
|
||||
onSavePressed(
|
||||
Bookmark(
|
||||
collectionId: collectionId,
|
||||
name: nameController.text,
|
||||
link: linkController.text,
|
||||
description: descriptionController.text,
|
||||
),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Icon(Icons.save),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user