Compare commits

..

No commits in common. "a613292095b785d106cfcdfbdada2ff163028b9b" and "d914b8bcaedf964b184a7e3da80cf1c5469729cb" have entirely different histories.

2 changed files with 71 additions and 80 deletions

View File

@ -76,14 +76,15 @@ class _AddFormState extends State<AddForm> {
} }
return null; return null;
}, },
textInputAction: TextInputAction.next, onFieldSubmitted: (value) {
onFieldSubmitted: (value) => if (_formKey.currentState!.validate()) {
_formKey.currentState!.validate(), FocusScope.of(context).requestFocus(_TemplateFocusNode);
}
},
decoration: const InputDecoration(labelText: 'Label')), decoration: const InputDecoration(labelText: 'Label')),
TextFormField( TextFormField(
decoration: decoration:
const InputDecoration(labelText: 'Description(optional)'), const InputDecoration(labelText: 'Description(optional)'),
textInputAction: TextInputAction.next,
onChanged: (value) { onChanged: (value) {
_listDesc = value; _listDesc = value;
}, },

View File

@ -43,9 +43,6 @@ class _MainListPageState extends State<MainListPage> {
int _selectedPage = data.Page.lists.index; int _selectedPage = data.Page.lists.index;
List<data.List> lists = []; List<data.List> lists = [];
final double _marginHorizontal = 10;
final double _cardSpacing = 4;
Future<void> _loadData(data.Page listType) async { Future<void> _loadData(data.Page listType) async {
lists.clear(); lists.clear();
var res = await DBHelper.dbHelper.getAllLists(listType); var res = await DBHelper.dbHelper.getAllLists(listType);
@ -69,9 +66,6 @@ class _MainListPageState extends State<MainListPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final EdgeInsets cardMargin =
EdgeInsets.symmetric(vertical: _cardSpacing, horizontal: 0);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(widget.title), title: Text(widget.title),
@ -89,80 +83,76 @@ class _MainListPageState extends State<MainListPage> {
tooltip: 'Add List', tooltip: 'Add List',
child: const Icon(Icons.add), child: const Icon(Icons.add),
), ),
body: Container( body: RefreshIndicator(
padding: EdgeInsets.symmetric(horizontal: _marginHorizontal), onRefresh: () => _loadData(data.Page.values[_selectedPage]),
child: RefreshIndicator( child: ListView.builder(
onRefresh: () => _loadData(data.Page.values[_selectedPage]), itemCount: lists.length,
child: ListView.builder( itemBuilder: (context, index) {
itemCount: lists.length, return Dismissible(
itemBuilder: (context, index) { direction: DismissDirection.startToEnd,
return Dismissible( key: Key(lists[index].id.toString()),
direction: DismissDirection.startToEnd, background: Card(
key: Key(lists[index].id.toString()), color: Colors.red,
background: Card( child: Row(
margin: cardMargin, children: const [
color: Colors.red, Padding(
child: Row( padding: EdgeInsets.all(10),
children: const [ child: Icon(Icons.delete),
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( showDialog(
context: context, context: context,
builder: (context) { builder: (context) {
return AlertDialog( return AlertDialog(
title: const Text('Are you sure?'), title: const Text('Are you sure?'),
content: const Text( content: const Text(
'You are about to delete this permently'), 'You are about to delete this permently'),
actions: [ actions: [
TextButton( TextButton(
onPressed: () => onPressed: () =>
Navigator.pop(context, false), Navigator.pop(context, false),
child: const Text('Cancel')), child: const Text('Cancel')),
TextButton( TextButton(
onPressed: () => onPressed: () =>
Navigator.pop(context, true), Navigator.pop(context, true),
child: const Text('OK')), child: const Text('OK')),
], ],
); );
}).then((value) { }).then((value) {
if (value) { if (value) {
setState(() { setState(() {
_removeList(lists[index]); _removeList(lists[index]);
lists.removeAt(index); lists.removeAt(index);
});
}
return value;
}); });
}
return value;
});
},
child: Card(
child: ListTile(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
CheckList(id: lists[index].id!)));
}, },
child: Card( title: Text(lists[index].name),
margin: cardMargin, subtitle: Text((lists[index].description != null)
child: ListTile( ? lists[index].description!
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( bottomNavigationBar: BottomNavigationBar(
elevation: 4, elevation: 4,
currentIndex: _selectedPage, currentIndex: _selectedPage,