changed the layout to the first wireframes

This commit is contained in:
reinjens 2024-10-21 15:01:20 +02:00
parent 201444ce30
commit 102f8de792
19 changed files with 440 additions and 436 deletions

2
.env Normal file
View file

@ -0,0 +1,2 @@
BASEROW_TOKEN="TFxO7vzBLVRCu9I3VMoHmTuCvSu8aCDi"
BASEROW_IDS='{"massnahmen": 328253, "massnahmenkombination": 328217, "organismen": 328255, "foerderprogramme": 328256, "factsheet": 328273, "standortansprueche": 328188, "referenzumsetzung": 328465, "betriebsverzeichnis": 328472, "erfahrungsbericht": 330802, "genehmigungspflicht": 330806, "dienstleister": 330824, "ansprechperson": 330832, "material": 330836, "quellen": 334231, "baumarten": 342622, "aenderungfactsheet": 330946}'

2
.env.example Normal file
View file

@ -0,0 +1,2 @@
BASEROWTOKEN='ENTER_THE_TOKEN_HERE'
BASEROW_IDS="{'massnahmen': 1, 'massnahmenkombination': 2, 'organismen': 3, 'foerderprogramme': 4, 'factsheet': 5, 'standortansprueche': 6, 'referenzumsetzung': 7, 'betriebsverzeichnis': 8, 'erfahrungsbericht': 9, 'genehmigungspflicht': 10, 'dienstleister': 11, 'ansprechperson': 12, 'material': 13, 'quellen': 14, 'baumarten': 15, 'aenderungfactsheet': 16,}"

View file

@ -1,9 +1,10 @@
import 'package:ambito/src/domain/entity/baumarten/baumarten.dart';
import 'package:ambito/src/domain/entity/massnahme/massnahme.dart';
import 'package:ambito/src/packages/ambito_api/base.dart';
import 'package:ambito/src/pages/start/start_page.dart';
import 'package:ambito/src/pages/loading/loading_page.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:get/get_navigation/src/root/get_material_app.dart';
@ -11,8 +12,6 @@ import 'package:isar/isar.dart';
import 'package:logger/logger.dart';
import 'package:syncfusion_localizations/syncfusion_localizations.dart';
const String ambitoToken = 'TFxO7vzBLVRCu9I3VMoHmTuCvSu8aCDi';
final Logger logger = Logger(
printer: PrettyPrinter(),
);
@ -22,6 +21,8 @@ late Isar isar;
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await dotenv.load(fileName: '.env');
await Isar.initialize();
const dir = Isar.sqliteInMemory;
const engine = kIsWeb ? IsarEngine.sqlite : IsarEngine.isar;
@ -32,7 +33,7 @@ void main() async {
inspector: true,
);
Future.wait([
await Future.wait([
BaseApi().getContent('baumarten'),
BaseApi().getContent('massnahmen'),
]);
@ -64,14 +65,14 @@ class Ambito extends StatelessWidget {
SfGlobalLocalizations.delegate,
],
title: 'Flutter Demo',
supportedLocales: [Locale('de')],
supportedLocales: const [Locale('de')],
locale: const Locale('de'),
builder: FlutterI18n.rootAppBuilder(),
theme: ThemeData(
scaffoldBackgroundColor: Colors.white,
useMaterial3: true,
),
home: const StartPage(),
home: const LoadingPage(),
);
}
}

View file

@ -1 +1,5 @@
class BaseEntity {}
mixin EntityWithId {
late int id;
}

View file

@ -9,10 +9,9 @@ part 'baumarten.g.dart';
@JsonSerializable(explicitToJson: true)
@collection
class Baumarten extends BaseEntity {
class Baumarten extends BaseEntity with EntityWithId {
Baumarten();
late int id;
@JsonKey(name: 'order')
String? orderString;
@JsonKey(name: 'Art')

View file

@ -498,7 +498,6 @@ int serializeBaumarten(IsarWriter writer, Baumarten object) {
@isarProtected
Baumarten deserializeBaumarten(IsarReader reader) {
final object = Baumarten();
object.id = IsarCore.readId(reader);
object.orderString = IsarCore.readString(reader, 1);
object.art = IsarCore.readString(reader, 2);
object.id2 = IsarCore.readString(reader, 3);
@ -731,14 +730,13 @@ Baumarten deserializeBaumarten(IsarReader reader) {
object.local = IsarCore.readBool(reader, 32);
}
}
object.id = IsarCore.readId(reader);
return object;
}
@isarProtected
dynamic deserializeBaumartenProp(IsarReader reader, int property) {
switch (property) {
case 0:
return IsarCore.readId(reader);
case 1:
return IsarCore.readString(reader, 1);
case 2:
@ -1004,6 +1002,8 @@ dynamic deserializeBaumartenProp(IsarReader reader, int property) {
return IsarCore.readBool(reader, 32);
}
}
case 0:
return IsarCore.readId(reader);
default:
throw ArgumentError('Unknown property: $property');
}
@ -1344,87 +1344,6 @@ extension BaumartenQueryBuilderUpdate
extension BaumartenQueryFilter
on QueryBuilder<Baumarten, Baumarten, QFilterCondition> {
QueryBuilder<Baumarten, Baumarten, QAfterFilterCondition> idEqualTo(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
EqualCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Baumarten, Baumarten, QAfterFilterCondition> idGreaterThan(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
GreaterCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Baumarten, Baumarten, QAfterFilterCondition>
idGreaterThanOrEqualTo(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
GreaterOrEqualCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Baumarten, Baumarten, QAfterFilterCondition> idLessThan(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
LessCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Baumarten, Baumarten, QAfterFilterCondition> idLessThanOrEqualTo(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
LessOrEqualCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Baumarten, Baumarten, QAfterFilterCondition> idBetween(
int lower,
int upper,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
BetweenCondition(
property: 0,
lower: lower,
upper: upper,
),
);
});
}
QueryBuilder<Baumarten, Baumarten, QAfterFilterCondition>
orderStringIsNull() {
return QueryBuilder.apply(this, (query) {
@ -5461,6 +5380,87 @@ extension BaumartenQueryFilter
);
});
}
QueryBuilder<Baumarten, Baumarten, QAfterFilterCondition> idEqualTo(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
EqualCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Baumarten, Baumarten, QAfterFilterCondition> idGreaterThan(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
GreaterCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Baumarten, Baumarten, QAfterFilterCondition>
idGreaterThanOrEqualTo(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
GreaterOrEqualCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Baumarten, Baumarten, QAfterFilterCondition> idLessThan(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
LessCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Baumarten, Baumarten, QAfterFilterCondition> idLessThanOrEqualTo(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
LessOrEqualCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Baumarten, Baumarten, QAfterFilterCondition> idBetween(
int lower,
int upper,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
BetweenCondition(
property: 0,
lower: lower,
upper: upper,
),
);
});
}
}
extension BaumartenQueryObject
@ -5502,18 +5502,6 @@ extension BaumartenQueryObject
}
extension BaumartenQuerySortBy on QueryBuilder<Baumarten, Baumarten, QSortBy> {
QueryBuilder<Baumarten, Baumarten, QAfterSortBy> sortById() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(0);
});
}
QueryBuilder<Baumarten, Baumarten, QAfterSortBy> sortByIdDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(0, sort: Sort.desc);
});
}
QueryBuilder<Baumarten, Baumarten, QAfterSortBy> sortByOrderString(
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
@ -5945,22 +5933,22 @@ extension BaumartenQuerySortBy on QueryBuilder<Baumarten, Baumarten, QSortBy> {
return query.addSortBy(32, sort: Sort.desc);
});
}
}
extension BaumartenQuerySortThenBy
on QueryBuilder<Baumarten, Baumarten, QSortThenBy> {
QueryBuilder<Baumarten, Baumarten, QAfterSortBy> thenById() {
QueryBuilder<Baumarten, Baumarten, QAfterSortBy> sortById() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(0);
});
}
QueryBuilder<Baumarten, Baumarten, QAfterSortBy> thenByIdDesc() {
QueryBuilder<Baumarten, Baumarten, QAfterSortBy> sortByIdDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(0, sort: Sort.desc);
});
}
}
extension BaumartenQuerySortThenBy
on QueryBuilder<Baumarten, Baumarten, QSortThenBy> {
QueryBuilder<Baumarten, Baumarten, QAfterSortBy> thenByOrderString(
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
@ -6252,6 +6240,18 @@ extension BaumartenQuerySortThenBy
return query.addSortBy(32, sort: Sort.desc);
});
}
QueryBuilder<Baumarten, Baumarten, QAfterSortBy> thenById() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(0);
});
}
QueryBuilder<Baumarten, Baumarten, QAfterSortBy> thenByIdDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(0, sort: Sort.desc);
});
}
}
extension BaumartenQueryWhereDistinct
@ -6405,12 +6405,6 @@ extension BaumartenQueryWhereDistinct
extension BaumartenQueryProperty1
on QueryBuilder<Baumarten, Baumarten, QProperty> {
QueryBuilder<Baumarten, int, QAfterProperty> idProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(0);
});
}
QueryBuilder<Baumarten, String?, QAfterProperty> orderStringProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(1);
@ -6609,16 +6603,16 @@ extension BaumartenQueryProperty1
return query.addProperty(32);
});
}
}
extension BaumartenQueryProperty2<R>
on QueryBuilder<Baumarten, R, QAfterProperty> {
QueryBuilder<Baumarten, (R, int), QAfterProperty> idProperty() {
QueryBuilder<Baumarten, int, QAfterProperty> idProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(0);
});
}
}
extension BaumartenQueryProperty2<R>
on QueryBuilder<Baumarten, R, QAfterProperty> {
QueryBuilder<Baumarten, (R, String?), QAfterProperty> orderStringProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(1);
@ -6825,16 +6819,16 @@ extension BaumartenQueryProperty2<R>
return query.addProperty(32);
});
}
}
extension BaumartenQueryProperty3<R1, R2>
on QueryBuilder<Baumarten, (R1, R2), QAfterProperty> {
QueryBuilder<Baumarten, (R1, R2, int), QOperations> idProperty() {
QueryBuilder<Baumarten, (R, int), QAfterProperty> idProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(0);
});
}
}
extension BaumartenQueryProperty3<R1, R2>
on QueryBuilder<Baumarten, (R1, R2), QAfterProperty> {
QueryBuilder<Baumarten, (R1, R2, String?), QOperations>
orderStringProperty() {
return QueryBuilder.apply(this, (query) {
@ -7043,6 +7037,12 @@ extension BaumartenQueryProperty3<R1, R2>
return query.addProperty(32);
});
}
QueryBuilder<Baumarten, (R1, R2, int), QOperations> idProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(0);
});
}
}
// **************************************************************************

View file

@ -15,10 +15,9 @@ part 'massnahme.g.dart';
@JsonSerializable(explicitToJson: true)
@collection
class Massnahme extends BaseEntity {
class Massnahme extends BaseEntity with EntityWithId {
Massnahme();
late int id;
@JsonKey(name: 'order')
String? orderString;
@JsonKey(name: 'Maßnahmenbezeichung')

View file

@ -1054,7 +1054,6 @@ int serializeMassnahme(IsarWriter writer, Massnahme object) {
@isarProtected
Massnahme deserializeMassnahme(IsarReader reader) {
final object = Massnahme();
object.id = IsarCore.readId(reader);
object.orderString = IsarCore.readString(reader, 1);
object.name = IsarCore.readString(reader, 2);
{
@ -1723,14 +1722,13 @@ Massnahme deserializeMassnahme(IsarReader reader) {
}
}
}
object.id = IsarCore.readId(reader);
return object;
}
@isarProtected
dynamic deserializeMassnahmeProp(IsarReader reader, int property) {
switch (property) {
case 0:
return IsarCore.readId(reader);
case 1:
return IsarCore.readString(reader, 1);
case 2:
@ -2472,6 +2470,8 @@ dynamic deserializeMassnahmeProp(IsarReader reader, int property) {
}
}
}
case 0:
return IsarCore.readId(reader);
default:
throw ArgumentError('Unknown property: $property');
}
@ -3028,87 +3028,6 @@ extension MassnahmeQueryBuilderUpdate
extension MassnahmeQueryFilter
on QueryBuilder<Massnahme, Massnahme, QFilterCondition> {
QueryBuilder<Massnahme, Massnahme, QAfterFilterCondition> idEqualTo(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
EqualCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Massnahme, Massnahme, QAfterFilterCondition> idGreaterThan(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
GreaterCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Massnahme, Massnahme, QAfterFilterCondition>
idGreaterThanOrEqualTo(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
GreaterOrEqualCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Massnahme, Massnahme, QAfterFilterCondition> idLessThan(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
LessCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Massnahme, Massnahme, QAfterFilterCondition> idLessThanOrEqualTo(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
LessOrEqualCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Massnahme, Massnahme, QAfterFilterCondition> idBetween(
int lower,
int upper,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
BetweenCondition(
property: 0,
lower: lower,
upper: upper,
),
);
});
}
QueryBuilder<Massnahme, Massnahme, QAfterFilterCondition>
orderStringIsNull() {
return QueryBuilder.apply(this, (query) {
@ -11025,6 +10944,87 @@ extension MassnahmeQueryFilter
);
});
}
QueryBuilder<Massnahme, Massnahme, QAfterFilterCondition> idEqualTo(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
EqualCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Massnahme, Massnahme, QAfterFilterCondition> idGreaterThan(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
GreaterCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Massnahme, Massnahme, QAfterFilterCondition>
idGreaterThanOrEqualTo(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
GreaterOrEqualCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Massnahme, Massnahme, QAfterFilterCondition> idLessThan(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
LessCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Massnahme, Massnahme, QAfterFilterCondition> idLessThanOrEqualTo(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
LessOrEqualCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Massnahme, Massnahme, QAfterFilterCondition> idBetween(
int lower,
int upper,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
BetweenCondition(
property: 0,
lower: lower,
upper: upper,
),
);
});
}
}
extension MassnahmeQueryObject
@ -11038,18 +11038,6 @@ extension MassnahmeQueryObject
}
extension MassnahmeQuerySortBy on QueryBuilder<Massnahme, Massnahme, QSortBy> {
QueryBuilder<Massnahme, Massnahme, QAfterSortBy> sortById() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(0);
});
}
QueryBuilder<Massnahme, Massnahme, QAfterSortBy> sortByIdDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(0, sort: Sort.desc);
});
}
QueryBuilder<Massnahme, Massnahme, QAfterSortBy> sortByOrderString(
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
@ -11838,22 +11826,22 @@ extension MassnahmeQuerySortBy on QueryBuilder<Massnahme, Massnahme, QSortBy> {
);
});
}
}
extension MassnahmeQuerySortThenBy
on QueryBuilder<Massnahme, Massnahme, QSortThenBy> {
QueryBuilder<Massnahme, Massnahme, QAfterSortBy> thenById() {
QueryBuilder<Massnahme, Massnahme, QAfterSortBy> sortById() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(0);
});
}
QueryBuilder<Massnahme, Massnahme, QAfterSortBy> thenByIdDesc() {
QueryBuilder<Massnahme, Massnahme, QAfterSortBy> sortByIdDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(0, sort: Sort.desc);
});
}
}
extension MassnahmeQuerySortThenBy
on QueryBuilder<Massnahme, Massnahme, QSortThenBy> {
QueryBuilder<Massnahme, Massnahme, QAfterSortBy> thenByOrderString(
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
@ -12383,6 +12371,18 @@ extension MassnahmeQuerySortThenBy
return query.addSortBy(62, sort: Sort.desc, caseSensitive: caseSensitive);
});
}
QueryBuilder<Massnahme, Massnahme, QAfterSortBy> thenById() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(0);
});
}
QueryBuilder<Massnahme, Massnahme, QAfterSortBy> thenByIdDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(0, sort: Sort.desc);
});
}
}
extension MassnahmeQueryWhereDistinct
@ -12655,12 +12655,6 @@ extension MassnahmeQueryWhereDistinct
extension MassnahmeQueryProperty1
on QueryBuilder<Massnahme, Massnahme, QProperty> {
QueryBuilder<Massnahme, int, QAfterProperty> idProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(0);
});
}
QueryBuilder<Massnahme, String?, QAfterProperty> orderStringProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(1);
@ -13075,16 +13069,16 @@ extension MassnahmeQueryProperty1
return query.addProperty(63);
});
}
}
extension MassnahmeQueryProperty2<R>
on QueryBuilder<Massnahme, R, QAfterProperty> {
QueryBuilder<Massnahme, (R, int), QAfterProperty> idProperty() {
QueryBuilder<Massnahme, int, QAfterProperty> idProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(0);
});
}
}
extension MassnahmeQueryProperty2<R>
on QueryBuilder<Massnahme, R, QAfterProperty> {
QueryBuilder<Massnahme, (R, String?), QAfterProperty> orderStringProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(1);
@ -13516,16 +13510,16 @@ extension MassnahmeQueryProperty2<R>
return query.addProperty(63);
});
}
}
extension MassnahmeQueryProperty3<R1, R2>
on QueryBuilder<Massnahme, (R1, R2), QAfterProperty> {
QueryBuilder<Massnahme, (R1, R2, int), QOperations> idProperty() {
QueryBuilder<Massnahme, (R, int), QAfterProperty> idProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(0);
});
}
}
extension MassnahmeQueryProperty3<R1, R2>
on QueryBuilder<Massnahme, (R1, R2), QAfterProperty> {
QueryBuilder<Massnahme, (R1, R2, String?), QOperations>
orderStringProperty() {
return QueryBuilder.apply(this, (query) {
@ -13961,6 +13955,12 @@ extension MassnahmeQueryProperty3<R1, R2>
return query.addProperty(63);
});
}
QueryBuilder<Massnahme, (R1, R2, int), QOperations> idProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(0);
});
}
}
// **************************************************************************

View file

@ -2,9 +2,10 @@ import 'dart:convert';
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:ambito/src/packages/ambito_api/restclient.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import '../../../main.dart';
import '../ambito_db/repositories/baumarten_repository.dart';
import '../ambito_db/repositories/massnahme_repository.dart';
Map<String, int> tables = {
'massnahmen': 328253,
@ -26,28 +27,29 @@ Map<String, int> tables = {
};
class BaseApi {
Map tables = {};
init() {
tables = jsonDecode(dotenv.get('BASEROW_IDS'));
}
Future<bool> getContent(String table) async {
init();
int tableId = tables[table] ?? 0;
if (tableId > 0) {
var response =
await RestClient().get('$tableId/?user_field_names=true&size=200');
if (response.statusCode == 200) {
var json = jsonDecode(utf8.decode(response.body.runes.toList()));
var json = _jsonDecoded(response.body);
switch (table) {
case 'baumarten':
for (var baumart in json['results']) {
BaseDB.put(Baumarten.fromJson(baumart));
isar.write((isar) {
isar.baumartens.put(Baumarten.fromJson(baumart));
});
BaumartenRepository().put(Baumarten.fromJson(baumart));
}
break;
case 'massnahmen':
for (var massnahme in json['results']) {
BaseDB.put(Massnahme.fromJson(massnahme));
isar.write((isar) {
isar.massnahmes.put(Massnahme.fromJson(massnahme));
});
MassnahmeRepository().put(Massnahme.fromJson(massnahme));
}
break;
}
@ -57,4 +59,8 @@ class BaseApi {
}
return false;
}
dynamic _jsonDecoded(String input) {
return jsonDecode(utf8.decode(input.runes.toList()));
}
}

View file

@ -4,6 +4,7 @@ import 'dart:async';
import 'dart:convert';
import 'package:ambito/main.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:http/http.dart' as http;
class RestClient {
@ -19,7 +20,7 @@ class RestClient {
var headers = {
"Content-Type": contentType,
"Accept": accept,
"Authorization": "Token $ambitoToken",
"Authorization": "Token ${dotenv.get('BASEROW_TOKEN')}",
};
return headers;
}

View file

@ -3,28 +3,26 @@ import 'package:isar/isar.dart';
import '../../../main.dart';
class BaseDB {
static put(var entity) {
switch (entity.runtimeType.toString()) {
case 'Baumarten':
isar.write((isar) {
isar.baumartens.put(entity);
});
break;
case 'Massnahme':
isar.write((isar) {
isar.massnahmes.put(entity);
});
break;
}
abstract class BaseDB {
abstract IsarCollection collection;
put(BaseEntity entity) {
isar.write((isar) {
collection.put(entity);
});
}
static getAll(String type) {
switch (type) {
case 'Maßnahme':
return isar.massnahmes.where().sortByName().findAll();
case 'Baumart':
return isar.baumartens.where().findAll();
}
putAll(List<BaseEntity> entities) {
isar.write((isar) {
collection.putAll(entities);
});
}
get(int id) {
return collection.get(id);
}
List<dynamic> getAll() {
return collection.where().findAll();
}
}

View file

@ -0,0 +1,9 @@
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:isar/isar.dart';
import '../../../../main.dart';
import '../base_db.dart';
class BaumartenRepository extends BaseDB {
IsarCollection collection = isar.baumartens;
}

View file

@ -0,0 +1,9 @@
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:isar/isar.dart';
import '../../../../main.dart';
class MassnahmeRepository extends BaseDB {
IsarCollection collection = isar.massnahmes;
}

View file

@ -1,7 +1,6 @@
import 'package:ambito/src/domain/entity/id_value_color/id_value_color.dart';
import 'package:ambito/src/domain/entity/massnahme/massnahme.dart';
import 'package:ambito/src/extensions/extensions.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:ambito/src/packages/ambito_db/repositories/massnahme_repository.dart';
import 'package:ambito/src/widgets/form/fields/field_dropdown.dart';
import 'package:ambito/src/widgets/form/fields/field_monthsrangepicker.dart';
import 'package:ambito/src/widgets/form/form_widget.dart';
@ -33,10 +32,12 @@ class ActionsPageState extends State<ActionsPage> {
Set<String> support = {};
String? filterMonths;
Set<String> months = {};
List massnahmen = [];
@override
void initState() {
super.initState();
massnahmen = MassnahmeRepository().getAll();
effort = [];
effect = [];
type = {};
@ -45,61 +46,53 @@ class ActionsPageState extends State<ActionsPage> {
support = {};
}
@override
Widget build(BuildContext context) {
List<Massnahme> massnahmen = BaseDB.getAll('Maßnahme');
Set<String> updatedTypes = {};
Set<String> updatedAreaTypes = {};
Set<String> updatedSupports = {};
Set<String> updatedMonths = {};
// Step 1: Collect all distinct values in each Set in a single loop
final updatedTypes = <String>{};
final updatedAreaTypes = <String>{};
final updatedSupports = <String>{};
final updatedMonths = <String>{};
for (var massnahme in massnahmen) {
if (massnahme.actionGroup != null) {
for (final massnahme in massnahmen) {
if (massnahme.actionGroup?.value != null) {
updatedTypes.add(massnahme.actionGroup!.value!);
}
if (massnahme.factsheetAreaType != null) {
for (IdValueColor aType in massnahme.factsheetAreaType!) {
updatedAreaTypes.add(aType.value!);
}
}
if (massnahme.fundingPrograms != null) {
for (IdValueColor aType in massnahme.fundingPrograms!) {
updatedSupports.add(aType.value!);
}
}
if (massnahme.timeFrame != null) {
logger.d(massnahme.timeFrame);
for (IdValueColor tfType in massnahme.timeFrame!) {
updatedMonths.add(tfType.value!);
}
}
massnahme.factsheetAreaType?.forEach((aType) {
updatedAreaTypes.add(aType.value!);
});
massnahme.fundingPrograms?.forEach((aType) {
updatedSupports.add(aType.value!);
});
massnahme.timeFrame?.forEach((tfType) {
updatedMonths.add(tfType.value!);
});
}
logger.d(updatedMonths);
// Step 2: Update state with collected data in a single setState() call
setState(() {
type.addAll(updatedTypes);
areaType.addAll(updatedAreaTypes);
support.addAll(updatedSupports);
months.addAll(updatedMonths.toList());
months.addAll(updatedMonths);
});
List<Widget> actionCards = massnahmen.map((massnahme) {
bool typeMatches = filterType == null ||
(massnahme.actionGroup != null &&
massnahme.actionGroup!.value == filterType);
bool areaTypeMatches = filterAreaType == null ||
// Step 3: Generate the list of action cards with matching filters
final actionCards = massnahmen.map((massnahme) {
final typeMatches =
filterType == null || massnahme.actionGroup?.value == filterType;
final areaTypeMatches = filterAreaType == null ||
(massnahme.factsheetAreaType
?.any((aType) => aType.value == filterAreaType) ??
false);
bool supportMatches = filterSupport == null ||
final supportMatches = filterSupport == null ||
(massnahme.fundingPrograms
?.any((aType) => aType.value == filterSupport) ??
false);
// Update visibility based on the matches
// Update visibility in a single batch setState()
setState(() {
visible[massnahme.id] =
typeMatches && areaTypeMatches && supportMatches;
@ -108,8 +101,9 @@ class ActionsPageState extends State<ActionsPage> {
return getCard(context, massnahme);
}).toList();
// Step 4: Return UI widget structure
return Padding(
padding: const EdgeInsets.only(left: 32, right: 32),
padding: const EdgeInsets.symmetric(horizontal: 32),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -126,19 +120,13 @@ class ActionsPageState extends State<ActionsPage> {
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
width: 300,
child: getFilter(context),
),
const SizedBox(
width: 16,
),
SizedBox(width: 300, child: getFilter(context)),
const SizedBox(width: 16),
Expanded(
child: SingleChildScrollView(
child: Wrap(
direction: Axis.horizontal,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: actionCards,
),
),
@ -225,101 +213,20 @@ class ActionsPageState extends State<ActionsPage> {
.add(FlutterI18n.translate(context, 'general.lists.months.$i'));
}
/*var monthsSorted = months.toList();
monthsSorted.sort((a, b) => a.toLowerCase().compareTo(b.toLowerCase()));*/
/*fields.add(
FieldDropdown(
name: 'months',
label: 'Beginn der Maßnahme',
filterValue: filterMonths,
onClear: () {
setState(() {
filterMonths = null;
});
},
onSelected: ((String? value) {
setState(() {
filterMonths = value;
});
}),
entries: monthsSorted,
),
);*/
logger.d(monthsSorted);
fields.add(
FieldMonthsRangepicker(
name: 'months',
label: 'Beginn der Maßnahme',
filterValue: filterMonths,
onClear: () {},
onSelected: (String? value) {},
onSelected: (String? value) {
logger.d(value);
},
entries: monthsSorted,
),
);
return FormWidget(type: FormWidgetType.vertical, fields: fields);
/*return Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
DropdownMenuWidget(
formKey: _keyAreaType,
label: 'Ort der Maßnahme',
controller: _controllerAreaType,
filterValue: filterAreaType,
onClear: () {
setState(() {
filterAreaType = null;
});
_controllerAreaType.clear();
},
onSelected: (String? selection) {
setState(() {
filterAreaType = selection;
});
},
entries: areaType.toList(),
),
DropdownMenuWidget(
formKey: _keyType,
label: 'Art der Maßnahme',
controller: _controllerType,
filterValue: filterType,
onClear: () {
setState(() {
filterType = null;
});
_controllerType.clear();
},
onSelected: (String? selection) {
setState(() {
filterType = selection;
});
},
entries: type.toList(),
),
DropdownMenuWidget(
formKey: _keySupport,
label: 'Förderprogramm',
controller: _controllerSupport,
filterValue: filterSupport,
onClear: () {
setState(() {
filterSupport = null;
});
_controllerSupport.clear();
},
onSelected: (String? selection) {
setState(() {
filterSupport = selection;
});
},
entries: support.toList(),
),
],
);*/
}
Widget getCard(BuildContext context, Massnahme massnahme) {
@ -340,27 +247,41 @@ class ActionsPageState extends State<ActionsPage> {
return Visibility(
visible: visible[massnahme.id] ?? false,
child: SizedBox(
width: 400,
width: 800,
child: Card(
color: background,
child: Padding(
padding: const EdgeInsets.all(32),
child: Column(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (image != null) image,
(image != null)
? image
: const SizedBox(
width: 300,
height: 140,
),
const SizedBox(
height: 8,
width: 16,
),
Text(massnahme.name!,
style: Theme.of(context).textTheme.headlineSmall),
const SizedBox(
height: 8,
),
ExpandableText(
massnahme.factsheetDefinition ?? '',
maxLines: 3,
expandText: 'mehr',
collapseText: 'weniger',
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(massnahme.name!,
style: Theme.of(context).textTheme.headlineSmall),
const SizedBox(
height: 8,
),
ExpandableText(
massnahme.factsheetDefinition ?? '',
maxLines: 3,
expandText: 'mehr',
collapseText: 'weniger',
)
],
),
)
],
),

View file

@ -0,0 +1,39 @@
import 'package:ambito/src/pages/start/start_page.dart';
import 'package:flutter/material.dart';
class LoadingPage extends StatelessWidget {
const LoadingPage({super.key});
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: Future.delayed(
const Duration(seconds: 1),
() {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) {
return const StartPage();
},
),
(route) => false,
);
},
),
builder: (context, snapshot) {
if (snapshot.connectionState != ConnectionState.done) {
return Center(
child: Hero(
tag: 'logo',
child: Image.asset('assets/images/logo_trans.png')),
);
}
return Center(
child: Hero(
tag: 'logo', child: Image.asset('assets/images/logo_trans.png')),
);
},
);
}
}

View file

@ -32,9 +32,13 @@ class StartPageState extends State<StartPage> {
const SizedBox(
width: 30,
),
Image.asset(
'images/logo.png',
scale: .8,
Hero(
tag: 'logo',
child: Image.asset(
'assets/images/logo_trans.png',
width: 50,
height: 50,
),
),
const SizedBox(
width: 30,

View file

@ -26,10 +26,10 @@ packages:
dependency: transitive
description:
name: args
sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a"
sha256: bf9f5caeea8d8fe6721a9c358dd8a5c1947b27f1cfaa18b39c301273594919e6
url: "https://pub.dev"
source: hosted
version: "2.5.0"
version: "2.6.0"
async:
dependency: transitive
description:
@ -323,14 +323,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.8.0"
flutter_dotenv:
dependency: "direct main"
description:
name: flutter_dotenv
sha256: b7c7be5cd9f6ef7a78429cabd2774d3c4af50e79cb2b7593e3d5d763ef95c61b
url: "https://pub.dev"
source: hosted
version: "5.2.1"
flutter_form_builder:
dependency: "direct main"
description:
name: flutter_form_builder
sha256: b42ad8a9b3e8a629eb0fee8e4feaf7c2862fc40808ebf9f7ddc9da798e890136
sha256: c278ef69b08957d484f83413f0e77b656a39b7a7bb4eb8a295da3a820ecc6545
url: "https://pub.dev"
source: hosted
version: "9.4.1"
version: "9.5.0"
flutter_i18n:
dependency: "direct main"
description:
@ -1011,26 +1019,26 @@ packages:
dependency: transitive
description:
name: syncfusion_flutter_core
sha256: "7130fc3259247946b59fe9b76ee89500c775c3f7e5c1d0826f3105e1dd0bebf6"
sha256: becd190595cba56feac5ec17b805b35df9f006171c131c209f79b5c58fc780eb
url: "https://pub.dev"
source: hosted
version: "27.1.52"
version: "27.1.53"
syncfusion_flutter_datepicker:
dependency: "direct main"
description:
name: syncfusion_flutter_datepicker
sha256: "61efc09e962d7b7cc3c7d33a2e44ec027112403af49590d5cc1025a255cc34fa"
sha256: "5638805bea1c70a6d46dea9d39ef67f0085176e1c15cf57f7036cf67c1568816"
url: "https://pub.dev"
source: hosted
version: "27.1.52"
version: "27.1.53"
syncfusion_localizations:
dependency: "direct main"
description:
name: syncfusion_localizations
sha256: d04b86990411e1f0c896e273bbdb312b1ed52d8009010ddc2af9cbea5ed90e09
sha256: "742cd5df17f6438628655b7a16d1ee87624166a9dd0362cb818d9f6968ffbc10"
url: "https://pub.dev"
source: hosted
version: "27.1.52"
version: "27.1.53"
synchronized:
dependency: transitive
description:
@ -1171,10 +1179,10 @@ packages:
dependency: transitive
description:
name: xml2json
sha256: dbe79a85d902674d95c7608c8048355ce2ec5846640da1c0f91389ccdad5b5a8
sha256: "9523203b99032ce419672804010cce72ea47fc277b3135f77bbb7ac8fa391664"
url: "https://pub.dev"
source: hosted
version: "6.2.4"
version: "6.2.5"
yaml:
dependency: transitive
description:

View file

@ -42,6 +42,7 @@ dependencies:
flutter_form_builder: ^9.4.1
syncfusion_flutter_datepicker: ^27.1.50
syncfusion_localizations: ^27.1.52
flutter_dotenv: ^5.2.1
dev_dependencies:
@ -53,6 +54,7 @@ dev_dependencies:
flutter:
uses-material-design: true
assets:
- .env
- assets/
- assets/i18n/
- assets/images/

View file

@ -98,7 +98,7 @@
</style>
</head>
<body>
<div class="loader"></div>
<!--<div class="loader"></div>-->
<script src="flutter_bootstrap.js" async></script>
</body>