boxchecker/lib/add_form.dart

68 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import 'data_util.dart' as data;
class AddForm extends StatelessWidget {
AddForm({Key? key, required this.type}) : super(key: key);
final _formKey = GlobalKey<FormState>();
final data.Page type;
int _templatChoice = -1;
final FocusNode _TemplateFocusNode = FocusNode();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'Add ' +
((type == data.Page.lists)
? 'Check List'
: (type == data.Page.templates)
? 'Template'
: ''),
),
),
body: Container(
margin: const EdgeInsets.all(10),
child: Form(
key: _formKey,
child: Column(
children: [
TextFormField(
onFieldSubmitted: (value) {
FocusScope.of(context).requestFocus(_TemplateFocusNode);
},
decoration: const InputDecoration(labelText: 'Label')),
DropdownButtonFormField(
focusNode: _TemplateFocusNode,
value: _templatChoice,
onChanged: (value) {
setState() {
_templatChoice = value as int;
}
},
decoration:
const InputDecoration(labelText: "Starting Template"),
items: const [
// TODO get templates from database
DropdownMenuItem<int>(child: Text("None"), value: -1),
DropdownMenuItem<int>(child: Text("1"), value: 0),
],
)
],
),
),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.save_alt),
onPressed: () {
// TODO implement adding list to database
Navigator.pop(context); // TODO replace route with checklist page
},
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
);
}
}