List descriptions
This commit is contained in:
parent
0aea396e99
commit
b458393948
|
|
@ -17,6 +17,7 @@ class _AddFormState extends State<AddForm> {
|
|||
final data.Page type;
|
||||
int _templatChoice = -1;
|
||||
String _listLabel = "";
|
||||
String _listDesc = "";
|
||||
List<data.List> templates = [];
|
||||
|
||||
final FocusNode _TemplateFocusNode = FocusNode();
|
||||
|
|
@ -81,6 +82,13 @@ class _AddFormState extends State<AddForm> {
|
|||
}
|
||||
},
|
||||
decoration: const InputDecoration(labelText: 'Label')),
|
||||
TextFormField(
|
||||
decoration:
|
||||
const InputDecoration(labelText: 'Description(optional)'),
|
||||
onChanged: (value) {
|
||||
_listDesc = value;
|
||||
},
|
||||
),
|
||||
DropdownButtonFormField<int>(
|
||||
focusNode: _TemplateFocusNode,
|
||||
value: _templatChoice,
|
||||
|
|
@ -103,7 +111,7 @@ class _AddFormState extends State<AddForm> {
|
|||
data.List(
|
||||
_listLabel,
|
||||
isTemplate: type.index == 1,
|
||||
// TODO Add description to lists
|
||||
description: _listDesc,
|
||||
),
|
||||
);
|
||||
if (_templatChoice >= 0 && _templatChoice < templates.length) {
|
||||
|
|
|
|||
|
|
@ -146,7 +146,9 @@ class _MainListPageState extends State<MainListPage> {
|
|||
CheckList(id: lists[index].id!)));
|
||||
},
|
||||
title: Text(lists[index].name),
|
||||
subtitle: Text(lists[index].id.toString()),
|
||||
subtitle: Text((lists[index].description != null)
|
||||
? lists[index].description!
|
||||
: ""),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,23 +1,29 @@
|
|||
enum Page { lists, templates }
|
||||
|
||||
class List {
|
||||
List(this.name, {this.id, this.isTemplate});
|
||||
List(this.name, {this.id, this.description, this.isTemplate});
|
||||
|
||||
int? id;
|
||||
String name;
|
||||
String? description;
|
||||
bool? isTemplate;
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
var map = Map<String, dynamic>();
|
||||
if (id != null) map["id"] = this.id;
|
||||
map["list_name"] = this.name;
|
||||
if (description != null) map["list_desc"] = description;
|
||||
if (isTemplate != null) map["is_template"] = isTemplate! ? 1 : 0;
|
||||
return map;
|
||||
}
|
||||
|
||||
static List fromMap(Map<String, dynamic> map) {
|
||||
return List(map["list_name"],
|
||||
id: map["id"], isTemplate: map["is_template"] == 1);
|
||||
return List(
|
||||
map["list_name"],
|
||||
id: map["id"],
|
||||
description: map["list_desc"],
|
||||
isTemplate: map["is_template"] == 1,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ class DBHelper {
|
|||
CREATE TABLE List(
|
||||
id INTEGER PRIMARY KEY,
|
||||
list_name TEXT,
|
||||
list_desc TEXT,
|
||||
is_template int2
|
||||
)
|
||||
""");
|
||||
|
|
@ -36,10 +37,10 @@ class DBHelper {
|
|||
)
|
||||
""");
|
||||
db.execute("""
|
||||
INSERT INTO List(id, list_name, is_template)
|
||||
INSERT INTO List(id, list_name, list_desc, is_template)
|
||||
VALUES
|
||||
(0, 'test list', 0),
|
||||
(1, 'test template', 1)
|
||||
(0, 'test list', 'A list to test', 0),
|
||||
(1, 'test template', 'A template to test', 1)
|
||||
""");
|
||||
db.execute("""
|
||||
INSERT INTO Item(id, check_text, status, list_id)
|
||||
|
|
@ -49,7 +50,7 @@ class DBHelper {
|
|||
(2, 'test item', 0, 1),
|
||||
(3, 'test item', 1, 1)
|
||||
""");
|
||||
}, version: 1);
|
||||
}, version: 2);
|
||||
return database;
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +87,6 @@ class DBHelper {
|
|||
|
||||
Future<void> copyList(int oldID, int newID) async {
|
||||
Database db = await database;
|
||||
print('$newID, $oldID');
|
||||
|
||||
var batch = db.batch();
|
||||
db.execute("""
|
||||
|
|
|
|||
Loading…
Reference in New Issue