Code cleaned up
This commit is contained in:
+64
-211
@@ -1,4 +1,7 @@
|
|||||||
/*import 'package:flutter/material.dart';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
|
||||||
class AddScreen extends StatefulWidget {
|
class AddScreen extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
@@ -9,7 +12,17 @@ class _AddScreenState extends State<AddScreen> {
|
|||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
final _titleController = TextEditingController();
|
final _titleController = TextEditingController();
|
||||||
final _descriptionController = TextEditingController();
|
final _descriptionController = TextEditingController();
|
||||||
final _imageController = 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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -24,7 +37,9 @@ class _AddScreenState extends State<AddScreen> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
_titleController.clear();
|
_titleController.clear();
|
||||||
_descriptionController.clear();
|
_descriptionController.clear();
|
||||||
_imageController.clear();
|
setState(() {
|
||||||
|
_imageFile = null;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -84,218 +99,56 @@ class _AddScreenState extends State<AddScreen> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
SizedBox(height: 16.0),
|
SizedBox(height: 16.0),
|
||||||
TextFormField(
|
_imageFile != null
|
||||||
decoration: InputDecoration(
|
? Image.file(_imageFile!)
|
||||||
labelText: 'Bild',
|
: Container(
|
||||||
filled: true,
|
height: 150.0,
|
||||||
fillColor: Colors.grey[200],
|
decoration: BoxDecoration(
|
||||||
border: OutlineInputBorder(
|
color: Colors.grey[200],
|
||||||
borderRadius: BorderRadius.circular(16.0),
|
borderRadius: BorderRadius.circular(16.0),
|
||||||
),
|
),
|
||||||
),
|
child: Center(
|
||||||
controller: _imageController,
|
child: TextButton(
|
||||||
validator: (value) {
|
onPressed: () {
|
||||||
if (value!.isEmpty) {
|
showModalBottomSheet(
|
||||||
return 'Bitte geben Sie ein Bild ein.';
|
context: context,
|
||||||
}
|
builder: (context) => Column(
|
||||||
return null;
|
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 '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});
|
|
||||||
|
|
||||||
|
|
||||||
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'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|||||||
@@ -130,56 +130,6 @@ class NewsList extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*class IssueList extends StatelessWidget {
|
|
||||||
IssueList({super.key});
|
|
||||||
final List<UserDefinedItem> _items = [];
|
|
||||||
|
|
||||||
/*void addItem(UserDefinedItem item) {
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeItem(UserDefinedItem item) {
|
|
||||||
_items.remove(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
final UserDefinedItem item1 = UserDefinedItem(
|
|
||||||
title: 'Licht ausgebrannt',
|
|
||||||
description: 'Licht ist ausgebrannt in der Sebastianstraße',
|
|
||||||
image: Image.network('https://api.ebsg.at/uploads/immo70/originals/objekt_809_oggau-am-neusiedler-see_7063_6021.jpeg',),
|
|
||||||
);
|
|
||||||
final UserDefinedItem item2 = UserDefinedItem(
|
|
||||||
title: 'test2',
|
|
||||||
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'),
|
|
||||||
);
|
|
||||||
|
|
||||||
_items.add(item1);
|
|
||||||
_items.add(item2);*/
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return ListView(
|
|
||||||
children: [
|
|
||||||
UserDefinedItem(
|
|
||||||
title: 'Licht ausgebrannt',
|
|
||||||
description: 'Licht ist ausgebrannt in der Sebastianstraße',
|
|
||||||
image: Image.network('https://api.ebsg.at/uploads/immo70/originals/objekt_809_oggau-am-neusiedler-see_7063_6021.jpeg',),
|
|
||||||
),
|
|
||||||
UserDefinedItem(
|
|
||||||
title: 'test2',
|
|
||||||
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'),
|
|
||||||
),
|
|
||||||
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
IssueList issueList = IssueList();
|
IssueList issueList = IssueList();
|
||||||
|
|
||||||
class IssueList extends StatelessWidget {
|
class IssueList extends StatelessWidget {
|
||||||
|
|||||||
Reference in New Issue
Block a user