From ed31c1e4dcb989be13fdeead4ab9c5d2841d2ca9 Mon Sep 17 00:00:00 2001 From: reinjens Date: Wed, 20 Nov 2024 17:09:53 +0100 Subject: [PATCH] Categorypage -> responsive, collapsible, --- analysis_options.yaml | 26 +- lib/main.dart | 88 +----- lib/src/config/config.dart | 66 +++++ lib/src/consts/consts.dart | 19 ++ .../filter/item_filter_repository.dart | 8 +- .../approval_requirement_repository.dart | 2 +- .../entity/business/business_repository.dart | 2 +- .../experience_report_repository.dart | 2 +- .../funding_program_repository.dart | 2 +- .../location_requirements_repository.dart | 2 +- .../entity/material/material_repository.dart | 2 +- .../entity/measure/measure_repository.dart | 2 +- .../measure_combination_repository.dart | 2 +- .../number_factsheet_repository.dart | 2 +- .../entity/organism/organism_repository.dart | 2 +- .../reference_implementation_repository.dart | 2 +- ...ce_provider_contact_person_repository.dart | 2 +- .../service_provider_repository.dart | 2 +- lib/src/entity/source/source_repository.dart | 2 +- .../tree_type/tree_type_repository.dart | 2 +- lib/src/packages/ambito_api/base_api.dart | 4 +- lib/src/packages/ambito_api/restclient.dart | 6 +- lib/src/packages/ambito_db/base_db.dart | 2 +- .../ambito_downloader/ambito_downloader.dart | 2 +- .../ambito_formbuilder.dart | 2 +- .../notifier/filter_notifier.dart | 7 +- .../notifier/theme_manager.dart | 13 + .../ambito_sharedprefs.dart | 2 +- .../packages/ambito_theme/ambito_theme.dart | 7 +- .../ambito_theme/ambito_theme_large.dart | 1 + .../ambito_theme/ambito_theme_medium.dart | 1 + .../ambito_theme/ambito_theme_small.dart | 7 +- lib/src/pages/actions/actions_page.dart | 5 +- lib/src/pages/actions/actions_pre_page.dart | 251 +++++++++++------- .../actions/create/action_create_page.dart | 6 +- .../actions/detail/action_detail_page.dart | 3 +- .../actions/detail/cards/review_card.dart | 53 ---- lib/src/pages/calendar/calendar_page.dart | 7 +- .../pages/calendar/calendar_page_year.dart | 86 +++--- lib/src/pages/cart/cart_page.dart | 4 +- lib/src/pages/dashboard/dashboard_page.dart | 133 +++++----- lib/src/pages/start/start_page.dart | 5 +- lib/src/widgets/appbar/ambito_appbar.dart | 19 +- .../form/fields/field_daterangepicker.dart | 2 +- .../widgets/form/fields/field_dropdown.dart | 2 +- .../form/fields/field_monthsrangepicker.dart | 2 +- lib/src/widgets/form/fields/field_title.dart | 5 +- lib/src/widgets/form/form_widget.dart | 14 +- lib/src/widgets/page/base_page.dart | 20 ++ 49 files changed, 481 insertions(+), 427 deletions(-) create mode 100644 lib/src/config/config.dart create mode 100644 lib/src/widgets/page/base_page.dart diff --git a/analysis_options.yaml b/analysis_options.yaml index 0d29021..f16eead 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,28 +1,4 @@ -# This file configures the analyzer, which statically analyzes Dart code to -# check for errors, warnings, and lints. -# -# The issues identified by the analyzer are surfaced in the UI of Dart-enabled -# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be -# invoked from the command line by running `flutter analyze`. - -# The following line activates a set of recommended lints for Flutter apps, -# packages, and plugins designed to encourage good coding practices. include: package:flutter_lints/flutter.yaml linter: - # The lint rules applied to this project can be customized in the - # section below to disable rules from the `package:flutter_lints/flutter.yaml` - # included above or to enable additional rules. A list of all available lints - # and their documentation is published at https://dart.dev/lints. - # - # Instead of disabling a lint rule for the entire project in the - # section below, it can also be suppressed for a single line of code - # or a specific dart file by using the `// ignore: name_of_lint` and - # `// ignore_for_file: name_of_lint` syntax on the line or in the file - # producing the lint. - rules: - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options + rules: \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index e5dc835..212a117 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,11 +1,9 @@ +import 'package:ambito/src/config/config.dart'; +import 'package:ambito/src/consts/consts.dart'; import 'package:ambito/src/packages/ambito_api/base_api.dart'; import 'package:ambito/src/packages/ambito_db/base_db.dart'; import 'package:ambito/src/packages/ambito_notifier/notifier/theme_manager.dart'; import 'package:ambito/src/packages/ambito_sharedprefs/ambito_sharedprefs.dart'; -import 'package:ambito/src/packages/ambito_theme/ambito_theme.dart'; -import 'package:ambito/src/packages/ambito_theme/ambito_theme_large.dart'; -import 'package:ambito/src/packages/ambito_theme/ambito_theme_medium.dart'; -import 'package:ambito/src/packages/ambito_theme/ambito_theme_small.dart'; import 'package:ambito/src/pages/actions/actions_page.dart'; import 'package:ambito/src/pages/actions/actions_pre_page.dart'; import 'package:ambito/src/pages/actions/create/action_create_page.dart'; @@ -18,85 +16,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:get/get.dart'; -import 'package:isar/isar.dart'; -import 'package:logger/logger.dart'; import 'package:provider/provider.dart'; import 'package:screen_breakpoints/screen_breakpoints.dart'; -import 'package:shared_preferences/shared_preferences.dart'; import 'package:syncfusion_localizations/syncfusion_localizations.dart'; -final Logger logger = Logger( - printer: PrettyPrinter(), -); - -const BreakpointConfiguration myBreakpoints = BreakpointConfiguration( - xs: Breakpoint( - breakpoint: 0, - width: double.infinity, - margin: 16, - padding: 0, - columns: 4, - ), - sm: Breakpoint( - breakpoint: 320, - width: double.infinity, - margin: 32, - padding: 10, - columns: 8, - ), - md: Breakpoint( - breakpoint: 905, - width: 840, - margin: null, - padding: 0, - columns: 12, - ), - lg: Breakpoint( - breakpoint: 1240, - width: 1152, - margin: 0, - padding: 0, - columns: 12, - ), - xl: Breakpoint( - breakpoint: 1440, - width: 1152, - margin: null, - padding: 0, - columns: 12, - ), - xxl: null, -); - -late Isar isar; -late SharedPreferences prefs; -AmbitoTheme largeTheme = AmbitoThemeLarge(); -AmbitoTheme mediumTheme = AmbitoThemeMedium(); -AmbitoTheme smallTheme = AmbitoThemeSmall(); - -const BASEROW_TOKEN = 'TFxO7vzBLVRCu9I3VMoHmTuCvSu8aCDi'; -const BASEROW_IDS = { - "measure": 328253, - "measure_combination": 328217, - "organism": 328255, - "funding_program": 328256, - "factsheet": 328273, - "location_requirements": 328188, - "reference_implementation": 328465, - "business": 328472, - "experience_report": 330802, - "approval_requirement": 330806, - "service_provider": 330824, - "service_provider_contact_person": 330832, - "material": 330836, - "source": 334231, - "tree_type": 342622, - "aenderungfactsheet": 330946, -}; - void main() async { WidgetsFlutterBinding.ensureInitialized(); - //await dotenv.load(fileName: '.env'); await AmbitoSharedPrefs.start(); await AmbitoIsarDB.init(); await Future.wait([ @@ -113,11 +38,8 @@ void main() async { //BaseApi().getContent('material'), //BaseApi().getContent('source'), ]); - await MeasureRepository().buildMeasureFilters(); - - await MeasureRepository().downloadImages(); - + //await MeasureRepository().downloadImages(); runApp(const Ambito()); } @@ -151,8 +73,8 @@ class Ambito extends StatelessWidget { SfGlobalLocalizations.delegate, ], title: 'AmBiTo', - supportedLocales: const [Locale('de')], - locale: const Locale('de'), + supportedLocales: supportedLocales, + locale: ThemeManager().locale, builder: FlutterI18n.rootAppBuilder(), theme: ThemeManager().themeData?.lightThemeData, darkTheme: ThemeManager().themeData?.darkThemeData, diff --git a/lib/src/config/config.dart b/lib/src/config/config.dart new file mode 100644 index 0000000..e7a07a7 --- /dev/null +++ b/lib/src/config/config.dart @@ -0,0 +1,66 @@ +import 'dart:ui'; + +import 'package:screen_breakpoints/screen_breakpoints.dart'; + +const supportedLocales = [Locale('de')]; +const currentLocale = Locale('de'); + +/// configure the used breakpoints. Currently only sm is handled separately +const BreakpointConfiguration myBreakpoints = BreakpointConfiguration( + xs: Breakpoint( + breakpoint: 0, + width: double.infinity, + margin: 16, + padding: 0, + columns: 4, + ), + sm: Breakpoint( + breakpoint: 320, + width: double.infinity, + margin: 10, + padding: 10, + columns: 8, + ), + md: Breakpoint( + breakpoint: 905, + width: 840, + margin: null, + padding: 0, + columns: 12, + ), + lg: Breakpoint( + breakpoint: 1240, + width: 1152, + margin: 0, + padding: 0, + columns: 12, + ), + xl: Breakpoint( + breakpoint: 1440, + width: 1152, + margin: null, + padding: 0, + columns: 12, + ), + xxl: null, +); + +const baserowToken = 'TFxO7vzBLVRCu9I3VMoHmTuCvSu8aCDi'; +const baserowIds = { + "measure": 328253, + "measure_combination": 328217, + "organism": 328255, + "funding_program": 328256, + "factsheet": 328273, + "location_requirements": 328188, + "reference_implementation": 328465, + "business": 328472, + "experience_report": 330802, + "approval_requirement": 330806, + "service_provider": 330824, + "service_provider_contact_person": 330832, + "material": 330836, + "source": 334231, + "tree_type": 342622, + "aenderungfactsheet": 330946, +}; diff --git a/lib/src/consts/consts.dart b/lib/src/consts/consts.dart index c2861cb..e547798 100644 --- a/lib/src/consts/consts.dart +++ b/lib/src/consts/consts.dart @@ -1,3 +1,12 @@ +import 'package:isar/isar.dart'; +import 'package:logger/logger.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import '../packages/ambito_theme/ambito_theme.dart'; +import '../packages/ambito_theme/ambito_theme_large.dart'; +import '../packages/ambito_theme/ambito_theme_medium.dart'; +import '../packages/ambito_theme/ambito_theme_small.dart'; + const List months = [ 'Januar', 'Februar', @@ -12,3 +21,13 @@ const List months = [ 'November', 'Dezember', ]; + +final Logger logger = Logger( + printer: PrettyPrinter(), +); + +late Isar isar; +late SharedPreferences prefs; +final AmbitoTheme largeTheme = AmbitoThemeLarge(); +final AmbitoTheme mediumTheme = AmbitoThemeMedium(); +final AmbitoTheme smallTheme = AmbitoThemeSmall(); diff --git a/lib/src/entity/_general/filter/item_filter_repository.dart b/lib/src/entity/_general/filter/item_filter_repository.dart index bfd7010..e905fb9 100644 --- a/lib/src/entity/_general/filter/item_filter_repository.dart +++ b/lib/src/entity/_general/filter/item_filter_repository.dart @@ -3,15 +3,15 @@ import 'package:ambito/src/packages/ambito_db/base_db.dart'; import 'package:ambito/src/packages/ambito_notifier/notifier/filter_notifier.dart'; import 'package:isar/isar.dart'; -import '../../../../main.dart'; +import '../../../consts/consts.dart'; import '../../../widgets/form/fields/field_dropdown.dart'; class ItemFilterRepository extends BaseDB { @override IsarCollection collection = isar.itemFilters; - List? getByType(String type) { - return isar.itemFilters.where().typeEqualTo(type).findAll(); + Set? getByType(String type) { + return isar.itemFilters.where().typeEqualTo(type).findAll().toSet(); } List? getIdsByType(String type) { @@ -41,7 +41,7 @@ class ItemFilterRepository extends BaseDB { FieldDropdown getDropDown(String type, String label) { if (type == 'month') {} - List filterItems = getByType(type)!; + Set filterItems = getByType(type)!; return FieldDropdown( name: type, diff --git a/lib/src/entity/approval_requirement/approval_requirement_repository.dart b/lib/src/entity/approval_requirement/approval_requirement_repository.dart index 5be56ac..9328317 100644 --- a/lib/src/entity/approval_requirement/approval_requirement_repository.dart +++ b/lib/src/entity/approval_requirement/approval_requirement_repository.dart @@ -2,7 +2,7 @@ import 'package:ambito/src/entity/entities.dart'; import 'package:ambito/src/packages/ambito_db/base_db.dart'; import 'package:isar/isar.dart'; -import '../../../../main.dart'; +import '../../consts/consts.dart'; class ApprovalRequirementRepository extends BaseDB { @override diff --git a/lib/src/entity/business/business_repository.dart b/lib/src/entity/business/business_repository.dart index f24ba29..c7f37d9 100644 --- a/lib/src/entity/business/business_repository.dart +++ b/lib/src/entity/business/business_repository.dart @@ -2,7 +2,7 @@ import 'package:ambito/src/entity/entities.dart'; import 'package:ambito/src/packages/ambito_db/base_db.dart'; import 'package:isar/isar.dart'; -import '../../../../main.dart'; +import '../../consts/consts.dart'; class BusinessRepository extends BaseDB { @override diff --git a/lib/src/entity/experience_report/experience_report_repository.dart b/lib/src/entity/experience_report/experience_report_repository.dart index 64e37bf..29c045e 100644 --- a/lib/src/entity/experience_report/experience_report_repository.dart +++ b/lib/src/entity/experience_report/experience_report_repository.dart @@ -2,7 +2,7 @@ import 'package:ambito/src/entity/entities.dart'; import 'package:ambito/src/packages/ambito_db/base_db.dart'; import 'package:isar/isar.dart'; -import '../../../../main.dart'; +import '../../consts/consts.dart'; class ExperienceReportRepository extends BaseDB { @override diff --git a/lib/src/entity/funding_program/funding_program_repository.dart b/lib/src/entity/funding_program/funding_program_repository.dart index 1fd7f44..c86b65a 100644 --- a/lib/src/entity/funding_program/funding_program_repository.dart +++ b/lib/src/entity/funding_program/funding_program_repository.dart @@ -2,7 +2,7 @@ import 'package:ambito/src/entity/entities.dart'; import 'package:ambito/src/packages/ambito_db/base_db.dart'; import 'package:isar/isar.dart'; -import '../../../../main.dart'; +import '../../consts/consts.dart'; class FundingProgramRepository extends BaseDB { @override diff --git a/lib/src/entity/location_requirements/location_requirements_repository.dart b/lib/src/entity/location_requirements/location_requirements_repository.dart index 01229f9..b3e6200 100644 --- a/lib/src/entity/location_requirements/location_requirements_repository.dart +++ b/lib/src/entity/location_requirements/location_requirements_repository.dart @@ -2,7 +2,7 @@ import 'package:ambito/src/entity/entities.dart'; import 'package:ambito/src/packages/ambito_db/base_db.dart'; import 'package:isar/isar.dart'; -import '../../../../main.dart'; +import '../../consts/consts.dart'; class LocationRequirementsRepository extends BaseDB { @override diff --git a/lib/src/entity/material/material_repository.dart b/lib/src/entity/material/material_repository.dart index bdb08d8..e3f2626 100644 --- a/lib/src/entity/material/material_repository.dart +++ b/lib/src/entity/material/material_repository.dart @@ -2,7 +2,7 @@ import 'package:ambito/src/entity/entities.dart'; import 'package:ambito/src/packages/ambito_db/base_db.dart'; import 'package:isar/isar.dart'; -import '../../../../main.dart'; +import '../../consts/consts.dart'; class MaterialRepository extends BaseDB { @override diff --git a/lib/src/entity/measure/measure_repository.dart b/lib/src/entity/measure/measure_repository.dart index 4d56528..70dbe6c 100644 --- a/lib/src/entity/measure/measure_repository.dart +++ b/lib/src/entity/measure/measure_repository.dart @@ -4,7 +4,7 @@ import 'package:ambito/src/extensions/extensions.dart'; import 'package:ambito/src/packages/ambito_db/base_db.dart'; import 'package:isar/isar.dart'; -import '../../../../main.dart'; +import '../../consts/consts.dart'; class MeasureRepository extends BaseDB { @override diff --git a/lib/src/entity/measure_combination/measure_combination_repository.dart b/lib/src/entity/measure_combination/measure_combination_repository.dart index f2f837b..63943fd 100644 --- a/lib/src/entity/measure_combination/measure_combination_repository.dart +++ b/lib/src/entity/measure_combination/measure_combination_repository.dart @@ -2,7 +2,7 @@ import 'package:ambito/src/entity/entities.dart'; import 'package:ambito/src/packages/ambito_db/base_db.dart'; import 'package:isar/isar.dart'; -import '../../../../main.dart'; +import '../../consts/consts.dart'; class MeasureCombinationRepository extends BaseDB { @override diff --git a/lib/src/entity/number_factsheet/number_factsheet_repository.dart b/lib/src/entity/number_factsheet/number_factsheet_repository.dart index 20fe134..5321dc1 100644 --- a/lib/src/entity/number_factsheet/number_factsheet_repository.dart +++ b/lib/src/entity/number_factsheet/number_factsheet_repository.dart @@ -2,7 +2,7 @@ import 'package:ambito/src/entity/entities.dart'; import 'package:ambito/src/packages/ambito_db/base_db.dart'; import 'package:isar/isar.dart'; -import '../../../../main.dart'; +import '../../consts/consts.dart'; class NumberFactsheetRepository extends BaseDB { @override diff --git a/lib/src/entity/organism/organism_repository.dart b/lib/src/entity/organism/organism_repository.dart index c5f8b0b..2191aaa 100644 --- a/lib/src/entity/organism/organism_repository.dart +++ b/lib/src/entity/organism/organism_repository.dart @@ -2,7 +2,7 @@ import 'package:ambito/src/entity/entities.dart'; import 'package:ambito/src/packages/ambito_db/base_db.dart'; import 'package:isar/isar.dart'; -import '../../../../main.dart'; +import '../../consts/consts.dart'; class OrganismRepository extends BaseDB { @override diff --git a/lib/src/entity/reference_implementation/reference_implementation_repository.dart b/lib/src/entity/reference_implementation/reference_implementation_repository.dart index 48918d8..870d5ea 100644 --- a/lib/src/entity/reference_implementation/reference_implementation_repository.dart +++ b/lib/src/entity/reference_implementation/reference_implementation_repository.dart @@ -2,7 +2,7 @@ import 'package:ambito/src/entity/entities.dart'; import 'package:ambito/src/packages/ambito_db/base_db.dart'; import 'package:isar/isar.dart'; -import '../../../../main.dart'; +import '../../consts/consts.dart'; class ReferenceImplementationRepository extends BaseDB { @override diff --git a/lib/src/entity/service_provider/service_provider_contact_person_repository.dart b/lib/src/entity/service_provider/service_provider_contact_person_repository.dart index 75be70f..b6222e0 100644 --- a/lib/src/entity/service_provider/service_provider_contact_person_repository.dart +++ b/lib/src/entity/service_provider/service_provider_contact_person_repository.dart @@ -2,7 +2,7 @@ import 'package:ambito/src/entity/entities.dart'; import 'package:ambito/src/packages/ambito_db/base_db.dart'; import 'package:isar/isar.dart'; -import '../../../../main.dart'; +import '../../consts/consts.dart'; class ServiceProviderContactPersonRepository extends BaseDB { @override diff --git a/lib/src/entity/service_provider/service_provider_repository.dart b/lib/src/entity/service_provider/service_provider_repository.dart index c19e60b..651e910 100644 --- a/lib/src/entity/service_provider/service_provider_repository.dart +++ b/lib/src/entity/service_provider/service_provider_repository.dart @@ -2,7 +2,7 @@ import 'package:ambito/src/entity/entities.dart'; import 'package:ambito/src/packages/ambito_db/base_db.dart'; import 'package:isar/isar.dart'; -import '../../../../main.dart'; +import '../../consts/consts.dart'; class ServiceProviderRepository extends BaseDB { @override diff --git a/lib/src/entity/source/source_repository.dart b/lib/src/entity/source/source_repository.dart index 63e185c..b847bd1 100644 --- a/lib/src/entity/source/source_repository.dart +++ b/lib/src/entity/source/source_repository.dart @@ -2,7 +2,7 @@ import 'package:ambito/src/entity/entities.dart'; import 'package:ambito/src/packages/ambito_db/base_db.dart'; import 'package:isar/isar.dart'; -import '../../../../main.dart'; +import '../../consts/consts.dart'; class SourceRepository extends BaseDB { @override diff --git a/lib/src/entity/tree_type/tree_type_repository.dart b/lib/src/entity/tree_type/tree_type_repository.dart index 36d0f0e..9f6719a 100644 --- a/lib/src/entity/tree_type/tree_type_repository.dart +++ b/lib/src/entity/tree_type/tree_type_repository.dart @@ -1,7 +1,7 @@ import 'package:ambito/src/entity/entities.dart'; import 'package:isar/isar.dart'; -import '../../../../main.dart'; +import '../../consts/consts.dart'; import '../../packages/ambito_db/base_db.dart'; class TreeTypeRepository extends BaseDB { diff --git a/lib/src/packages/ambito_api/base_api.dart b/lib/src/packages/ambito_api/base_api.dart index 7cfa94b..efedf00 100644 --- a/lib/src/packages/ambito_api/base_api.dart +++ b/lib/src/packages/ambito_api/base_api.dart @@ -3,7 +3,7 @@ import 'dart:convert'; import 'package:ambito/src/entity/entities.dart'; import 'package:ambito/src/packages/ambito_api/restclient.dart'; -import '../../../main.dart'; +import '../../config/config.dart'; import '../ambito_db/base_db.dart'; class BaseApi { @@ -11,7 +11,7 @@ class BaseApi { init() { // read table ids from .env file... - tables = BASEROW_IDS; + tables = baserowIds; } Future getContent(String table) async { diff --git a/lib/src/packages/ambito_api/restclient.dart b/lib/src/packages/ambito_api/restclient.dart index 30f61d2..2ae96fa 100644 --- a/lib/src/packages/ambito_api/restclient.dart +++ b/lib/src/packages/ambito_api/restclient.dart @@ -3,9 +3,11 @@ library vyc_api; import 'dart:async'; import 'dart:convert'; -import 'package:ambito/main.dart'; +import 'package:ambito/src/config/config.dart'; import 'package:http/http.dart' as http; +import '../../consts/consts.dart'; + class RestClient { final String baseUrl = 'https://api.baserow.io/api/database/rows/table/'; static final http.Client _client = http.Client(); @@ -19,7 +21,7 @@ class RestClient { var headers = { "Content-Type": contentType, "Accept": accept, - "Authorization": "Token $BASEROW_TOKEN", + "Authorization": "Token $baserowToken", }; return headers; } diff --git a/lib/src/packages/ambito_db/base_db.dart b/lib/src/packages/ambito_db/base_db.dart index 9a2cc03..88093a0 100644 --- a/lib/src/packages/ambito_db/base_db.dart +++ b/lib/src/packages/ambito_db/base_db.dart @@ -3,7 +3,7 @@ import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; import 'package:path_provider/path_provider.dart'; -import '../../../main.dart'; +import '../../consts/consts.dart'; export 'repositories/_repositories.dart'; diff --git a/lib/src/packages/ambito_downloader/ambito_downloader.dart b/lib/src/packages/ambito_downloader/ambito_downloader.dart index d4cf2c3..70968be 100644 --- a/lib/src/packages/ambito_downloader/ambito_downloader.dart +++ b/lib/src/packages/ambito_downloader/ambito_downloader.dart @@ -1,4 +1,4 @@ -import '../../../main.dart'; +import '../../consts/consts.dart'; class AmbitoDownloader { static Future downloadImage( diff --git a/lib/src/packages/ambito_formbuilder/ambito_formbuilder.dart b/lib/src/packages/ambito_formbuilder/ambito_formbuilder.dart index ad9c4d7..ed7face 100644 --- a/lib/src/packages/ambito_formbuilder/ambito_formbuilder.dart +++ b/lib/src/packages/ambito_formbuilder/ambito_formbuilder.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:isar/isar.dart'; -import '../../../main.dart'; +import '../../consts/consts.dart'; class AmbitoFormBuilder { String type = ''; diff --git a/lib/src/packages/ambito_notifier/notifier/filter_notifier.dart b/lib/src/packages/ambito_notifier/notifier/filter_notifier.dart index 830c382..c76d094 100644 --- a/lib/src/packages/ambito_notifier/notifier/filter_notifier.dart +++ b/lib/src/packages/ambito_notifier/notifier/filter_notifier.dart @@ -1,7 +1,8 @@ -import 'package:ambito/main.dart'; import 'package:ambito/src/entity/_general/filter/item_filter_repository.dart'; import 'package:flutter/cupertino.dart'; +import '../../../consts/consts.dart'; + AmbitoFilterNotifier ambitoFilterNotifier = AmbitoFilterNotifier(); class AmbitoFilterNotifier extends ChangeNotifier { @@ -30,7 +31,9 @@ class AmbitoFilterNotifier extends ChangeNotifier { }); } - List? getMergedIds() {} + List? getMergedIds() { + return null; + } String? getFilter(String type) { return activeFilters[type]; diff --git a/lib/src/packages/ambito_notifier/notifier/theme_manager.dart b/lib/src/packages/ambito_notifier/notifier/theme_manager.dart index 1f12ace..18d44cb 100644 --- a/lib/src/packages/ambito_notifier/notifier/theme_manager.dart +++ b/lib/src/packages/ambito_notifier/notifier/theme_manager.dart @@ -5,15 +5,28 @@ import 'package:flutter/cupertino.dart'; class ThemeManager with ChangeNotifier { AmbitoTheme? _themeData; + Locale? _locale; + /// Use this method on UI to get selected theme. AmbitoTheme? get themeData { _themeData ??= AmbitoThemeMedium(); return _themeData; } + Locale? get locale { + _locale ??= const Locale('de'); + return _locale; + } + /// Sets theme and notifies listeners about change. setTheme(AmbitoTheme theme) async { _themeData = theme; notifyListeners(); } + + /// Sets locale and notifies listeners about change + setLocale(Locale locale) async { + _locale = locale; + notifyListeners(); + } } diff --git a/lib/src/packages/ambito_sharedprefs/ambito_sharedprefs.dart b/lib/src/packages/ambito_sharedprefs/ambito_sharedprefs.dart index d588b5f..a1896ba 100644 --- a/lib/src/packages/ambito_sharedprefs/ambito_sharedprefs.dart +++ b/lib/src/packages/ambito_sharedprefs/ambito_sharedprefs.dart @@ -1,6 +1,6 @@ import 'package:shared_preferences/shared_preferences.dart'; -import '../../../main.dart'; +import '../../consts/consts.dart'; class AmbitoSharedPrefs { static Future start() async { diff --git a/lib/src/packages/ambito_theme/ambito_theme.dart b/lib/src/packages/ambito_theme/ambito_theme.dart index 6aa057a..2ad4c9c 100644 --- a/lib/src/packages/ambito_theme/ambito_theme.dart +++ b/lib/src/packages/ambito_theme/ambito_theme.dart @@ -3,7 +3,8 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:screen_breakpoints/screen_breakpoints.dart'; -import '../../../main.dart'; +import '../../config/config.dart'; +import '../../consts/consts.dart'; final orangeColors = { 'primary': const Color(0xffeebb4b), @@ -56,10 +57,10 @@ AmbitoTheme getTheme(BuildContext context) { return largeTheme; } if (breakpoint >= myBreakpoints.sm) { - ThemeManager().setTheme(smallTheme); + ThemeManager().setTheme(mediumTheme); return mediumTheme; } - ThemeManager().setTheme(mediumTheme); + ThemeManager().setTheme(smallTheme); return smallTheme; } diff --git a/lib/src/packages/ambito_theme/ambito_theme_large.dart b/lib/src/packages/ambito_theme/ambito_theme_large.dart index 8428f72..6be6f8f 100644 --- a/lib/src/packages/ambito_theme/ambito_theme_large.dart +++ b/lib/src/packages/ambito_theme/ambito_theme_large.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; class AmbitoThemeLarge extends AmbitoTheme { + @override TextTheme get textTheme => TextTheme( displayLarge: GoogleFonts.openSans( fontSize: 57, diff --git a/lib/src/packages/ambito_theme/ambito_theme_medium.dart b/lib/src/packages/ambito_theme/ambito_theme_medium.dart index 5401028..ed7da7b 100644 --- a/lib/src/packages/ambito_theme/ambito_theme_medium.dart +++ b/lib/src/packages/ambito_theme/ambito_theme_medium.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; class AmbitoThemeMedium extends AmbitoTheme { + @override TextTheme get textTheme => TextTheme( displayLarge: GoogleFonts.openSans( fontSize: 57, diff --git a/lib/src/packages/ambito_theme/ambito_theme_small.dart b/lib/src/packages/ambito_theme/ambito_theme_small.dart index 60e50cd..013bdf9 100644 --- a/lib/src/packages/ambito_theme/ambito_theme_small.dart +++ b/lib/src/packages/ambito_theme/ambito_theme_small.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; class AmbitoThemeSmall extends AmbitoTheme { + @override TextTheme get textTheme => TextTheme( displayLarge: GoogleFonts.openSans( fontSize: 57, @@ -22,19 +23,19 @@ class AmbitoThemeSmall extends AmbitoTheme { letterSpacing: 0, ), headlineLarge: GoogleFonts.openSans( - fontSize: 32, + fontSize: 18, height: 1.25, fontWeight: FontWeight.w400, letterSpacing: 0, ), headlineMedium: GoogleFonts.openSans( - fontSize: 28, + fontSize: 20, height: 1.29, fontWeight: FontWeight.w400, letterSpacing: 0, ), headlineSmall: GoogleFonts.openSans( - fontSize: 24, + fontSize: 16, height: 1.33, fontWeight: FontWeight.w400, letterSpacing: 0, diff --git a/lib/src/pages/actions/actions_page.dart b/lib/src/pages/actions/actions_page.dart index ea5587a..59544c2 100644 --- a/lib/src/pages/actions/actions_page.dart +++ b/lib/src/pages/actions/actions_page.dart @@ -210,10 +210,13 @@ class ActionsPageState extends State { return getCard(context, massnahme); }).toList(); + final AmbitoTheme theme = getTheme(context); + return Scaffold( appBar: AmbitoAppbar( links: const ['dashboard', 'massnahmen'], breakpoint: Breakpoint.fromContext(context), + theme: theme, ), body: Padding( padding: const EdgeInsets.symmetric(horizontal: 32), @@ -357,7 +360,7 @@ class ActionsPageState extends State { ), Expanded( child: Padding( - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ diff --git a/lib/src/pages/actions/actions_pre_page.dart b/lib/src/pages/actions/actions_pre_page.dart index 419f869..067baf0 100644 --- a/lib/src/pages/actions/actions_pre_page.dart +++ b/lib/src/pages/actions/actions_pre_page.dart @@ -1,14 +1,16 @@ +import 'package:ambito/src/config/config.dart'; import 'package:ambito/src/entity/_general/filter/item_filter_repository.dart'; import 'package:ambito/src/entity/entities.dart'; import 'package:ambito/src/entity/measure/measure_repository.dart'; +import 'package:ambito/src/extensions/extensions.dart'; import 'package:ambito/src/pages/ambito_page.dart'; +import 'package:ambito/src/widgets/page/base_page.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:screen_breakpoints/screen_breakpoints.dart'; -import '../../../main.dart'; +import '../../consts/consts.dart'; import '../../packages/ambito_theme/ambito_theme.dart'; -import '../../widgets/appbar/ambito_appbar.dart'; class ActionsPrePage extends AmbitoPage { const ActionsPrePage({super.key}); @@ -23,91 +25,17 @@ class ActionsPrePage extends AmbitoPage { } class ActionsPrePageState extends State { - List cards = []; + Set cards = {}; Map counter = {}; Map ids = {}; int counterComplete = 0; + Set? filters; @override void initState() { - List? filters = ItemFilterRepository().getByType('areaType'); - + cards = {}; + filters = ItemFilterRepository().getByType('areaType'); counterComplete = MeasureRepository().getMeasureCount(); - - for (ItemFilter filter in filters!) { - setState(() { - cards.add( - InkWell( - onTap: () { - prefs.setString('selected_areaType', filter.name!).then((value) { - Get.toNamed('/massnahmendatenbank/${filter.name}'); - setState(() {}); - }); - }, - onHover: (hovered) {}, - highlightColor: Colors.transparent, - splashColor: Colors.transparent, - focusColor: Colors.transparent, - hoverColor: Colors.transparent, - child: SizedBox( - width: 262, - height: 380, - child: Card( - elevation: 0, - color: actionAreaColors[filter.name!], - child: Column( - children: [ - ClipRRect( - borderRadius: BorderRadius.circular(8.0), - child: Image.asset( - filter.image!, - ), - ), - largeTheme.verticalSpacer, - Padding( - padding: const EdgeInsets.only(left: 16, right: 16), - child: Text( - filter.name!, - style: largeTheme.currentThemeData.textTheme.labelMedium - ?.copyWith( - color: actionAreaFGColors[filter.name!], - fontWeight: FontWeight.bold, - ), - ), - ), - largeTheme.verticalSpacer, - Padding( - padding: const EdgeInsets.only(left: 16, right: 16), - child: Text( - filter.description!, - style: largeTheme.currentThemeData.textTheme.bodyMedium - ?.copyWith( - color: largeTheme.currentColorScheme.onSurface, - ), - ), - ), - const Spacer(), - Padding( - padding: const EdgeInsets.only( - left: 16, right: 16, bottom: 16), - child: Text( - 'Anzahl: ${filter.ids!.length}', - style: largeTheme.currentThemeData.textTheme.titleMedium - ?.copyWith( - color: actionAreaFGColors[filter.name!], - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ), - ), - ), - ); - }); - } - super.initState(); } @@ -115,12 +43,19 @@ class ActionsPrePageState extends State { Widget build(BuildContext context) { final AmbitoTheme theme = getTheme(context); - return Scaffold( - appBar: AmbitoAppbar( - links: const ['dashboard', 'massnahmen'], - breakpoint: Breakpoint.fromContext(context), - ), - body: BreakpointBuilder(builder: ( + setState(() { + cards = {}; + }); + + for (ItemFilter filter in filters!) { + setState(() { + cards.add(_buildCard(context, filter)); + }); + } + + return BasePage().getPage( + context, + BreakpointBuilder(builder: ( context, breakpoint, configuration, @@ -135,20 +70,22 @@ class ActionsPrePageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(breakpoint.toString()), - theme.verticalSpacerMax, + theme.verticalSpacer, Text( - 'Maßnahmenkategorien', + context.translate('page.general.links.massnahmen.title'), textAlign: TextAlign.start, - style: theme.currentThemeData.textTheme.headlineLarge - ?.copyWith( + style: theme.headlineLarge.copyWith( color: theme.currentColorScheme.onSurface, ), ), theme.verticalSpacerMax, - Wrap( - alignment: WrapAlignment.center, - spacing: 32, - children: cards, + Align( + alignment: Alignment.center, + child: Wrap( + alignment: WrapAlignment.center, + spacing: 32, + children: cards.toList(), + ), ), theme.verticalSpacerMax, InkWell( @@ -189,4 +126,130 @@ class ActionsPrePageState extends State { }), ); } + + Widget _buildCard(BuildContext context, ItemFilter filter) { + return InkWell( + onTap: () { + prefs.setString('selected_areaType', filter.name!).then((value) { + Get.toNamed('/massnahmendatenbank/${filter.name}'); + }); + }, + onHover: (hovered) {}, + highlightColor: Colors.transparent, + splashColor: Colors.transparent, + focusColor: Colors.transparent, + hoverColor: Colors.transparent, + child: context.breakpoint.breakpoint == myBreakpoints.sm!.breakpoint + ? _smallCard(filter) + : _normalCard(filter), + ); + } + + Widget _smallCard(ItemFilter filter) { + final AmbitoTheme theme = getTheme(context); + return Padding( + padding: EdgeInsets.only(bottom: 10), + child: Container( + height: 180, + width: double.infinity, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + image: DecorationImage( + image: AssetImage(filter.image!), + fit: BoxFit.cover, + ), + ), + child: Column( + children: [ + const Expanded(child: SizedBox()), + Container( + height: 80, + decoration: BoxDecoration( + color: actionAreaFGColors[filter.name!]!.withOpacity(.6), + borderRadius: const BorderRadius.only( + bottomLeft: Radius.circular(10), + bottomRight: Radius.circular(10)), + ), + width: double.infinity, + child: Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + filter.name!, + style: theme.labelMedium.copyWith( + color: theme.currentColorScheme.onPrimary, + fontWeight: FontWeight.bold, + ), + ), + Text( + 'Anzahl: ${filter.ids!.length}', + style: theme.titleMedium.copyWith( + color: theme.currentColorScheme.onPrimary, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + ], + ), + ), + ); + } + + Widget _normalCard(ItemFilter filter) { + final AmbitoTheme theme = getTheme(context); + return SizedBox( + width: 262, + height: 380, + child: Card( + elevation: 0, + color: actionAreaColors[filter.name!], + child: Column( + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(8.0), + child: Image.asset( + filter.image!, + ), + ), + largeTheme.verticalSpacer, + Padding( + padding: const EdgeInsets.only(left: 16, right: 16), + child: Text( + filter.name!, + style: theme.labelMedium.copyWith( + color: actionAreaFGColors[filter.name!], + fontWeight: FontWeight.bold, + ), + ), + ), + largeTheme.verticalSpacer, + Padding( + padding: const EdgeInsets.only(left: 16, right: 16), + child: Text( + filter.description!, + style: theme.bodyMedium.copyWith( + color: theme.currentColorScheme.onSurface, + ), + ), + ), + const Spacer(), + Padding( + padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16), + child: Text( + 'Anzahl: ${filter.ids!.length}', + style: theme.titleMedium.copyWith( + color: actionAreaFGColors[filter.name!], + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ), + ); + } } diff --git a/lib/src/pages/actions/create/action_create_page.dart b/lib/src/pages/actions/create/action_create_page.dart index 6c85990..1c05f95 100644 --- a/lib/src/pages/actions/create/action_create_page.dart +++ b/lib/src/pages/actions/create/action_create_page.dart @@ -35,9 +35,9 @@ class ActionsCreatePageState extends State { return Scaffold( appBar: AmbitoAppbar( - links: const ['dashboard', 'massnahmen'], - breakpoint: Breakpoint.fromContext(context), - ), + links: const ['dashboard', 'massnahmen'], + breakpoint: Breakpoint.fromContext(context), + theme: theme), body: BreakpointBuilder(builder: ( context, breakpoint, diff --git a/lib/src/pages/actions/detail/action_detail_page.dart b/lib/src/pages/actions/detail/action_detail_page.dart index 035d537..92ac00e 100644 --- a/lib/src/pages/actions/detail/action_detail_page.dart +++ b/lib/src/pages/actions/detail/action_detail_page.dart @@ -1,4 +1,3 @@ -import 'package:ambito/main.dart'; import 'package:ambito/src/entity/entities.dart'; import 'package:ambito/src/entity/measure/measure_repository.dart'; import 'package:ambito/src/extensions/extensions.dart'; @@ -9,6 +8,7 @@ import 'package:flutter_breadcrumb/flutter_breadcrumb.dart'; import 'package:get/get.dart'; import 'package:screen_breakpoints/screen_breakpoints.dart'; +import '../../../config/config.dart'; import '../../../packages/ambito_theme/ambito_theme.dart'; import '../../../widgets/appbar/ambito_appbar.dart'; import '../../ambito_page.dart'; @@ -61,6 +61,7 @@ class ActionDetailPageState extends State { appBar: AmbitoAppbar( links: const ['dashboard', 'massnahmen'], breakpoint: Breakpoint.fromContext(context), + theme: theme, ), body: (context.breakpoint != myBreakpoints.sm) ? _buildInfoPage(context, massnahme) diff --git a/lib/src/pages/actions/detail/cards/review_card.dart b/lib/src/pages/actions/detail/cards/review_card.dart index f299d01..8528c77 100644 --- a/lib/src/pages/actions/detail/cards/review_card.dart +++ b/lib/src/pages/actions/detail/cards/review_card.dart @@ -1,7 +1,5 @@ -import 'package:ambito/src/extensions/extensions.dart'; import 'package:flutter/material.dart'; import 'package:flutter_rating/flutter_rating.dart'; -import 'package:flutter_rating_stars/flutter_rating_stars.dart'; import '../../../../entity/entities.dart'; import '../../../../packages/ambito_theme/ambito_theme.dart'; @@ -58,56 +56,5 @@ class ReviewCard extends StatelessWidget { ), ], ); - - return SizedBox( - width: double.infinity, - child: Card( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(0), - ), - elevation: 0, - color: theme.currentColorScheme.tertiary, - child: Padding( - padding: const EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - context.translate('page.actionDetailPage.review.title'), - style: theme.currentThemeData.textTheme.titleMedium, - ), - theme.verticalSpacer, - RatingStars( - value: 4.5, - onValueChanged: (v) {}, - starBuilder: (index, color) => Icon( - Icons.star, - color: color, - ), - starCount: 5, - starSize: 32, - valueLabelColor: const Color(0xff9b9b9b), - valueLabelTextStyle: const TextStyle( - color: Colors.white, - fontWeight: FontWeight.w400, - fontStyle: FontStyle.normal, - fontSize: 12.0), - valueLabelRadius: 10, - maxValue: 5, - starSpacing: 2, - maxValueVisibility: true, - valueLabelVisibility: false, - animationDuration: const Duration(milliseconds: 1000), - valueLabelPadding: - const EdgeInsets.symmetric(vertical: 1, horizontal: 8), - valueLabelMargin: const EdgeInsets.only(right: 8), - starOffColor: Colors.yellow.withOpacity(.3), - starColor: Colors.yellow, - ), - ], - ), - ), - ), - ); } } diff --git a/lib/src/pages/calendar/calendar_page.dart b/lib/src/pages/calendar/calendar_page.dart index 76c663b..8e4d095 100644 --- a/lib/src/pages/calendar/calendar_page.dart +++ b/lib/src/pages/calendar/calendar_page.dart @@ -22,7 +22,7 @@ class CalendarPage extends StatefulWidget { class CalendarPageState extends State { List appointments = []; - List? monthFilter = []; + Set? monthFilter = {}; @override void initState() { @@ -62,10 +62,13 @@ class CalendarPageState extends State { @override Widget build(BuildContext context) { + final AmbitoTheme theme = getTheme(context); + return Scaffold( appBar: AmbitoAppbar( links: const ['dashboard', 'massnahmen'], breakpoint: Breakpoint.fromContext(context), + theme: theme, ), body: Center( child: Padding( @@ -89,7 +92,7 @@ class CalendarPageState extends State { List appointments = []; appointments.add(Appointment( startTime: DateTime.now(), - endTime: DateTime.now().add(Duration(minutes: 10)), + endTime: DateTime.now().add(const Duration(minutes: 10)), subject: 'Meeting', isAllDay: true, color: Colors.blue, diff --git a/lib/src/pages/calendar/calendar_page_year.dart b/lib/src/pages/calendar/calendar_page_year.dart index 2506b69..bd5128d 100644 --- a/lib/src/pages/calendar/calendar_page_year.dart +++ b/lib/src/pages/calendar/calendar_page_year.dart @@ -1,10 +1,13 @@ -import 'package:ambito/main.dart'; +import 'package:ambito/src/config/config.dart'; import 'package:ambito/src/entity/_general/filter/item_filter.dart'; import 'package:ambito/src/entity/measure/measure_repository.dart'; +import 'package:ambito/src/packages/ambito_notifier/notifier/theme_manager.dart'; import 'package:flutter/material.dart'; +import 'package:get/get.dart'; import 'package:screen_breakpoints/screen_breakpoints.dart'; import '../../consts/consts.dart'; +import '../../packages/ambito_theme/ambito_theme.dart'; import '../../widgets/appbar/ambito_appbar.dart'; class CalendarPageYear extends StatefulWidget { @@ -25,11 +28,16 @@ class CalendarPageYearState extends State { @override void initState() { - initDataSource(); + ThemeManager().addListener(_updateState); + super.initState(); } - initDataSource() { + void _updateState() { + setState(() {}); + } + + initDataSource(BuildContext context, AmbitoTheme theme) { List cells = [ TableCell( child: Padding( @@ -48,15 +56,20 @@ class CalendarPageYearState extends State { verticalAlignment: TableCellVerticalAlignment.middle, child: Text( textAlign: TextAlign.center, - month, - style: largeTheme.currentThemeData.textTheme.titleMedium + (context.breakpoint.breakpoint == myBreakpoints.sm!.breakpoint) + ? month.substring(0, 1) + : (context.breakpoint.breakpoint == + myBreakpoints.md!.breakpoint) + ? month.substring(0, 3) + : month, + style: theme.titleMedium ?.copyWith(fontWeight: FontWeight.bold, color: Colors.white), ), ), ); } rowsHeader.add(TableRow( - decoration: const BoxDecoration(color: Color(0xFF60845E)), + decoration: BoxDecoration(color: theme.currentColorScheme.secondary), children: cells)); var massnahmen = MeasureRepository().getAllOrdered(); for (var massnahme in massnahmen) { @@ -65,8 +78,18 @@ class CalendarPageYearState extends State { TableCell( child: Padding( padding: const EdgeInsets.all(8), - child: Text( - massnahme.name!, + child: TextButton( + onPressed: () { + Get.toNamed('/massnahme/${massnahme.id}'); + }, + child: Align( + alignment: Alignment.centerLeft, + child: Text( + textAlign: TextAlign.start, + massnahme.name!, + style: theme.bodySmall, + ), + ), ), ), ), @@ -80,7 +103,7 @@ class CalendarPageYearState extends State { child: Container( width: double.infinity, height: 44, - color: largeTheme.currentColorScheme.primary, + color: theme.currentColorScheme.secondary, ), ), ); @@ -107,52 +130,23 @@ class CalendarPageYearState extends State { @override Widget build(BuildContext context) { + final AmbitoTheme theme = getTheme(context); + + rowsHeader = []; + rowsBody = []; + + initDataSource(context, theme); + double fixedWidth = 120; return Scaffold( appBar: AmbitoAppbar( links: const ['dashboard', 'massnahmen'], breakpoint: Breakpoint.fromContext(context), + theme: theme, ), body: Card( child: Column( children: [ - /*Padding( - padding: const EdgeInsets.only(top: 32, left: 32, right: 32), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - FilterChip( - label: const Text('Zeitraum der Anlage'), - selected: displayFilterSet.contains('creation'), - selectedColor: baseTheme.currentColorScheme.primary, - onSelected: (bool selected) { - setState(() { - if (selected) { - displayFilterSet.add('creation'); - } else { - displayFilterSet.remove('creation'); - } - }); - }, - ), - baseTheme.horizontalSpacerSmall, - FilterChip( - label: const Text('Zeitraum der Pflege'), - selected: displayFilterSet.contains('maintenance'), - selectedColor: baseTheme.currentColorScheme.inversePrimary, - onSelected: (bool selected) { - setState(() { - if (selected) { - displayFilterSet.add('maintenance'); - } else { - displayFilterSet.remove('maintenance'); - } - }); - }, - ), - ], - ), - ),*/ Padding( padding: const EdgeInsets.only(top: 32, left: 32, right: 32), child: _buildTableHeader(fixedWidth), diff --git a/lib/src/pages/cart/cart_page.dart b/lib/src/pages/cart/cart_page.dart index 76c663b..2d433c8 100644 --- a/lib/src/pages/cart/cart_page.dart +++ b/lib/src/pages/cart/cart_page.dart @@ -62,10 +62,12 @@ class CalendarPageState extends State { @override Widget build(BuildContext context) { + final AmbitoTheme theme = getTheme(context); return Scaffold( appBar: AmbitoAppbar( links: const ['dashboard', 'massnahmen'], breakpoint: Breakpoint.fromContext(context), + theme: theme, ), body: Center( child: Padding( @@ -89,7 +91,7 @@ class CalendarPageState extends State { List appointments = []; appointments.add(Appointment( startTime: DateTime.now(), - endTime: DateTime.now().add(Duration(minutes: 10)), + endTime: DateTime.now().add(const Duration(minutes: 10)), subject: 'Meeting', isAllDay: true, color: Colors.blue, diff --git a/lib/src/pages/dashboard/dashboard_page.dart b/lib/src/pages/dashboard/dashboard_page.dart index a7d413a..bf013bd 100644 --- a/lib/src/pages/dashboard/dashboard_page.dart +++ b/lib/src/pages/dashboard/dashboard_page.dart @@ -4,7 +4,6 @@ import 'package:get/get.dart'; import 'package:percent_indicator/linear_percent_indicator.dart'; import 'package:screen_breakpoints/screen_breakpoints.dart'; -import '../../../main.dart'; import '../../widgets/appbar/ambito_appbar.dart'; class DashboardPage extends StatefulWidget { @@ -23,6 +22,16 @@ class DashboardPageState extends State { @override void initState() { + cards = []; + super.initState(); + } + + @override + Widget build(BuildContext context) { + final AmbitoTheme theme = getTheme(context); + + cards = []; + cards.add( _buildCard( Colors.green, @@ -55,15 +64,12 @@ class DashboardPageState extends State { '/dashboard/stammdaten', ), ); - super.initState(); - } - @override - Widget build(BuildContext context) { return Scaffold( appBar: AmbitoAppbar( links: const ['dashboard', 'massnahmen'], breakpoint: Breakpoint.fromContext(context), + theme: theme, ), body: SingleChildScrollView( child: Align( @@ -75,22 +81,21 @@ class DashboardPageState extends State { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - largeTheme.verticalSpacerMax, + theme.verticalSpacerMax, Text( 'Willkommen, Max Mustermann!', textAlign: TextAlign.start, - style: largeTheme.currentThemeData.textTheme.headlineLarge - ?.copyWith( - color: largeTheme.currentColorScheme.onSurface, + style: theme.headlineLarge.copyWith( + color: theme.currentColorScheme.onSurface, ), ), - largeTheme.verticalSpacerMax, + theme.verticalSpacerMax, Wrap( alignment: WrapAlignment.center, spacing: 32, children: cards, ), - largeTheme.verticalSpacerMax, + theme.verticalSpacerMax, Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, @@ -103,13 +108,11 @@ class DashboardPageState extends State { Text( 'Biodiversitätsbewertung', textAlign: TextAlign.start, - style: largeTheme - .currentThemeData.textTheme.headlineMedium - ?.copyWith( - color: largeTheme.currentColorScheme.onSurface, + style: theme.headlineMedium.copyWith( + color: theme.currentColorScheme.onSurface, ), ), - largeTheme.verticalSpacer, + theme.verticalSpacer, SizedBox( width: 532, child: Card( @@ -123,14 +126,14 @@ class DashboardPageState extends State { Text( 'Fragebögen', textAlign: TextAlign.left, - style: largeTheme.currentThemeData - .textTheme.headlineSmall + style: theme.currentThemeData.textTheme + .headlineSmall ?.copyWith( color: orangeColors['primary'], fontWeight: FontWeight.bold, ), ), - largeTheme.verticalSpacerSmall, + theme.verticalSpacerSmall, Row( children: [ LinearPercentIndicator( @@ -139,8 +142,8 @@ class DashboardPageState extends State { animation: true, percent: 0.8, padding: EdgeInsets.zero, - backgroundColor: largeTheme - .currentColorScheme.surface, + backgroundColor: + theme.currentColorScheme.surface, progressColor: orangeColors['primary'], barRadius: const Radius.circular(8), @@ -166,15 +169,15 @@ class DashboardPageState extends State { ), ], ), - largeTheme.verticalSpacerSmall, + theme.verticalSpacerSmall, Text( '4 / 5 abgeschlossen', textAlign: TextAlign.start, - style: largeTheme + style: theme .currentThemeData.textTheme.bodyLarge ?.copyWith( - color: largeTheme - .currentColorScheme.onSurface, + color: + theme.currentColorScheme.onSurface, ), ), ], @@ -182,7 +185,7 @@ class DashboardPageState extends State { ), ), ), - largeTheme.verticalSpacer, + theme.verticalSpacer, SizedBox( width: 532, child: Card( @@ -196,14 +199,14 @@ class DashboardPageState extends State { Text( 'Ergebnisse', textAlign: TextAlign.left, - style: largeTheme.currentThemeData - .textTheme.headlineSmall + style: theme.currentThemeData.textTheme + .headlineSmall ?.copyWith( color: greenColors['primary'], fontWeight: FontWeight.bold, ), ), - largeTheme.verticalSpacerSmall, + theme.verticalSpacerSmall, Row( children: [ LinearPercentIndicator( @@ -212,25 +215,25 @@ class DashboardPageState extends State { animation: true, percent: 0.8, padding: EdgeInsets.zero, - backgroundColor: largeTheme - .currentColorScheme.surface, + backgroundColor: + theme.currentColorScheme.surface, progressColor: greenColors['primary'], barRadius: const Radius.circular(8), ), ], ), - largeTheme.verticalSpacerSmall, + theme.verticalSpacerSmall, Text( 'Weinberg: 80%', textAlign: TextAlign.start, - style: largeTheme + style: theme .currentThemeData.textTheme.bodyLarge ?.copyWith( - color: largeTheme - .currentColorScheme.onSurface, + color: + theme.currentColorScheme.onSurface, ), ), - largeTheme.verticalSpacerSmall, + theme.verticalSpacerSmall, Row( children: [ LinearPercentIndicator( @@ -239,25 +242,25 @@ class DashboardPageState extends State { animation: true, percent: 0.52, padding: EdgeInsets.zero, - backgroundColor: largeTheme - .currentColorScheme.surface, + backgroundColor: + theme.currentColorScheme.surface, progressColor: greenColors['primary'], barRadius: const Radius.circular(8), ), ], ), - largeTheme.verticalSpacerSmall, + theme.verticalSpacerSmall, Text( 'Landschaft: 52%', textAlign: TextAlign.start, - style: largeTheme + style: theme .currentThemeData.textTheme.bodyLarge ?.copyWith( - color: largeTheme - .currentColorScheme.onSurface, + color: + theme.currentColorScheme.onSurface, ), ), - largeTheme.verticalSpacerSmall, + theme.verticalSpacerSmall, Row( children: [ LinearPercentIndicator( @@ -266,22 +269,22 @@ class DashboardPageState extends State { animation: true, percent: 0.27, padding: EdgeInsets.zero, - backgroundColor: largeTheme - .currentColorScheme.surface, + backgroundColor: + theme.currentColorScheme.surface, progressColor: greenColors['primary'], barRadius: const Radius.circular(8), ), ], ), - largeTheme.verticalSpacerSmall, + theme.verticalSpacerSmall, Text( 'Betriebsstätte: 27%', textAlign: TextAlign.start, - style: largeTheme + style: theme .currentThemeData.textTheme.bodyLarge ?.copyWith( - color: largeTheme - .currentColorScheme.onSurface, + color: + theme.currentColorScheme.onSurface, ), ), ], @@ -302,28 +305,27 @@ class DashboardPageState extends State { Text( 'Förderungen', textAlign: TextAlign.start, - style: largeTheme + style: theme .currentThemeData.textTheme.headlineMedium ?.copyWith( - color: largeTheme.currentColorScheme.onSurface, + color: theme.currentColorScheme.onSurface, ), ), - largeTheme.verticalSpacer, + theme.verticalSpacer, Text( 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.', textAlign: TextAlign.start, - style: largeTheme - .currentThemeData.textTheme.bodyLarge + style: theme.currentThemeData.textTheme.bodyLarge ?.copyWith( - color: largeTheme.currentColorScheme.onSurface, + color: theme.currentColorScheme.onSurface, ), ), - largeTheme.verticalSpacer, + theme.verticalSpacer, _buildProjectCard( 'Projekt A', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.', ), - largeTheme.verticalSpacer, + theme.verticalSpacer, _buildProjectCard( 'Projekt B', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.', @@ -342,6 +344,8 @@ class DashboardPageState extends State { } Widget _buildCard(Color background, String image, String title, String link) { + final AmbitoTheme theme = getTheme(context); + return GestureDetector( onTap: () { Get.toNamed(link); @@ -365,7 +369,7 @@ class DashboardPageState extends State { child: Text( title, textAlign: TextAlign.center, - style: largeTheme.currentThemeData.textTheme.headlineSmall + style: theme.currentThemeData.textTheme.headlineSmall ?.copyWith( color: const Color(0xFF666666), fontWeight: FontWeight.bold, @@ -381,6 +385,8 @@ class DashboardPageState extends State { } Widget _buildProjectCard(String title, String text) { + final AmbitoTheme theme = getTheme(context); + return SizedBox( width: 532, child: Card( @@ -394,13 +400,12 @@ class DashboardPageState extends State { Text( title, textAlign: TextAlign.center, - style: largeTheme.currentThemeData.textTheme.headlineSmall - ?.copyWith( + style: theme.currentThemeData.textTheme.headlineSmall?.copyWith( color: greenColors['primary'], fontWeight: FontWeight.bold, ), ), - largeTheme.verticalSpacerSmall, + theme.verticalSpacerSmall, Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -411,9 +416,9 @@ class DashboardPageState extends State { overflow: TextOverflow.ellipsis, maxLines: 3, textAlign: TextAlign.start, - style: largeTheme.currentThemeData.textTheme.bodyLarge - ?.copyWith( - color: largeTheme.currentColorScheme.onSurface, + style: + theme.currentThemeData.textTheme.bodyLarge?.copyWith( + color: theme.currentColorScheme.onSurface, ), ), ), diff --git a/lib/src/pages/start/start_page.dart b/lib/src/pages/start/start_page.dart index b82baca..1801760 100644 --- a/lib/src/pages/start/start_page.dart +++ b/lib/src/pages/start/start_page.dart @@ -8,7 +8,8 @@ import 'package:flutter_breadcrumb/flutter_breadcrumb.dart'; import 'package:get/get.dart'; import 'package:screen_breakpoints/screen_breakpoints.dart'; -import '../../../main.dart'; +import '../../consts/consts.dart'; +import '../../packages/ambito_theme/ambito_theme.dart'; class StartPage extends StatefulWidget { const StartPage({super.key, required this.activeLink}); @@ -36,9 +37,11 @@ class StartPageState extends State { @override Widget build(BuildContext context) { + final AmbitoTheme theme = getTheme(context); return Scaffold( appBar: AmbitoAppbar( breakpoint: Breakpoint.fromContext(context), + theme: theme, ), body: Column( crossAxisAlignment: CrossAxisAlignment.center, diff --git a/lib/src/widgets/appbar/ambito_appbar.dart b/lib/src/widgets/appbar/ambito_appbar.dart index 5f8c659..d3548ec 100644 --- a/lib/src/widgets/appbar/ambito_appbar.dart +++ b/lib/src/widgets/appbar/ambito_appbar.dart @@ -1,12 +1,17 @@ -import 'package:ambito/main.dart'; import 'package:ambito/src/extensions/extensions.dart'; import 'package:ambito/src/packages/ambito_theme/ambito_theme.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:screen_breakpoints/screen_breakpoints.dart'; +import '../../config/config.dart'; + class AmbitoAppbar extends AppBar { - AmbitoAppbar({super.key, List? links, required Breakpoint breakpoint}) + AmbitoAppbar( + {super.key, + List? links, + required Breakpoint breakpoint, + required AmbitoTheme theme}) : super( automaticallyImplyLeading: false, leading: Padding( @@ -31,7 +36,7 @@ class AmbitoAppbar extends AppBar { builder: (context) => _links(context, links), ), toolbarHeight: 80, - backgroundColor: largeTheme.currentColorScheme.primaryContainer, + backgroundColor: theme.currentColorScheme.primaryContainer, actions: [ Text(breakpoint.breakpoint.toString()), IconButton( @@ -40,7 +45,7 @@ class AmbitoAppbar extends AppBar { }, icon: Icon( Icons.notifications, - color: largeTheme.currentColorScheme.primary, + color: theme.currentColorScheme.primary, ), ), if (breakpoint >= myBreakpoints.md) @@ -50,7 +55,7 @@ class AmbitoAppbar extends AppBar { }, icon: Icon( Icons.calendar_view_month, - color: largeTheme.currentColorScheme.primary, + color: theme.currentColorScheme.primary, ), ), if (breakpoint >= myBreakpoints.md) @@ -60,7 +65,7 @@ class AmbitoAppbar extends AppBar { }, icon: Icon( Icons.calendar_month, - color: largeTheme.currentColorScheme.primary, + color: theme.currentColorScheme.primary, ), ), if (breakpoint >= myBreakpoints.md) @@ -68,7 +73,7 @@ class AmbitoAppbar extends AppBar { onSelected: (item) {}, icon: Icon( Icons.person, - color: largeTheme.currentColorScheme.primary, + color: theme.currentColorScheme.primary, ), itemBuilder: ( BuildContext context, diff --git a/lib/src/widgets/form/fields/field_daterangepicker.dart b/lib/src/widgets/form/fields/field_daterangepicker.dart index aea3e00..780a9f4 100644 --- a/lib/src/widgets/form/fields/field_daterangepicker.dart +++ b/lib/src/widgets/form/fields/field_daterangepicker.dart @@ -20,7 +20,7 @@ class FieldDaterangepicker extends FormWidgetField { final List entries; @override - FormBuilderField get() { + FormBuilderField get(theme) { DateTime now = DateTime.now(); return FormBuilderDateRangePicker( diff --git a/lib/src/widgets/form/fields/field_dropdown.dart b/lib/src/widgets/form/fields/field_dropdown.dart index e69671e..c668f68 100644 --- a/lib/src/widgets/form/fields/field_dropdown.dart +++ b/lib/src/widgets/form/fields/field_dropdown.dart @@ -20,7 +20,7 @@ class FieldDropdown extends FormWidgetField { final List entries; @override - FormBuilderField get() { + FormBuilderField get(theme) { return FormBuilderDropdown( name: name, initialValue: filterValue, diff --git a/lib/src/widgets/form/fields/field_monthsrangepicker.dart b/lib/src/widgets/form/fields/field_monthsrangepicker.dart index bc305ef..03dded8 100644 --- a/lib/src/widgets/form/fields/field_monthsrangepicker.dart +++ b/lib/src/widgets/form/fields/field_monthsrangepicker.dart @@ -21,7 +21,7 @@ class FieldMonthsRangepicker extends FormWidgetField { final List entries; @override - Widget get() { + Widget get(theme) { return SfDateRangePicker( minDate: DateTime(2024, 1), maxDate: DateTime(2024, 12, 31), diff --git a/lib/src/widgets/form/fields/field_title.dart b/lib/src/widgets/form/fields/field_title.dart index feaea47..1c14e6a 100644 --- a/lib/src/widgets/form/fields/field_title.dart +++ b/lib/src/widgets/form/fields/field_title.dart @@ -1,4 +1,3 @@ -import 'package:ambito/main.dart'; import 'package:ambito/src/widgets/form/form_widget.dart'; import 'package:flutter/material.dart'; @@ -10,13 +9,13 @@ class FieldTitle extends FormWidgetField { final String text; @override - Widget get() { + Widget get(theme) { return Align( alignment: Alignment.centerLeft, child: Text( text, textAlign: TextAlign.start, - style: largeTheme.currentThemeData.textTheme.titleLarge, + style: theme.titleLarge, ), ); } diff --git a/lib/src/widgets/form/form_widget.dart b/lib/src/widgets/form/form_widget.dart index eef7e5a..9291717 100644 --- a/lib/src/widgets/form/form_widget.dart +++ b/lib/src/widgets/form/form_widget.dart @@ -2,8 +2,10 @@ import 'package:ambito/src/widgets/form/form_widget_type.dart'; import 'package:flutter/material.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; +import '../../packages/ambito_theme/ambito_theme.dart'; + abstract class FormWidgetField { - Widget get() { + Widget get(AmbitoTheme theme) { return FormBuilderTextField(name: ''); } } @@ -18,25 +20,27 @@ class FormWidget extends StatelessWidget { @override Widget build(BuildContext context) { + final AmbitoTheme theme = getTheme(context); + return SizedBox( child: FormBuilder( key: _formKey, child: (type == FormWidgetType.vertical) ? Column( children: fields - .map((element) => _getElementVertical(element)) + .map((element) => _getElementVertical(element, theme)) .toList(), ) : Row( - children: fields.map((element) => element.get()).toList(), + children: fields.map((element) => element.get(theme)).toList(), ), )); } - Widget _getElementVertical(FormWidgetField element) { + Widget _getElementVertical(FormWidgetField element, AmbitoTheme theme) { return Padding( padding: const EdgeInsets.only(bottom: 16), - child: element.get(), + child: element.get(theme), ); } } diff --git a/lib/src/widgets/page/base_page.dart b/lib/src/widgets/page/base_page.dart new file mode 100644 index 0000000..5247c51 --- /dev/null +++ b/lib/src/widgets/page/base_page.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; +import 'package:screen_breakpoints/screen_breakpoints.dart'; + +import '../../packages/ambito_theme/ambito_theme.dart'; +import '../appbar/ambito_appbar.dart'; + +class BasePage { + Widget getPage(BuildContext context, Widget body) { + final AmbitoTheme theme = getTheme(context); + + return Scaffold( + appBar: AmbitoAppbar( + links: const ['dashboard', 'massnahmen'], + breakpoint: Breakpoint.fromContext(context), + theme: theme, + ), + body: body, + ); + } +}