first commit

This commit is contained in:
Leandro 2024-05-17 23:46:30 +02:00
commit 39e38f931f
382 changed files with 520450 additions and 0 deletions

56
lib/database.dart Normal file
View file

@ -0,0 +1,56 @@
import 'package:drift/drift.dart';
import 'dart:io';
import 'package:drift/native.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart' as p;
import 'package:sqlite3/sqlite3.dart';
import 'package:sqlite3_flutter_libs/sqlite3_flutter_libs.dart';
part 'database.g.dart';
class Wolle extends Table {
IntColumn get id => integer().autoIncrement()();
TextColumn get manufacture => text()();
TextColumn get title => text()();
TextColumn get color => text().withLength(min: 7, max: 7)();
}
class TempRange extends Table {
IntColumn get id => integer().autoIncrement()();
RealColumn get min => real()();
RealColumn get max => real()();
IntColumn get wolle => integer().references(Wolle, #id)();
}
@DriftDatabase(tables: [Wolle, TempRange])
class AppDatabase extends _$AppDatabase {
AppDatabase() : super(_openConnection());
@override
int get schemaVersion => 1;
}
LazyDatabase _openConnection() {
// the LazyDatabase util lets us find the right location for the file async.
return LazyDatabase(() async {
// put the database file, called db.sqlite here, into the documents folder
// for your app.
final dbFolder = await getApplicationDocumentsDirectory();
final file = File(p.join(dbFolder.path, 'db.sqlite'));
// Also work around limitations on old Android versions
if (Platform.isAndroid) {
await applyWorkaroundToOpenSqlite3OnOldAndroidVersions();
}
// Make sqlite3 pick a more suitable location for temporary files - the
// one from the system may be inaccessible due to sandboxing.
final cachebase = (await getTemporaryDirectory()).path;
// We can't access /tmp on Android, which sqlite3 would try by default.
// Explicitly tell it about the correct temporary directory.
sqlite3.tempDirectory = cachebase;
return NativeDatabase.createInBackground(file);
});
}

514
lib/database.g.dart Normal file
View file

@ -0,0 +1,514 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'database.dart';
// ignore_for_file: type=lint
class $WolleTable extends Wolle with TableInfo<$WolleTable, WolleData> {
@override
final GeneratedDatabase attachedDatabase;
final String? _alias;
$WolleTable(this.attachedDatabase, [this._alias]);
static const VerificationMeta _idMeta = const VerificationMeta('id');
@override
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
static const VerificationMeta _manufactureMeta =
const VerificationMeta('manufacture');
@override
late final GeneratedColumn<String> manufacture = GeneratedColumn<String>(
'manufacture', aliasedName, false,
type: DriftSqlType.string, requiredDuringInsert: true);
static const VerificationMeta _titleMeta = const VerificationMeta('title');
@override
late final GeneratedColumn<String> title = GeneratedColumn<String>(
'title', aliasedName, false,
type: DriftSqlType.string, requiredDuringInsert: true);
static const VerificationMeta _colorMeta = const VerificationMeta('color');
@override
late final GeneratedColumn<String> color = GeneratedColumn<String>(
'color', aliasedName, false,
additionalChecks:
GeneratedColumn.checkTextLength(minTextLength: 7, maxTextLength: 7),
type: DriftSqlType.string,
requiredDuringInsert: true);
@override
List<GeneratedColumn> get $columns => [id, manufacture, title, color];
@override
String get aliasedName => _alias ?? actualTableName;
@override
String get actualTableName => $name;
static const String $name = 'wolle';
@override
VerificationContext validateIntegrity(Insertable<WolleData> instance,
{bool isInserting = false}) {
final context = VerificationContext();
final data = instance.toColumns(true);
if (data.containsKey('id')) {
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
}
if (data.containsKey('manufacture')) {
context.handle(
_manufactureMeta,
manufacture.isAcceptableOrUnknown(
data['manufacture']!, _manufactureMeta));
} else if (isInserting) {
context.missing(_manufactureMeta);
}
if (data.containsKey('title')) {
context.handle(
_titleMeta, title.isAcceptableOrUnknown(data['title']!, _titleMeta));
} else if (isInserting) {
context.missing(_titleMeta);
}
if (data.containsKey('color')) {
context.handle(
_colorMeta, color.isAcceptableOrUnknown(data['color']!, _colorMeta));
} else if (isInserting) {
context.missing(_colorMeta);
}
return context;
}
@override
Set<GeneratedColumn> get $primaryKey => {id};
@override
WolleData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return WolleData(
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
manufacture: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}manufacture'])!,
title: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
color: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}color'])!,
);
}
@override
$WolleTable createAlias(String alias) {
return $WolleTable(attachedDatabase, alias);
}
}
class WolleData extends DataClass implements Insertable<WolleData> {
final int id;
final String manufacture;
final String title;
final String color;
const WolleData(
{required this.id,
required this.manufacture,
required this.title,
required this.color});
@override
Map<String, Expression> toColumns(bool nullToAbsent) {
final map = <String, Expression>{};
map['id'] = Variable<int>(id);
map['manufacture'] = Variable<String>(manufacture);
map['title'] = Variable<String>(title);
map['color'] = Variable<String>(color);
return map;
}
WolleCompanion toCompanion(bool nullToAbsent) {
return WolleCompanion(
id: Value(id),
manufacture: Value(manufacture),
title: Value(title),
color: Value(color),
);
}
factory WolleData.fromJson(Map<String, dynamic> json,
{ValueSerializer? serializer}) {
serializer ??= driftRuntimeOptions.defaultSerializer;
return WolleData(
id: serializer.fromJson<int>(json['id']),
manufacture: serializer.fromJson<String>(json['manufacture']),
title: serializer.fromJson<String>(json['title']),
color: serializer.fromJson<String>(json['color']),
);
}
@override
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
serializer ??= driftRuntimeOptions.defaultSerializer;
return <String, dynamic>{
'id': serializer.toJson<int>(id),
'manufacture': serializer.toJson<String>(manufacture),
'title': serializer.toJson<String>(title),
'color': serializer.toJson<String>(color),
};
}
WolleData copyWith(
{int? id, String? manufacture, String? title, String? color}) =>
WolleData(
id: id ?? this.id,
manufacture: manufacture ?? this.manufacture,
title: title ?? this.title,
color: color ?? this.color,
);
@override
String toString() {
return (StringBuffer('WolleData(')
..write('id: $id, ')
..write('manufacture: $manufacture, ')
..write('title: $title, ')
..write('color: $color')
..write(')'))
.toString();
}
@override
int get hashCode => Object.hash(id, manufacture, title, color);
@override
bool operator ==(Object other) =>
identical(this, other) ||
(other is WolleData &&
other.id == this.id &&
other.manufacture == this.manufacture &&
other.title == this.title &&
other.color == this.color);
}
class WolleCompanion extends UpdateCompanion<WolleData> {
final Value<int> id;
final Value<String> manufacture;
final Value<String> title;
final Value<String> color;
const WolleCompanion({
this.id = const Value.absent(),
this.manufacture = const Value.absent(),
this.title = const Value.absent(),
this.color = const Value.absent(),
});
WolleCompanion.insert({
this.id = const Value.absent(),
required String manufacture,
required String title,
required String color,
}) : manufacture = Value(manufacture),
title = Value(title),
color = Value(color);
static Insertable<WolleData> custom({
Expression<int>? id,
Expression<String>? manufacture,
Expression<String>? title,
Expression<String>? color,
}) {
return RawValuesInsertable({
if (id != null) 'id': id,
if (manufacture != null) 'manufacture': manufacture,
if (title != null) 'title': title,
if (color != null) 'color': color,
});
}
WolleCompanion copyWith(
{Value<int>? id,
Value<String>? manufacture,
Value<String>? title,
Value<String>? color}) {
return WolleCompanion(
id: id ?? this.id,
manufacture: manufacture ?? this.manufacture,
title: title ?? this.title,
color: color ?? this.color,
);
}
@override
Map<String, Expression> toColumns(bool nullToAbsent) {
final map = <String, Expression>{};
if (id.present) {
map['id'] = Variable<int>(id.value);
}
if (manufacture.present) {
map['manufacture'] = Variable<String>(manufacture.value);
}
if (title.present) {
map['title'] = Variable<String>(title.value);
}
if (color.present) {
map['color'] = Variable<String>(color.value);
}
return map;
}
@override
String toString() {
return (StringBuffer('WolleCompanion(')
..write('id: $id, ')
..write('manufacture: $manufacture, ')
..write('title: $title, ')
..write('color: $color')
..write(')'))
.toString();
}
}
class $TempRangeTable extends TempRange
with TableInfo<$TempRangeTable, TempRangeData> {
@override
final GeneratedDatabase attachedDatabase;
final String? _alias;
$TempRangeTable(this.attachedDatabase, [this._alias]);
static const VerificationMeta _idMeta = const VerificationMeta('id');
@override
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
static const VerificationMeta _minMeta = const VerificationMeta('min');
@override
late final GeneratedColumn<double> min = GeneratedColumn<double>(
'min', aliasedName, false,
type: DriftSqlType.double, requiredDuringInsert: true);
static const VerificationMeta _maxMeta = const VerificationMeta('max');
@override
late final GeneratedColumn<double> max = GeneratedColumn<double>(
'max', aliasedName, false,
type: DriftSqlType.double, requiredDuringInsert: true);
static const VerificationMeta _wolleMeta = const VerificationMeta('wolle');
@override
late final GeneratedColumn<int> wolle = GeneratedColumn<int>(
'wolle', aliasedName, false,
type: DriftSqlType.int,
requiredDuringInsert: true,
defaultConstraints:
GeneratedColumn.constraintIsAlways('REFERENCES wolle (id)'));
@override
List<GeneratedColumn> get $columns => [id, min, max, wolle];
@override
String get aliasedName => _alias ?? actualTableName;
@override
String get actualTableName => $name;
static const String $name = 'temp_range';
@override
VerificationContext validateIntegrity(Insertable<TempRangeData> instance,
{bool isInserting = false}) {
final context = VerificationContext();
final data = instance.toColumns(true);
if (data.containsKey('id')) {
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
}
if (data.containsKey('min')) {
context.handle(
_minMeta, min.isAcceptableOrUnknown(data['min']!, _minMeta));
} else if (isInserting) {
context.missing(_minMeta);
}
if (data.containsKey('max')) {
context.handle(
_maxMeta, max.isAcceptableOrUnknown(data['max']!, _maxMeta));
} else if (isInserting) {
context.missing(_maxMeta);
}
if (data.containsKey('wolle')) {
context.handle(
_wolleMeta, wolle.isAcceptableOrUnknown(data['wolle']!, _wolleMeta));
} else if (isInserting) {
context.missing(_wolleMeta);
}
return context;
}
@override
Set<GeneratedColumn> get $primaryKey => {id};
@override
TempRangeData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return TempRangeData(
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
min: attachedDatabase.typeMapping
.read(DriftSqlType.double, data['${effectivePrefix}min'])!,
max: attachedDatabase.typeMapping
.read(DriftSqlType.double, data['${effectivePrefix}max'])!,
wolle: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}wolle'])!,
);
}
@override
$TempRangeTable createAlias(String alias) {
return $TempRangeTable(attachedDatabase, alias);
}
}
class TempRangeData extends DataClass implements Insertable<TempRangeData> {
final int id;
final double min;
final double max;
final int wolle;
const TempRangeData(
{required this.id,
required this.min,
required this.max,
required this.wolle});
@override
Map<String, Expression> toColumns(bool nullToAbsent) {
final map = <String, Expression>{};
map['id'] = Variable<int>(id);
map['min'] = Variable<double>(min);
map['max'] = Variable<double>(max);
map['wolle'] = Variable<int>(wolle);
return map;
}
TempRangeCompanion toCompanion(bool nullToAbsent) {
return TempRangeCompanion(
id: Value(id),
min: Value(min),
max: Value(max),
wolle: Value(wolle),
);
}
factory TempRangeData.fromJson(Map<String, dynamic> json,
{ValueSerializer? serializer}) {
serializer ??= driftRuntimeOptions.defaultSerializer;
return TempRangeData(
id: serializer.fromJson<int>(json['id']),
min: serializer.fromJson<double>(json['min']),
max: serializer.fromJson<double>(json['max']),
wolle: serializer.fromJson<int>(json['wolle']),
);
}
@override
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
serializer ??= driftRuntimeOptions.defaultSerializer;
return <String, dynamic>{
'id': serializer.toJson<int>(id),
'min': serializer.toJson<double>(min),
'max': serializer.toJson<double>(max),
'wolle': serializer.toJson<int>(wolle),
};
}
TempRangeData copyWith({int? id, double? min, double? max, int? wolle}) =>
TempRangeData(
id: id ?? this.id,
min: min ?? this.min,
max: max ?? this.max,
wolle: wolle ?? this.wolle,
);
@override
String toString() {
return (StringBuffer('TempRangeData(')
..write('id: $id, ')
..write('min: $min, ')
..write('max: $max, ')
..write('wolle: $wolle')
..write(')'))
.toString();
}
@override
int get hashCode => Object.hash(id, min, max, wolle);
@override
bool operator ==(Object other) =>
identical(this, other) ||
(other is TempRangeData &&
other.id == this.id &&
other.min == this.min &&
other.max == this.max &&
other.wolle == this.wolle);
}
class TempRangeCompanion extends UpdateCompanion<TempRangeData> {
final Value<int> id;
final Value<double> min;
final Value<double> max;
final Value<int> wolle;
const TempRangeCompanion({
this.id = const Value.absent(),
this.min = const Value.absent(),
this.max = const Value.absent(),
this.wolle = const Value.absent(),
});
TempRangeCompanion.insert({
this.id = const Value.absent(),
required double min,
required double max,
required int wolle,
}) : min = Value(min),
max = Value(max),
wolle = Value(wolle);
static Insertable<TempRangeData> custom({
Expression<int>? id,
Expression<double>? min,
Expression<double>? max,
Expression<int>? wolle,
}) {
return RawValuesInsertable({
if (id != null) 'id': id,
if (min != null) 'min': min,
if (max != null) 'max': max,
if (wolle != null) 'wolle': wolle,
});
}
TempRangeCompanion copyWith(
{Value<int>? id,
Value<double>? min,
Value<double>? max,
Value<int>? wolle}) {
return TempRangeCompanion(
id: id ?? this.id,
min: min ?? this.min,
max: max ?? this.max,
wolle: wolle ?? this.wolle,
);
}
@override
Map<String, Expression> toColumns(bool nullToAbsent) {
final map = <String, Expression>{};
if (id.present) {
map['id'] = Variable<int>(id.value);
}
if (min.present) {
map['min'] = Variable<double>(min.value);
}
if (max.present) {
map['max'] = Variable<double>(max.value);
}
if (wolle.present) {
map['wolle'] = Variable<int>(wolle.value);
}
return map;
}
@override
String toString() {
return (StringBuffer('TempRangeCompanion(')
..write('id: $id, ')
..write('min: $min, ')
..write('max: $max, ')
..write('wolle: $wolle')
..write(')'))
.toString();
}
}
abstract class _$AppDatabase extends GeneratedDatabase {
_$AppDatabase(QueryExecutor e) : super(e);
late final $WolleTable wolle = $WolleTable(this);
late final $TempRangeTable tempRange = $TempRangeTable(this);
@override
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities => [wolle, tempRange];
}

29
lib/db_test.dart Normal file
View file

@ -0,0 +1,29 @@
import 'package:drift/drift.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:temperaturdecke/database.dart';
void addWool(BuildContext context) async {
try {
AppDatabase db = Provider.of<AppDatabase>(context, listen: false);
db.into(db.wolle).insert(WolleCompanion.insert(
title: 'Kakapo',
color: '#00FF05',
manufacture: 'test',
));
} catch (e) {
// Fehlerbehandlung hier
print('Fehler beim Einfügen: $e');
}
}
void removeWool(BuildContext context, int dId) async {
try {
AppDatabase db = Provider.of<AppDatabase>(context, listen: false);
(db.delete(db.wolle)..where((t) => t.id.isValue(dId))).go();
} catch (e) {
print('Fehler beim Einfügen: $e');
}
}

113
lib/main.dart Normal file
View file

@ -0,0 +1,113 @@
import 'package:drift/drift.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:temperaturdecke/database.dart';
import 'package:temperaturdecke/screens/day.dart';
import 'package:temperaturdecke/screens/overview.dart';
import 'package:temperaturdecke/screens/settings.dart';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:temperaturdecke/screens/wool.dart';
void main() async {
runApp(Provider<AppDatabase>(
create: (context) => AppDatabase(),
child: MyApp(),
dispose: (context, db) => db.close(),
));
WidgetsFlutterBinding.ensureInitialized();
}
class MyApp extends StatefulWidget {
MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
int currentPageIndex = 0;
List screens = [
dayScreen(),
OverviewScreen(),
WoolScreen(),
SettingsScreen(),
];
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return DynamicColorBuilder(
builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) {
ColorScheme lightColorScheme;
ColorScheme darkColorScheme;
if (lightDynamic != null && darkDynamic != null) {
// On Android S+ devices, use the provided dynamic color scheme.
// (Recommended) Harmonize the dynamic color scheme' built-in semantic colors.
lightColorScheme = lightDynamic.harmonized();
// Repeat for the dark color scheme.
darkColorScheme = darkDynamic.harmonized();
} else {
// Otherwise, use fallback schemes.
lightColorScheme = ColorScheme.fromSeed(
seedColor: Colors.blue,
);
darkColorScheme = ColorScheme.fromSeed(
seedColor: Colors.blue,
brightness: Brightness.dark,
);
}
return MaterialApp(
theme: ThemeData(useMaterial3: true, colorScheme: darkColorScheme),
title: 'Flutter Demo',
home: Scaffold(
body: AnimatedSwitcher(
duration: Duration(milliseconds: 200),
child: screens[currentPageIndex],
),
bottomNavigationBar: NavigationBar(
onDestinationSelected: (int index) {
print(currentPageIndex);
setState(() {
currentPageIndex = index;
});
},
selectedIndex: currentPageIndex,
destinations: const <Widget>[
NavigationDestination(
icon: Icon(Icons.sunny),
label: 'Tag',
),
NavigationDestination(
icon: Icon(Icons.list),
label: 'Übersicht',
),
NavigationDestination(
icon: Icon(Icons.circle),
label: 'Wolle',
),
NavigationDestination(
icon: Icon(Icons.settings),
label: 'Einstellungen',
),
],
),
),
);
});
}
}
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return dayScreen();
}

27
lib/screens/day.dart Normal file
View file

@ -0,0 +1,27 @@
import 'package:blobs/blobs.dart';
import 'package:flutter/material.dart';
import 'package:temperaturdecke/widgets/cards/overview_card.dart';
import 'package:temperaturdecke/widgets/daily_blob.dart';
class dayScreen extends StatelessWidget {
const dayScreen({super.key});
@override
Widget build(BuildContext context) {
final blobLayoutSize = const Size(400, 400);
Size area = Size(20, 20);
return Scaffold(
body: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Center(
child: Dailyblob(20),
)
],
),
));
}
}

27
lib/screens/overview.dart Normal file
View file

@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
import 'package:temperaturdecke/widgets/custom_card.dart';
class OverviewScreen extends StatelessWidget {
const OverviewScreen({super.key});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(10.0),
child: CustomCard(Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
"Übersicht",
style: Theme.of(context).textTheme.headlineMedium,
),
const Text("Blubb"),
],
),
)),
);
}
}

27
lib/screens/settings.dart Normal file
View file

@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:temperaturdecke/database.dart';
import 'package:temperaturdecke/db_test.dart';
import 'package:temperaturdecke/screens/wool.dart';
class SettingsScreen extends StatelessWidget {
const SettingsScreen({super.key});
@override
Widget build(BuildContext context) {
return AccentColorExample();
}
}
// Colors
class AccentColorExample extends StatelessWidget {
const AccentColorExample({Key? key}) : super(key: key);
static const title = 'Accent color (desktop)';
@override
Widget build(BuildContext context) {
return Placeholder();
}
}

54
lib/screens/wool.dart Normal file
View file

@ -0,0 +1,54 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:temperaturdecke/database.dart';
import 'package:temperaturdecke/widgets/cards/wool_card.dart';
class WoolScreen extends StatelessWidget {
WoolScreen({super.key});
int currentScreen = 1;
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: Provider.of<AppDatabase>(context)
.select(Provider.of<AppDatabase>(context).wolle)
.get(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(),
);
} else {
// Hier können Sie den Inhalt basierend auf den geladenen Daten anzeigen
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,
)
],
),
);
},
itemCount: snapshot.data.length,
),
),
],
);
}
},
);
}
}

View file

@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import 'package:temperaturdecke/db_test.dart';
class WoolModal extends StatelessWidget {
WoolModal(this.woolId, {super.key});
int woolId;
@override
Widget build(BuildContext context) {
return ClipRRect(
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
child: SizedBox(
width: 750,
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
children: [
TextButton(
onPressed: () {
removeWool(context, woolId);
},
child: Text("Löschen"),
style: ButtonStyle(
minimumSize:
WidgetStateProperty.all(Size(double.maxFinite, 70))),
),
],
),
),
),
);
}
}

View file

@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
class Overviewcard extends StatelessWidget {
Overviewcard(this.temperatur, {super.key});
Color mainColor = Colors.red;
int temperatur = 15;
@override
Widget build(BuildContext context) {
return Placeholder();
}
}

View file

@ -0,0 +1,55 @@
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:temperaturdecke/screens/wool_modal.dart';
import 'package:temperaturdecke/widgets/custom_card.dart';
class Woolcard extends StatelessWidget {
Woolcard(this.id, this.manufacture, this.title, this.color, {super.key});
int id;
String manufacture;
String title;
String color;
@override
Widget build(BuildContext context) {
return CustomCard(Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Container(
height: 70,
width: 30,
color: HexColor(color),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: [
Text(title),
Text(manufacture),
],
),
),
],
),
Padding(
padding: const EdgeInsets.all(10.0),
child: IconButton(
onPressed: () {
showModalBottomSheet(
context: context,
builder: (context) {
return WoolModal(id);
},
);
},
icon: Icon(Icons.more_vert),
alignment: Alignment.centerRight,
),
)
],
));
}
}

View file

@ -0,0 +1,23 @@
import 'package:flutter/material.dart';
class CustomCard extends StatelessWidget {
CustomCard(this.child, {super.key});
Widget child;
double radius = 20;
@override
Widget build(BuildContext context) {
return ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(radius)),
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.secondaryContainer,
borderRadius: BorderRadius.all(Radius.circular(radius)),
),
child: child,
),
);
}
}

140
lib/widgets/daily_blob.dart Normal file
View file

@ -0,0 +1,140 @@
import 'package:blobs/blobs.dart';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/material.dart';
class Dailyblob extends StatelessWidget {
Dailyblob(this.temperatur, {super.key});
int temperatur;
Color mainColor = Color.fromARGB(255, 233, 125, 224);
@override
Widget build(BuildContext context) {
Color blobColor = mainColor.harmonizeWith(Theme.of(context).canvasColor);
Color grad1 = Color.fromARGB(
blobColor.alpha,
(blobColor.red * 0.85).round(),
(blobColor.green * 0.85).round(),
(blobColor.blue * 0.85).round(),
);
return Stack(
alignment: AlignmentDirectional.center,
children: [
Blob.animatedFromID(
loop: true,
duration: Duration(milliseconds: 1300),
size: 365,
styles: BlobStyles(
color: Color.fromARGB(
blobColor.alpha,
(blobColor.red * 0.8).round(),
(blobColor.green * 0.8).round(),
(blobColor.blue * 0.8).round(),
).harmonizeWith(blobColor)),
id: [
'6-9-12903',
'6-9-438',
'6-9-9807',
'6-9-18',
'6-9-9260',
'6-9-12903',
'6-9-17311',
],
),
Blob.animatedFromID(
loop: true,
duration: Duration(milliseconds: 1000),
size: 355,
styles: BlobStyles(
color: Color.fromARGB(
blobColor.alpha,
(blobColor.red * 0.9).round(),
(blobColor.green * 0.9).round(),
(blobColor.blue * 0.9).round(),
).harmonizeWith(blobColor)),
id: const [
'6-9-438',
'6-9-9807',
'6-9-18',
'6-9-9260',
'6-9-12903',
'6-9-17311'
],
),
Blob.animatedFromID(
loop: true,
duration: Duration(milliseconds: 1500),
size: 340,
styles: BlobStyles(color: blobColor),
id: const [
'6-9-17311',
'6-9-438',
'6-9-9807',
'6-9-18',
'6-9-9260',
'6-9-12903',
],
),
Column(
children: [
ShaderMask(
blendMode: BlendMode.srcIn,
shaderCallback: (Rect bounds) {
return LinearGradient(
colors: blobColor.computeLuminance() > 0.1
? [
Color.fromARGB(
blobColor.alpha,
(blobColor.red * 0.35).round(),
(blobColor.green * 0.35).round(),
(blobColor.blue * 0.35).round(),
),
Color.fromARGB(
blobColor.alpha,
(blobColor.red * 0.5).round(),
(blobColor.green * 0.5).round(),
(blobColor.blue * 0.5).round(),
)
]
: [
Color.fromARGB(
blobColor.alpha,
(blobColor.red * 2.2).round(),
(blobColor.green * 2.2).round(),
(blobColor.blue * 2.2).round(),
),
Color.fromARGB(
blobColor.alpha,
(blobColor.red * 1.8).round(),
(blobColor.green * 1.8).round(),
(blobColor.blue * 1.8).round(),
),
],
).createShader(bounds);
},
child: Column(
children: [
Text(
"$temperatur °C",
style: TextStyle(
height: 1,
fontSize: 25,
fontWeight: FontWeight.w600,
),
),
Text(
"Farbe",
style: TextStyle(
fontSize: 45,
fontWeight: FontWeight.w800,
),
)
],
)),
],
),
],
);
}
}

View file

@ -0,0 +1,10 @@
import 'package:flutter/material.dart';
class Overviewcard extends StatelessWidget {
const Overviewcard({super.key});
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}