Map working - (only google, mapContext issue on selected point)

This commit is contained in:
Thomas Fransolet 2025-06-19 16:50:28 +02:00
parent 4e9dc59df9
commit b20a112eb2
3 changed files with 255 additions and 325 deletions

View File

@ -38,7 +38,7 @@ class _FilterTree extends State<FilterTree> {
Widget build(BuildContext context) {
return ListView.builder(
itemBuilder: (BuildContext context, int index) {
return _buildNode(widget.data[index], EdgeInsets.all(0));
return _buildNode(widget.data[index], const EdgeInsets.all(0));
},
itemCount: widget.data.length,
);
@ -65,11 +65,11 @@ class _FilterTree extends State<FilterTree> {
child: ExpansionTile(
iconColor: widget.checkBoxColor,
collapsedIconColor: widget.checkBoxColor,
tilePadding: EdgeInsets.fromLTRB(0, 0, 0, 0),
tilePadding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
initiallyExpanded: node.show,
title: Container(
margin: EdgeInsets.only(left: 0),
padding: EdgeInsets.only(left: 0),
margin: const EdgeInsets.only(left: 0),
padding: const EdgeInsets.only(left: 0),
child: Text(
node.title,
style: TextStyle(color: widget.textColor ?? Colors.black),
@ -86,7 +86,7 @@ class _FilterTree extends State<FilterTree> {
),
children: node.children
.map((child) => _buildNode(
child, widget.childrenPadding ?? EdgeInsets.all(0)))
child, widget.childrenPadding ?? const EdgeInsets.all(0)))
.toList(),
),
),

View File

@ -14,14 +14,13 @@ import 'package:mymuseum_visitapp/app_context.dart';
import 'package:photo_view/photo_view.dart';
import 'package:provider/provider.dart';
import 'package:html/parser.dart' show parse;
import 'package:qr_flutter/qr_flutter.dart';
import '../../../constants.dart';
import 'map_context.dart';
class MarkerViewWidget extends StatefulWidget {
MarkerViewWidget();
const MarkerViewWidget({super.key});
@override
_MarkerInfoWidget createState() => _MarkerInfoWidget();
@ -54,21 +53,21 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
var language = visitAppContext.language;
GeoPointDTO? selectedPoint = mapContext.getSelectedPoint() as GeoPointDTO?;
ScrollController scrollDescription = new ScrollController();
ScrollController scrollPrice = new ScrollController();
ScrollController scrollDescription = ScrollController();
ScrollController scrollPrice = ScrollController();
var isPointPrice = selectedPoint != null && selectedPoint.prices != null && selectedPoint.prices!.isNotEmpty && selectedPoint.prices!.any((d) => d.language == language) && selectedPoint.prices!.firstWhere((d) => d.language == language).value != null && selectedPoint.prices!.firstWhere((d) => d.language == language).value!.trim().length > 0;
var isPointPrice = selectedPoint != null && selectedPoint.prices != null && selectedPoint.prices!.isNotEmpty && selectedPoint.prices!.any((d) => d.language == language) && selectedPoint.prices!.firstWhere((d) => d.language == language).value != null && selectedPoint.prices!.firstWhere((d) => d.language == language).value!.trim().isNotEmpty;
Color primaryColor = new Color(int.parse(visitAppContext.configuration!.primaryColor!.split('(0x')[1].split(')')[0], radix: 16));
Color primaryColor = Color(int.parse(visitAppContext.configuration!.primaryColor!.split('(0x')[1].split(')')[0], radix: 16));
Size sizeMarker = Size(size.width * 0.93, size.height * 0.83);
Size sizeMarker = Size(size.width * 0.93, size.height * 0.8);
return Center(
child: Visibility(
visible: selectedPoint != null,
child: Container(
width: sizeMarker.width,
height: sizeMarker.height,
margin: EdgeInsets.symmetric(vertical: 3, horizontal: 4),
margin: const EdgeInsets.symmetric(vertical: 3, horizontal: 4),
decoration: BoxDecoration(
color: kBackgroundColor, // Colors.amberAccent //kBackgroundLight,
//shape: BoxShape.rectangle,
@ -84,97 +83,70 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
),
child: Stack(
children: <Widget> [
Positioned(
right: 5,
top: 5,
child: InkWell(
onTap: () {
setState(() {
mapContext.setSelectedPoint(null);
mapContext.setSelectedPointForNavigate(null);
});
},
child: Container(
width: 50,
height: 50,
if(selectedPoint != null)
ClipRRect(
borderRadius: BorderRadius.only(topLeft: Radius.circular(visitAppContext.configuration!.roundedValue?.toDouble() ?? 20.0), topRight: Radius.circular(visitAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)),
child: Stack(
children: [
Container(
decoration: BoxDecoration(
color: kBackgroundGrey,
shape: BoxShape.circle,
boxShadow: [
boxShadow: const [
BoxShadow(
color: kBackgroundGrey,
color: kMainGrey,
spreadRadius: 0.5,
blurRadius: 1.1,
offset: Offset(0, 1.1), // changes position of shadow
blurRadius: 5,
offset: Offset(0, 1), // changes position of shadow
),
],
gradient: const LinearGradient(
begin: Alignment.centerRight,
end: Alignment.centerLeft,
colors: [
kMainColor0,
kMainColor1,
kMainColor2,
],
),
border: const Border(right: BorderSide(width: 0.05, color: kMainGrey)),
color: Colors.grey,
image: selectedPoint.imageUrl != null ? DecorationImage(
fit: BoxFit.cover,
opacity: 0.4,
image: NetworkImage(
selectedPoint.imageUrl!,
),
): null
),
width: size.width,
height: 75,
child: Center(
child: HtmlWidget(
selectedPoint.title!.firstWhere((t) => t.language == language).value!,
textStyle: const TextStyle(fontSize: 20.0),
customStylesBuilder: (element)
{
return {'text-align': 'center', 'font-family': "Roboto", '-webkit-line-clamp': "2"};
},
),
),
),
],
),
child: Icon(
Icons.close,
size: 25,
color: Colors.white,
),
),
),
),
if(selectedPoint != null)
Row(
children: [
selectedPoint.imageResourceId != null && selectedPoint.imageUrl != null ? ClipRRect(
borderRadius: BorderRadius.only(topLeft: Radius.circular(visitAppContext.configuration!.roundedValue?.toDouble() ?? 20.0), bottomLeft: Radius.circular(visitAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)),
child: Container(
child: Center(
child: Container(
decoration: BoxDecoration(
border: Border(right: BorderSide(width: 0.05, color: kMainGrey)),
color: Colors.grey,
),
width: size.width * 0.17,
height: size.height,
child: CachedNetworkImage(
imageUrl: selectedPoint.imageUrl!,
width: size.width,
fit: BoxFit.cover,
progressIndicatorBuilder: (context, url, downloadProgress) {
return Center(
child: SizedBox(
width: 50,
height: 50,
child: LoadingCommon(),
),
);
},
errorWidget: (context, url, error) => Icon(Icons.error),
),
),
)
),
): SizedBox(),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(top: 8.0, left: 15.0),
child: Container(
//color: Colors.green,
height: size.height * 0.06,
width: size.width * 0.65,
child: HtmlWidget(
selectedPoint.title!.firstWhere((t) => t.language == language).value!,
textStyle: TextStyle(fontSize: 20.0),
),
),
),
Row(
padding: const EdgeInsets.only(top: 75),
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
//mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(left: 15),
child: Column(
children: [
Container(
height: isPointPrice && selectedPoint.prices!.firstWhere((d) => d.language == language).value!.length > breakPointPrice ? size.height * 0.50 : size.height * 0.7,
width: size.width * 0.38,
padding: const EdgeInsets.all(6),
child: Container(
height: size.height * 0.4,
width: size.width,
decoration: BoxDecoration(
color: kBackgroundLight,
borderRadius: BorderRadius.all(Radius.circular(visitAppContext.configuration!.roundedValue?.toDouble() ?? 20.0))
@ -193,13 +165,13 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
if(selectedPoint.description!.any((d) => d.language == language) && selectedPoint.description!.firstWhere((d) => d.language == language).value != null && selectedPoint.description!.firstWhere((d) => d.language == language).value!.trim().length > 0)
if(selectedPoint.description!.any((d) => d.language == language) && selectedPoint.description!.firstWhere((d) => d.language == language).value != null && selectedPoint.description!.firstWhere((d) => d.language == language).value!.trim().isNotEmpty)
HtmlWidget(
selectedPoint.description!.firstWhere((d) => d.language == language).value!,
customStylesBuilder: (element) {
return {'text-align': 'left', 'font-family': "Roboto"};
},
textStyle: TextStyle(fontSize: kDescriptionSize),
textStyle: const TextStyle(fontSize: kMenuDescriptionDetailSize),
),
],
),
@ -208,10 +180,46 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
height: size.height * 0.2,
child: CarouselSlider(
carouselController: sliderController,
options: CarouselOptions(
onPageChanged: (int index, CarouselPageChangedReason reason) {
currentIndex.value = index + 1;
},
height: size.height *0.33,
enlargeCenterPage: true,
pageSnapping: true,
reverse: false,
),
items: selectedPoint.contents!.map<Widget>((ContentDTO i) {
return Builder(
builder: (BuildContext context) {
AppContext appContext = Provider.of<AppContext>(context);
var resourcetoShow = getElementForResource(context, appContext, i, true);
return resourcetoShow;
},
);
}).toList(),
),
),
Padding(
padding: const EdgeInsets.only(top: 10.0),
child: Column(
children: [
if(isPointPrice && selectedPoint.prices!.firstWhere((d) => d.language == language).value!.length > breakPointPrice)
Container(
height: size.height * 0.20,
width: size.width * 0.38,
Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
child: Container(
height: size.height * 0.18,
width: size.width,
decoration: BoxDecoration(
color: kBackgroundLight,
borderRadius: BorderRadius.all(Radius.circular(visitAppContext.configuration!.roundedValue?.toDouble() ?? 20.0))
@ -239,7 +247,7 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
customStylesBuilder: (element) {
return {'text-align': 'left', 'font-family': "Roboto"};
},
textStyle: TextStyle(fontSize: kDescriptionSize),
textStyle: const TextStyle(fontSize: kMenuDescriptionDetailSize),
),
],
),
@ -248,88 +256,7 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
),
),
),
],
),
),
SizedBox(
width: size.width * 0.32,
height: size.height * 0.7,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
//color: Colors.green,
height: size.height * 0.35,
child: CarouselSlider(
carouselController: sliderController,
options: CarouselOptions(
onPageChanged: (int index, CarouselPageChangedReason reason) {
currentIndex.value = index + 1;
},
height: size.height *0.33,
enlargeCenterPage: true,
pageSnapping: true,
reverse: false,
),
items: selectedPoint.contents!.map<Widget>((ContentDTO i) {
return Builder(
builder: (BuildContext context) {
AppContext appContext = Provider.of<AppContext>(context);
var resourcetoShow = getElementForResource(context, appContext, i, true);
return resourcetoShow;
},
);
}).toList(),
),
),
Container(
//color: Colors.yellow,
height: size.height * 0.33,
child: Padding(
padding: const EdgeInsets.only(top: 10.0),
child: Column(
children: [
/*if(isPointPrice && selectedPoint.prices!.firstWhere((d) => d.language == language).value!.length > breakPointPrice)
Container(
height: size.height * 0.1,
width: size.width * 0.38,
decoration: BoxDecoration(
color: kBackgroundLight,
borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0))
),
child: Padding(
padding: EdgeInsets.all(5),
child: Scrollbar(
thumbVisibility: true,
thickness: 2.0,
child: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.all(5.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
// todo add width ?
Padding(
padding: const EdgeInsets.all(5.0),
child: Icon(Icons.price_change_outlined, color: primaryColor, size: 13),
),
HtmlWidget(
selectedPoint.prices!.firstWhere((d) => d.language == language).value!,
customStylesBuilder: (element) {
return {'text-align': 'left', 'font-family': "Roboto"};
},
textStyle: TextStyle(fontSize: 12),
),
],
),
),
),
),
),
),*/
if(isPointPrice && selectedPoint.prices!.firstWhere((d) => d.language == language).value!.length <= breakPointPrice)
Row(
mainAxisAlignment: MainAxisAlignment.start,
@ -342,78 +269,52 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
customStylesBuilder: (element) {
return {'text-align': 'left', 'font-family': "Roboto"};
},
textStyle: TextStyle(fontSize: 12),
textStyle: const TextStyle(fontSize: 12),
),
)
],
),
selectedPoint.phone != null && selectedPoint.phone!.isNotEmpty && selectedPoint.phone!.any((d) => d.language == language) && selectedPoint.phone!.firstWhere((d) => d.language == language).value != null && selectedPoint.phone!.firstWhere((d) => d.language == language).value!.trim().length > 0 ? Row(
mainAxisAlignment: MainAxisAlignment.start,
selectedPoint.phone != null && selectedPoint.phone!.isNotEmpty && selectedPoint.phone!.any((d) => d.language == language) && selectedPoint.phone!.firstWhere((d) => d.language == language).value != null && selectedPoint.phone!.firstWhere((d) => d.language == language).value!.trim().isNotEmpty ? Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.phone, color: primaryColor, size: 13),
Padding(
padding: const EdgeInsets.all(4.0),
child: Text(parse(selectedPoint.phone!.firstWhere((p) => p.language == language).value!).documentElement!.text, style: TextStyle(fontSize: 12)),
child: Text(parse(selectedPoint.phone!.firstWhere((p) => p.language == language).value!).documentElement!.text, style: const TextStyle(fontSize: 18)),
)
],
): SizedBox(),
selectedPoint.email != null && selectedPoint.email!.isNotEmpty && selectedPoint.email!.any((d) => d.language == language) && selectedPoint.email!.firstWhere((d) => d.language == language).value != null && selectedPoint.email!.firstWhere((d) => d.language == language).value!.trim().length > 0 ? Row(
mainAxisAlignment: MainAxisAlignment.start,
): const SizedBox(),
selectedPoint.email != null && selectedPoint.email!.isNotEmpty && selectedPoint.email!.any((d) => d.language == language) && selectedPoint.email!.firstWhere((d) => d.language == language).value != null && selectedPoint.email!.firstWhere((d) => d.language == language).value!.trim().isNotEmpty ? Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.email, color: primaryColor, size: 13),
Padding(
padding: const EdgeInsets.all(4.0),
child: SizedBox(
width: size.width*0.25,
child: AutoSizeText(parse(selectedPoint.email!.firstWhere((p) => p.language == language).value!).documentElement!.text, style: TextStyle(fontSize: 12), maxLines: 3)
),
child: AutoSizeText(parse(selectedPoint.email!.firstWhere((p) => p.language == language).value!).documentElement!.text, style: const TextStyle(fontSize: 18), maxLines: 3),
)
],
): SizedBox(),
selectedPoint.site != null && selectedPoint.site!.isNotEmpty && selectedPoint.site!.any((d) => d.language == language) && selectedPoint.site!.firstWhere((d) => d.language == language).value != null && selectedPoint.site!.firstWhere((d) => d.language == language).value!.trim().length > 0 ? Row(
mainAxisAlignment: MainAxisAlignment.start,
): const SizedBox(),
selectedPoint.site != null && selectedPoint.site!.isNotEmpty && selectedPoint.site!.any((d) => d.language == language) && selectedPoint.site!.firstWhere((d) => d.language == language).value != null && selectedPoint.site!.firstWhere((d) => d.language == language).value!.trim().isNotEmpty ? Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.public, color: primaryColor, size: 13),
Padding(
padding: const EdgeInsets.all(4.0),
child: SizedBox(
width: size.width*0.25,
child: AutoSizeText(parse(selectedPoint.site!.firstWhere((p) => p.language == language).value!).documentElement!.text, style: TextStyle(fontSize: 12), maxLines: 3)
child: AutoSizeText(parse(selectedPoint.site!.firstWhere((p) => p.language == language).value!).documentElement!.text, style: const TextStyle(fontSize: 18), maxLines: 3),
)
],
): const SizedBox(),
],
),
),
],
),
)
],
): SizedBox(),
selectedPoint.site != null && selectedPoint.site!.isNotEmpty && selectedPoint.site!.any((d) => d.language == language) && selectedPoint.site!.firstWhere((d) => d.language == language).value != null && selectedPoint.site!.firstWhere((d) => d.language == language).value!.trim().length > 0 ? Expanded(
child: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: size.width *0.1,
height: 120,
child: QrImageView(
padding: EdgeInsets.only(left: 5.0, top: 5.0, bottom: 5.0, right: 5.0),
data: parse(selectedPoint.site!.firstWhere((p) => p.language == language).value!).documentElement!.text,
version: QrVersions.auto,
size: 50.0,
),
),
),
),
): SizedBox(),
],
),
),
),
],
),
),
)
],
)
],
),
],
),
/*Align(
alignment: Alignment.topCenter,
child: Padding(
@ -560,6 +461,31 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
),
),
),*/
Positioned(
right: 6.5,
top: 12.5,
child: GestureDetector(
onTap: () {
setState(() {
mapContext.setSelectedPoint(null);
mapContext.setSelectedPointForNavigate(null);
});
},
child: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
color: primaryColor,
shape: BoxShape.circle,
),
child: const Icon(
Icons.close,
size: 25,
color: Colors.white,
),
),
),
),
])
),
),
@ -592,8 +518,9 @@ getElementForResource(BuildContext context, AppContext appContext, ContentDTO i,
borderRadius: BorderRadius.all(Radius.circular(visitAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)),
color: kBackgroundColor,
),
height: size.height * 0.8,
width: size.width * 0.8,
constraints: const BoxConstraints(minWidth: 250, minHeight: 250, maxHeight: 350),
height: size.height * 0.6,
width: size.width * 0.85,
child: Container(
decoration: BoxDecoration(
//color: Colors.yellow,
@ -653,8 +580,9 @@ getElementForResource(BuildContext context, AppContext appContext, ContentDTO i,
borderRadius: BorderRadius.all(Radius.circular(visitAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)),
color: kBackgroundColor,
),
height: size.height * 0.8,
width: size.width * 0.8,
constraints: const BoxConstraints(minWidth: 250, minHeight: 250, maxHeight: 350),
height: size.height * 0.6,
width: size.width * 0.85,
child: Center(child: showElementForResource(ResourceDTO(id: i.resourceId, url: i.resource?.url, type: i.resource?.type), appContext, false, true)),
),
);
@ -666,7 +594,6 @@ getElementForResource(BuildContext context, AppContext appContext, ContentDTO i,
ignoring: i.resource!.type != ResourceType.Audio,
child: Container(
decoration: BoxDecoration(
color: Colors.yellow,
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(visitAppContext.configuration!.roundedValue?.toDouble() ?? 15.0),
),

View File

@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_beacon/flutter_beacon.dart';
import 'package:get/get.dart';
import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart';
import 'package:mymuseum_visitapp/Helpers/requirement_state_controller.dart';
import 'package:mymuseum_visitapp/Models/articleRead.dart';
import 'package:mymuseum_visitapp/Screens/Home/home.dart';
@ -26,6 +27,8 @@ void main() async {
Directory? appDocumentsDirectory = Platform.isIOS ? await getApplicationDocumentsDirectory() : await getDownloadsDirectory();
String localPath = appDocumentsDirectory!.path;
MapboxOptions.setAccessToken("pk.eyJ1IjoidGZyYW5zb2xldCIsImEiOiJjbHRpcGNvZDYwYWhkMnFxdmF0ampveW10In0.7xHN0NGvUfQu5ThS3RGJRw"); // TODO put in json file or resource file
if(localContext != null) {
print("we've got an local db !");
print(localContext);