Compare commits
2 Commits
d914b8bcae
...
a613292095
| Author | SHA1 | Date |
|---|---|---|
|
|
a613292095 | |
|
|
b8c49132d7 |
|
|
@ -76,15 +76,14 @@ class _AddFormState extends State<AddForm> {
|
|||
}
|
||||
return null;
|
||||
},
|
||||
onFieldSubmitted: (value) {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
FocusScope.of(context).requestFocus(_TemplateFocusNode);
|
||||
}
|
||||
},
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (value) =>
|
||||
_formKey.currentState!.validate(),
|
||||
decoration: const InputDecoration(labelText: 'Label')),
|
||||
TextFormField(
|
||||
decoration:
|
||||
const InputDecoration(labelText: 'Description(optional)'),
|
||||
textInputAction: TextInputAction.next,
|
||||
onChanged: (value) {
|
||||
_listDesc = value;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ class _MainListPageState extends State<MainListPage> {
|
|||
int _selectedPage = data.Page.lists.index;
|
||||
List<data.List> lists = [];
|
||||
|
||||
final double _marginHorizontal = 10;
|
||||
final double _cardSpacing = 4;
|
||||
|
||||
Future<void> _loadData(data.Page listType) async {
|
||||
lists.clear();
|
||||
var res = await DBHelper.dbHelper.getAllLists(listType);
|
||||
|
|
@ -66,6 +69,9 @@ class _MainListPageState extends State<MainListPage> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final EdgeInsets cardMargin =
|
||||
EdgeInsets.symmetric(vertical: _cardSpacing, horizontal: 0);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.title),
|
||||
|
|
@ -83,76 +89,80 @@ class _MainListPageState extends State<MainListPage> {
|
|||
tooltip: 'Add List',
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
body: RefreshIndicator(
|
||||
onRefresh: () => _loadData(data.Page.values[_selectedPage]),
|
||||
child: ListView.builder(
|
||||
itemCount: lists.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Dismissible(
|
||||
direction: DismissDirection.startToEnd,
|
||||
key: Key(lists[index].id.toString()),
|
||||
background: Card(
|
||||
color: Colors.red,
|
||||
child: Row(
|
||||
children: const [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Icon(Icons.delete),
|
||||
body: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: _marginHorizontal),
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () => _loadData(data.Page.values[_selectedPage]),
|
||||
child: ListView.builder(
|
||||
itemCount: lists.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Dismissible(
|
||||
direction: DismissDirection.startToEnd,
|
||||
key: Key(lists[index].id.toString()),
|
||||
background: Card(
|
||||
margin: cardMargin,
|
||||
color: Colors.red,
|
||||
child: Row(
|
||||
children: const [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Icon(Icons.delete),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
confirmDismiss: (direction) async {
|
||||
if (direction != DismissDirection.startToEnd) {
|
||||
return false;
|
||||
}
|
||||
),
|
||||
confirmDismiss: (direction) async {
|
||||
if (direction != DismissDirection.startToEnd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Are you sure?'),
|
||||
content: const Text(
|
||||
'You are about to delete this permently'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
Navigator.pop(context, false),
|
||||
child: const Text('Cancel')),
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
Navigator.pop(context, true),
|
||||
child: const Text('OK')),
|
||||
],
|
||||
);
|
||||
}).then((value) {
|
||||
if (value) {
|
||||
setState(() {
|
||||
_removeList(lists[index]);
|
||||
lists.removeAt(index);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Are you sure?'),
|
||||
content: const Text(
|
||||
'You are about to delete this permently'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
Navigator.pop(context, false),
|
||||
child: const Text('Cancel')),
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
Navigator.pop(context, true),
|
||||
child: const Text('OK')),
|
||||
],
|
||||
);
|
||||
}).then((value) {
|
||||
if (value) {
|
||||
setState(() {
|
||||
_removeList(lists[index]);
|
||||
lists.removeAt(index);
|
||||
});
|
||||
}
|
||||
|
||||
return value;
|
||||
});
|
||||
}
|
||||
|
||||
return value;
|
||||
});
|
||||
},
|
||||
child: Card(
|
||||
child: ListTile(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
CheckList(id: lists[index].id!)));
|
||||
},
|
||||
title: Text(lists[index].name),
|
||||
subtitle: Text((lists[index].description != null)
|
||||
? lists[index].description!
|
||||
: ""),
|
||||
),
|
||||
),
|
||||
);
|
||||
})),
|
||||
child: Card(
|
||||
margin: cardMargin,
|
||||
child: ListTile(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
CheckList(id: lists[index].id!)));
|
||||
},
|
||||
title: Text(lists[index].name),
|
||||
subtitle: Text((lists[index].description != null)
|
||||
? lists[index].description!
|
||||
: ""),
|
||||
),
|
||||
),
|
||||
);
|
||||
}))),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
elevation: 4,
|
||||
currentIndex: _selectedPage,
|
||||
|
|
|
|||
Loading…
Reference in New Issue