From 2428d2255894e03f90dfba8c703dc93113dac483 Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Fri, 19 Apr 2024 17:23:29 +0200 Subject: [PATCH] Fix localisation bug --- lib/Components/Buttons/rounded_button.dart | 4 +-- lib/Components/loading_common.dart | 3 +- lib/Components/rounded_input_field.dart | 2 +- lib/Screens/MainView/section_page_detail.dart | 4 +-- lib/Screens/Map/geo_point_filter.dart | 28 +++++++++++++++---- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/lib/Components/Buttons/rounded_button.dart b/lib/Components/Buttons/rounded_button.dart index 994547a..cf62882 100644 --- a/lib/Components/Buttons/rounded_button.dart +++ b/lib/Components/Buttons/rounded_button.dart @@ -18,7 +18,7 @@ class RoundedButton extends StatelessWidget { this.text, this.press, this.icon, - this.color = kMainRed, + this.color = kTestSecondColor, this.textColor = Colors.white, this.fontSize, this.vertical, @@ -37,7 +37,7 @@ class RoundedButton extends StatelessWidget { backgroundColor: MaterialStateColor.resolveWith((states) => color!), shape: MaterialStateProperty.all( RoundedRectangleBorder( - borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration?.roundedValue?.toDouble() ?? 20.0), ) ) ), diff --git a/lib/Components/loading_common.dart b/lib/Components/loading_common.dart index dc9dd5a..520563f 100644 --- a/lib/Components/loading_common.dart +++ b/lib/Components/loading_common.dart @@ -71,8 +71,7 @@ class _LoadingCommonState extends State with TickerProviderStateM print("not a local loader succck"); return CachedNetworkImage( imageUrl: tabletAppContext.configuration!.loaderImageUrl!, - progressIndicatorBuilder: (context, url, downloadProgress) => - CircularProgressIndicator(value: downloadProgress.progress, color: primaryColor), + progressIndicatorBuilder: (context, url, downloadProgress) => CircularProgressIndicator(value: downloadProgress.progress, color: primaryColor), errorWidget: (context, url, error) => Icon(Icons.error), ); } else { diff --git a/lib/Components/rounded_input_field.dart b/lib/Components/rounded_input_field.dart index 9c8ee78..962f752 100644 --- a/lib/Components/rounded_input_field.dart +++ b/lib/Components/rounded_input_field.dart @@ -17,7 +17,7 @@ class RoundedInputField extends StatelessWidget { this.icon, this.color = kBackgroundGrey, this.textColor = kMainGrey, - this.iconColor = kMainRed, + this.iconColor = kTestSecondColor, this.onChanged, this.maxLength, // 50 this.isString = true, diff --git a/lib/Screens/MainView/section_page_detail.dart b/lib/Screens/MainView/section_page_detail.dart index c9a5c16..d155764 100644 --- a/lib/Screens/MainView/section_page_detail.dart +++ b/lib/Screens/MainView/section_page_detail.dart @@ -58,14 +58,14 @@ class _SectionPageDetailState extends State { child: Container( height: size.height, width: size.width, - color: widget.configurationDTO.imageId == null ? widget.configurationDTO.secondaryColor != null ? new Color(int.parse(widget.configurationDTO.secondaryColor!.split('(0x')[1].split(')')[0], radix: 16)): kBackgroundGrey : null, + /*color: widget.configurationDTO.imageId == null ? widget.configurationDTO.secondaryColor != null ? new Color(int.parse(widget.configurationDTO.secondaryColor!.split('(0x')[1].split(')')[0], radix: 16)): kBackgroundGrey : null, decoration: widget.configurationDTO.imageId != null ? BoxDecoration( image: new DecorationImage( fit: BoxFit.cover, colorFilter: new ColorFilter.mode(Colors.white.withOpacity(0.8), BlendMode.lighten), image: ImageCustomProvider.getImageProvider(appContext, widget.configurationDTO.imageId!, widget.configurationDTO.imageSource!), ), - ) : null, + ) : null,*/ child: Padding( padding: const EdgeInsets.all(8.0), child: Container( diff --git a/lib/Screens/Map/geo_point_filter.dart b/lib/Screens/Map/geo_point_filter.dart index 1e6ba71..4d58f2c 100644 --- a/lib/Screens/Map/geo_point_filter.dart +++ b/lib/Screens/Map/geo_point_filter.dart @@ -1,5 +1,6 @@ import 'dart:ui'; +import 'dart:math'; //import 'package:animated_tree_view/animated_tree_view.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -69,8 +70,11 @@ class _GeoPointFilterState extends State { // Pour chaque point sans categorie, créer un noeud for(var pointWithoutCat in geoPoints.where((gp) => gp.categorieId == null && gp.categorie == null)) { + TreeNode nodeWithoutCat = TreeNode( - id: int.parse(pointWithoutCat.latitude!.substring(0,10).replaceAll(".", "")+pointWithoutCat.longitude!.substring(0,10).replaceAll(".", "")), + id: int.parse( + (pointWithoutCat.latitude ?? '').substring(0, min(pointWithoutCat.latitude!.length, 10)).replaceAll(".", "") + (pointWithoutCat.longitude ?? '').substring(0, min(pointWithoutCat.longitude!.length, 10)).replaceAll(".", "") + ), title: parse(pointWithoutCat.title!.firstWhere((l) => l.language == widget.language).value!).documentElement!.text, children: [], checked: true, // default true @@ -97,7 +101,9 @@ class _GeoPointFilterState extends State { for (var geoPoint in geoPoints.where((gp) => gp.categorie != null || gp.categorieId != null)) { if (geoPoint.categorieId == category.id) { TreeNode geoPointNode = TreeNode( - id: int.parse(geoPoint.latitude!.substring(0,10).replaceAll(".", "")+geoPoint.longitude!.substring(0,10).replaceAll(".", "")), + id: int.parse( + (geoPoint.latitude ?? '').substring(0, min(geoPoint.latitude!.length, 10)).replaceAll(".", "") + (geoPoint.longitude ?? '').substring(0, min(geoPoint.longitude!.length, 10)).replaceAll(".", "") + ), title: parse(geoPoint.title!.firstWhere((l) => l.language == widget.language).value!).documentElement!.text, checked: true, // default true show: false, @@ -139,12 +145,16 @@ class _GeoPointFilterState extends State { if (node.children.isNotEmpty) { for (var childNode in node.children) { if (childNode.checked) { - checkedGeoPoints.add(widget.geoPoints.firstWhere((point) => int.parse(point.latitude!.substring(0,10).replaceAll(".", "")+point.longitude!.substring(0,10).replaceAll(".", "")) == childNode.id)); + checkedGeoPoints.add(widget.geoPoints.firstWhere((point) => int.parse( + (point.latitude ?? '').substring(0, min(point.latitude!.length, 10)).replaceAll(".", "") + (point.longitude ?? '').substring(0, min(point.longitude!.length, 10)).replaceAll(".", "") + ) == childNode.id)); } } } else { if(node.checked) { - checkedGeoPoints.add(widget.geoPoints.firstWhere((point) => int.parse(point.latitude!.substring(0,10).replaceAll(".", "")+point.longitude!.substring(0,10).replaceAll(".", "")) == node.id)); + checkedGeoPoints.add(widget.geoPoints.firstWhere((point) => int.parse( + (point.latitude ?? '').substring(0, min(point.latitude!.length, 10)).replaceAll(".", "") + (point.longitude ?? '').substring(0, min(point.longitude!.length, 10)).replaceAll(".", "") + ) == node.id)); } } } @@ -157,7 +167,15 @@ class _GeoPointFilterState extends State { List filteredNodes = []; for (var node in buildTreeNodes(widget.categories, widget.geoPoints)) { if (_nodeOrChildrenContainsText(node, searchText)) { - filteredNodes.add(node); + if(node.children.isNotEmpty) { + for (var childNode in node.children) { + if (_nodeOrChildrenContainsText(childNode, searchText)) { + filteredNodes.add(childNode); + } + } + } else { + filteredNodes.add(node); + } } } return filteredNodes;