Merge branch 'main' into 'Dynamische_Liste'

addpage beginn

See merge request Gruber.Nicolas/oggauer_gemeindetrommler!2
This commit is contained in:
2023-02-23 13:50:37 +00:00
2 changed files with 171 additions and 0 deletions
+145
View File
@@ -0,0 +1,145 @@
import 'package:flutter/material.dart';
class AddScreen extends StatefulWidget {
@override
_AddScreenState createState() => _AddScreenState();
}
class _AddScreenState extends State<AddScreen> {
final _formKey = GlobalKey<FormState>();
final _titleController = TextEditingController();
final _descriptionController = TextEditingController();
final _imageController = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Neues Element hinzufügen'),
actions: [
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: IconButton(
icon: Icon(Icons.refresh),
onPressed: () {
_titleController.clear();
_descriptionController.clear();
_imageController.clear();
},
),
),
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: IconButton(
icon: Icon(Icons.check),
onPressed: () {
if (_formKey.currentState!.validate()) {
// Hier wird die Logik zum Hinzufügen des neuen Elements ausgeführt
Navigator.pop(context);
}
},
),
),
],
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: Column(
children: [
TextFormField(
decoration: InputDecoration(
labelText: 'Titel',
filled: true,
fillColor: Colors.grey[200],
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16.0),
),
),
controller: _titleController,
validator: (value) {
if (value!.isEmpty) {
return 'Bitte geben Sie einen Titel ein.';
}
return null;
},
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(
labelText: 'Beschreibung',
filled: true,
fillColor: Colors.grey[200],
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16.0),
),
),
controller: _descriptionController,
validator: (value) {
if (value!.isEmpty) {
return 'Bitte geben Sie eine Beschreibung ein.';
}
return null;
},
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(
labelText: 'Bild',
filled: true,
fillColor: Colors.grey[200],
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16.0),
),
),
controller: _imageController,
validator: (value) {
if (value!.isEmpty) {
return 'Bitte geben Sie ein Bild ein.';
}
return null;
},
),
],
),
),
),
);
}
}
/*import 'package:flutter/material.dart';
class AddScreen extends StatelessWidget {
const AddScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Neues Element hinzufügen'),
),
body: Column(
children: [
TextFormField(
decoration: InputDecoration(labelText: 'Titel'),
),
TextFormField(
decoration: InputDecoration(labelText: 'Beschreibung'),
),
TextFormField(
decoration: InputDecoration(labelText: 'Bild'),
),
ElevatedButton(
onPressed: () {
// Fügen Sie hier die Logik zum Hinzufügen eines neuen Elements hinzu
Navigator.pop(context);
},
child: Text('Hinzufügen'),
),
],
),
);
}
}*/
+26
View File
@@ -1,3 +1,4 @@
import 'package:demoapp/AddPage.dart';
import 'package:flutter/material.dart';
import 'UserDefinedList.dart';
@@ -23,6 +24,19 @@ class _MyHomePageState extends State<MyHomePage> {
});
}
int _counter = 0;
void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}
void setLogin(bool value) {
setState(() {
login = value;
@@ -65,6 +79,18 @@ class _MyHomePageState extends State<MyHomePage> {
child: widgetOptions.elementAt(_selectedIndex),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => AddScreen()),
);
},
tooltip: "Add",
child: Icon(Icons.add),
),
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>
[