tried to release issues per form dialog

This commit is contained in:
Schummi C
2023-03-02 17:00:20 +01:00
parent cd99dd5c34
commit dd737fa61a
6 changed files with 298 additions and 117 deletions
+212 -65
View File
@@ -1,7 +1,4 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
/*import 'package:flutter/material.dart';
class AddScreen extends StatefulWidget {
@override
@@ -12,17 +9,7 @@ class _AddScreenState extends State<AddScreen> {
final _formKey = GlobalKey<FormState>();
final _titleController = TextEditingController();
final _descriptionController = TextEditingController();
File? _imageFile;
Future<void> _getImage(ImageSource source) async {
final pickedFile = await ImagePicker().getImage(source: source);
if (pickedFile != null) {
setState(() {
_imageFile = File(pickedFile.path);
});
}
}
final _imageController = TextEditingController();
@override
Widget build(BuildContext context) {
@@ -37,9 +24,7 @@ class _AddScreenState extends State<AddScreen> {
onPressed: () {
_titleController.clear();
_descriptionController.clear();
setState(() {
_imageFile = null;
});
_imageController.clear();
},
),
),
@@ -99,56 +84,218 @@ class _AddScreenState extends State<AddScreen> {
},
),
SizedBox(height: 16.0),
_imageFile != null
? Image.file(_imageFile!)
: Container(
height: 150.0,
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(16.0),
),
child: Center(
child: TextButton(
onPressed: () {
showModalBottomSheet(
context: context,
builder: (context) => Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
leading: Icon(Icons.photo_library),
title: Text('Galerie auswählen'),
onTap: () {
Navigator.pop(context);
_getImage(ImageSource.gallery);
}, //
),
ListTile(
leading: Icon(Icons.camera_alt),
title: Text('Kamera verwenden'),
onTap: () {
Navigator.pop(context);
_getImage(ImageSource.camera);
},
),
],
),
);
},
child: Text(
'Bild hinzufügen',
style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold,
),
),
),
),
),
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 'dart:io';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
class AddScreen extends StatefulWidget {
@override
_AddScreenState createState() => _AddScreenState();
}
class _AddScreenState extends State<AddScreen> {
final _formKey = GlobalKey<FormState>();
final _titleController = TextEditingController();
final _descriptionController = TextEditingController();
File? _imageFile;
Future<void> _getImage(ImageSource source) async {
final pickedFile = await ImagePicker().getImage(source: source);
if (pickedFile != null) {
setState(() {
_imageFile = File(pickedFile.path);
});
}
}
@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();
setState(() {
_imageFile = null;
});
},
),
),
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),
_imageFile != null
? Image.file(_imageFile!)
: Container(
height: 150.0,
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(16.0),
),
child: Center(
child: TextButton(
onPressed: () {
showModalBottomSheet(
context: context,
builder: (context) => Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
leading: Icon(Icons.photo_library),
title: Text ('Galerie auswählen'),
onTap: () {
Navigator.pop(context);
_getImage(ImageSource.gallery);
}, //
),
ListTile(
leading: Icon(Icons.camera_alt),
title: Text('Kamera verwenden'),
onTap: () {
Navigator.pop(context);
_getImage(ImageSource.camera);
},
),
],
),
);
},
child: Text(
'Bild hinzufügen',
style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold,
),
),
),
),
),
],
),
),
),
);
}
}
/*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'),
),
],
),
);
}
}*/
+1 -1
View File
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
class DetailPage extends StatelessWidget {
final String title;
final String description;
final Image image;
final Image? image;
const DetailPage({
super.key,
+7 -5
View File
@@ -5,12 +5,12 @@ import 'DetailPage.dart';
class UserDefinedItem extends StatelessWidget {
final String title;
final String description;
final Image image;
final Image? image;
const UserDefinedItem({super.key,
required this.title,
required this.description,
required this.image,
this.image,
});
@override
@@ -28,7 +28,7 @@ class UserDefinedItem extends StatelessWidget {
builder: (context) => DetailPage(
title: title,
description: description,
image: image,
image: image!= null ? image! : null,
),
),
);
@@ -180,6 +180,8 @@ class NewsList extends StatelessWidget {
}
}*/
IssueList issueList = IssueList();
class IssueList extends StatelessWidget {
final List<UserDefinedItem> _items = [];
@@ -205,8 +207,8 @@ class IssueList extends StatelessWidget {
description: 'Gemeide Amt der Marktgemeinde Oggau. SPÖ regierend',
image: Image.network('https://upload.wikimedia.org/wikipedia/commons/a/a1/Oggau_am_Neusiedler_See_-_Gemeindeamt_%2801%29.jpg'),
);
addUDI(item1);
addUDI(item2);
//addUDI(item1);
//addUDI(item2);
return ListView(
children: _items.map((item) => UserDefinedItem(
title: item.title,
+1 -1
View File
@@ -33,7 +33,7 @@ class _MyHomePageState extends State<MyHomePage> {
Widget build(BuildContext context) {
final List<Widget> widgetOptions = <Widget>[
const NewsList(),
login ? IssueList() : const Text(
login ? issueList: const Text(
'Mängel (nur für angemeldete Benutzer verfügbar)',
style: optionStyle,
textAlign: TextAlign.center,