Compare commits
2 commits
Wolle-Scre
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 72c0208965 | |||
| 3c1e11778b |
11 changed files with 58 additions and 269 deletions
|
|
@ -13,7 +13,7 @@ class Wolle extends Table {
|
|||
IntColumn get id => integer().autoIncrement()();
|
||||
TextColumn get manufacture => text()();
|
||||
TextColumn get title => text()();
|
||||
IntColumn get color => integer()();
|
||||
TextColumn get color => text().withLength(min: 7, max: 7)();
|
||||
}
|
||||
|
||||
class TempRange extends Table {
|
||||
|
|
|
|||
|
|
@ -30,9 +30,12 @@ class $WolleTable extends Wolle with TableInfo<$WolleTable, WolleData> {
|
|||
type: DriftSqlType.string, requiredDuringInsert: true);
|
||||
static const VerificationMeta _colorMeta = const VerificationMeta('color');
|
||||
@override
|
||||
late final GeneratedColumn<int> color = GeneratedColumn<int>(
|
||||
late final GeneratedColumn<String> color = GeneratedColumn<String>(
|
||||
'color', aliasedName, false,
|
||||
type: DriftSqlType.int, requiredDuringInsert: true);
|
||||
additionalChecks:
|
||||
GeneratedColumn.checkTextLength(minTextLength: 7, maxTextLength: 7),
|
||||
type: DriftSqlType.string,
|
||||
requiredDuringInsert: true);
|
||||
@override
|
||||
List<GeneratedColumn> get $columns => [id, manufacture, title, color];
|
||||
@override
|
||||
|
|
@ -84,7 +87,7 @@ class $WolleTable extends Wolle with TableInfo<$WolleTable, WolleData> {
|
|||
title: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
|
||||
color: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}color'])!,
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}color'])!,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +101,7 @@ class WolleData extends DataClass implements Insertable<WolleData> {
|
|||
final int id;
|
||||
final String manufacture;
|
||||
final String title;
|
||||
final int color;
|
||||
final String color;
|
||||
const WolleData(
|
||||
{required this.id,
|
||||
required this.manufacture,
|
||||
|
|
@ -110,7 +113,7 @@ class WolleData extends DataClass implements Insertable<WolleData> {
|
|||
map['id'] = Variable<int>(id);
|
||||
map['manufacture'] = Variable<String>(manufacture);
|
||||
map['title'] = Variable<String>(title);
|
||||
map['color'] = Variable<int>(color);
|
||||
map['color'] = Variable<String>(color);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +133,7 @@ class WolleData extends DataClass implements Insertable<WolleData> {
|
|||
id: serializer.fromJson<int>(json['id']),
|
||||
manufacture: serializer.fromJson<String>(json['manufacture']),
|
||||
title: serializer.fromJson<String>(json['title']),
|
||||
color: serializer.fromJson<int>(json['color']),
|
||||
color: serializer.fromJson<String>(json['color']),
|
||||
);
|
||||
}
|
||||
@override
|
||||
|
|
@ -140,12 +143,12 @@ class WolleData extends DataClass implements Insertable<WolleData> {
|
|||
'id': serializer.toJson<int>(id),
|
||||
'manufacture': serializer.toJson<String>(manufacture),
|
||||
'title': serializer.toJson<String>(title),
|
||||
'color': serializer.toJson<int>(color),
|
||||
'color': serializer.toJson<String>(color),
|
||||
};
|
||||
}
|
||||
|
||||
WolleData copyWith(
|
||||
{int? id, String? manufacture, String? title, int? color}) =>
|
||||
{int? id, String? manufacture, String? title, String? color}) =>
|
||||
WolleData(
|
||||
id: id ?? this.id,
|
||||
manufacture: manufacture ?? this.manufacture,
|
||||
|
|
@ -179,7 +182,7 @@ class WolleCompanion extends UpdateCompanion<WolleData> {
|
|||
final Value<int> id;
|
||||
final Value<String> manufacture;
|
||||
final Value<String> title;
|
||||
final Value<int> color;
|
||||
final Value<String> color;
|
||||
const WolleCompanion({
|
||||
this.id = const Value.absent(),
|
||||
this.manufacture = const Value.absent(),
|
||||
|
|
@ -190,7 +193,7 @@ class WolleCompanion extends UpdateCompanion<WolleData> {
|
|||
this.id = const Value.absent(),
|
||||
required String manufacture,
|
||||
required String title,
|
||||
required int color,
|
||||
required String color,
|
||||
}) : manufacture = Value(manufacture),
|
||||
title = Value(title),
|
||||
color = Value(color);
|
||||
|
|
@ -198,7 +201,7 @@ class WolleCompanion extends UpdateCompanion<WolleData> {
|
|||
Expression<int>? id,
|
||||
Expression<String>? manufacture,
|
||||
Expression<String>? title,
|
||||
Expression<int>? color,
|
||||
Expression<String>? color,
|
||||
}) {
|
||||
return RawValuesInsertable({
|
||||
if (id != null) 'id': id,
|
||||
|
|
@ -212,7 +215,7 @@ class WolleCompanion extends UpdateCompanion<WolleData> {
|
|||
{Value<int>? id,
|
||||
Value<String>? manufacture,
|
||||
Value<String>? title,
|
||||
Value<int>? color}) {
|
||||
Value<String>? color}) {
|
||||
return WolleCompanion(
|
||||
id: id ?? this.id,
|
||||
manufacture: manufacture ?? this.manufacture,
|
||||
|
|
@ -234,7 +237,7 @@ class WolleCompanion extends UpdateCompanion<WolleData> {
|
|||
map['title'] = Variable<String>(title.value);
|
||||
}
|
||||
if (color.present) {
|
||||
map['color'] = Variable<int>(color.value);
|
||||
map['color'] = Variable<String>(color.value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,16 @@
|
|||
import 'package:drift/drift.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hexcolor/hexcolor.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:temperaturdecke/database.dart';
|
||||
|
||||
void addWool(BuildContext context, String title, String? manufacture,
|
||||
Color color) async {
|
||||
void addWool(BuildContext context) async {
|
||||
try {
|
||||
AppDatabase db = Provider.of<AppDatabase>(context, listen: false);
|
||||
|
||||
print("adding wool");
|
||||
|
||||
db.into(db.wolle).insert(WolleCompanion.insert(
|
||||
title: title,
|
||||
color: color.value,
|
||||
manufacture: manufacture ?? "none",
|
||||
title: 'Kakapo',
|
||||
color: '#00FF05',
|
||||
manufacture: 'test',
|
||||
));
|
||||
} catch (e) {
|
||||
// Fehlerbehandlung hier
|
||||
|
|
@ -31,13 +27,3 @@ void removeWool(BuildContext context, int dId) async {
|
|||
print('Fehler beim Einfügen: $e');
|
||||
}
|
||||
}
|
||||
|
||||
void deleteEverything(BuildContext context) async {
|
||||
AppDatabase db = Provider.of<AppDatabase>(context, listen: false);
|
||||
// you only need this if you've manually enabled foreign keys
|
||||
// await customStatement('PRAGMA foreign_keys = OFF');
|
||||
for (final table in db.allTables) {
|
||||
await db.delete(table).go();
|
||||
}
|
||||
;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,97 +0,0 @@
|
|||
import 'package:flex_color_picker/flex_color_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hexcolor/hexcolor.dart';
|
||||
import 'package:temperaturdecke/db_test.dart';
|
||||
import 'package:temperaturdecke/widgets/modal_wrapper.dart';
|
||||
|
||||
class AddWoolModal extends StatelessWidget {
|
||||
AddWoolModal({super.key});
|
||||
|
||||
Color selectedColor = Colors.white;
|
||||
String title = "";
|
||||
String manufacture = "";
|
||||
|
||||
void setSelectedColor(Color color) {
|
||||
selectedColor = color;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ModalWrapper(
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Text(
|
||||
"Randdaten",
|
||||
textAlign: TextAlign.start,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
TextField(
|
||||
onChanged: (value) => {title = value},
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Name',
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
TextField(
|
||||
onChanged: (value) => {manufacture = value},
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Marke',
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Text(
|
||||
"Farbe",
|
||||
textAlign: TextAlign.start,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
ColorPicker(
|
||||
spacing: 8,
|
||||
padding: EdgeInsets.all(0),
|
||||
borderRadius: 10,
|
||||
onColorChanged: (value) => setSelectedColor(value),
|
||||
enableShadesSelection: false,
|
||||
enableTonalPalette: true,
|
||||
tonalColorSameSize: true,
|
||||
pickersEnabled: {ColorPickerType.accent: false},
|
||||
tonalSubheading: Divider(),
|
||||
),
|
||||
SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: FilledButton(
|
||||
onPressed: () => addWool(
|
||||
context,
|
||||
title,
|
||||
manufacture,
|
||||
selectedColor,
|
||||
),
|
||||
child: Text(
|
||||
"Hinzufügen",
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
title: "Wolle hinzufügen",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -22,8 +22,6 @@ class AccentColorExample extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FilledButton(
|
||||
child: Text("Delete all"),
|
||||
onPressed: () => {deleteEverything(context)});
|
||||
return Placeholder();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
import 'package:temperaturdecke/database.dart';
|
||||
import 'package:temperaturdecke/screens/add_wool_modal.dart';
|
||||
import 'package:temperaturdecke/widgets/cards/wool_card.dart';
|
||||
import 'package:temperaturdecke/widgets/custom_card.dart';
|
||||
|
||||
class WoolScreen extends StatelessWidget {
|
||||
WoolScreen({super.key});
|
||||
|
|
@ -12,95 +9,45 @@ class WoolScreen extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget child;
|
||||
|
||||
return FutureBuilder(
|
||||
future: Provider.of<AppDatabase>(context)
|
||||
.select(Provider.of<AppDatabase>(context).wolle)
|
||||
.get(),
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
child = Center(
|
||||
child: Shimmer.fromColors(
|
||||
baseColor: Theme.of(context).colorScheme.secondaryContainer,
|
||||
highlightColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSecondaryContainer
|
||||
.withOpacity(.3),
|
||||
child: ListView.builder(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Column(
|
||||
children: [
|
||||
CustomCard(
|
||||
SizedBox(
|
||||
height: 70,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: 6,
|
||||
),
|
||||
),
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
} else {
|
||||
// Hier können Sie den Inhalt basierend auf den geladenen Daten anzeigen
|
||||
child = Scaffold(
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
label: Text("Hinzufügen"),
|
||||
onPressed: () {
|
||||
showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
showDragHandle: true,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AddWoolModal();
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Column(
|
||||
children: [
|
||||
Woolcard(
|
||||
index,
|
||||
snapshot.data[index].manufacture,
|
||||
snapshot.data[index].title,
|
||||
snapshot.data[index].color,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
icon: Icon(Icons.add),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Column(
|
||||
children: [
|
||||
Woolcard(
|
||||
index,
|
||||
snapshot.data[index].manufacture,
|
||||
snapshot.data[index].title,
|
||||
Color(snapshot.data[index].color),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: snapshot.data.length,
|
||||
),
|
||||
itemCount: snapshot.data.length,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return AnimatedSwitcher(
|
||||
duration: Duration(milliseconds: 500),
|
||||
switchInCurve: Curves.easeOut,
|
||||
switchOutCurve: Curves.ease,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class Woolcard extends StatelessWidget {
|
|||
int id;
|
||||
String manufacture;
|
||||
String title;
|
||||
Color color;
|
||||
String color;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomCard(Row(
|
||||
|
|
@ -21,7 +21,7 @@ class Woolcard extends StatelessWidget {
|
|||
Container(
|
||||
height: 70,
|
||||
width: 30,
|
||||
color: color,
|
||||
color: HexColor(color),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
|
|
@ -39,7 +39,6 @@ class Woolcard extends StatelessWidget {
|
|||
child: IconButton(
|
||||
onPressed: () {
|
||||
showModalBottomSheet(
|
||||
showDragHandle: true,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return WoolModal(id);
|
||||
|
|
|
|||
|
|
@ -1,38 +1,19 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class ModalWrapper extends StatelessWidget {
|
||||
ModalWrapper(this.child, {this.title, key});
|
||||
ModalWrapper(this.child, {super.key});
|
||||
|
||||
Widget child;
|
||||
String? title;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: Radius.circular(20),
|
||||
),
|
||||
child: Wrap(
|
||||
children: [
|
||||
SizedBox(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||
child: SizedBox(
|
||||
width: 750,
|
||||
height: MediaQuery.of(context).size.height - 100,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 25, vertical: 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title ?? "",
|
||||
textAlign: TextAlign.start,
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
child
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
padding: EdgeInsets.all(10),
|
||||
child: child,
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
24
pubspec.lock
24
pubspec.lock
|
|
@ -265,22 +265,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
flex_color_picker:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flex_color_picker
|
||||
sha256: "5c846437069fb7afdd7ade6bf37e628a71d2ab0787095ddcb1253bf9345d5f3a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.4.1"
|
||||
flex_seed_scheme:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flex_seed_scheme
|
||||
sha256: "4cee2f1d07259f77e8b36f4ec5f35499d19e74e17c7dce5b819554914082bc01"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.5.0"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
|
|
@ -592,14 +576,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
shimmer:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: shimmer
|
||||
sha256: "5f88c883a22e9f9f299e5ba0e4f7e6054857224976a5d9f839d4ebdc94a14ac9"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.0"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
|
|
|||
|
|
@ -33,10 +33,6 @@ dependencies:
|
|||
|
||||
blobs:
|
||||
|
||||
shimmer:
|
||||
|
||||
flex_color_picker:
|
||||
|
||||
hexcolor:
|
||||
|
||||
dynamic_color:
|
||||
|
|
|
|||
Reference in a new issue