mirror of
https://bitbucket.org/FransoletThomas/tablet-app.git
synced 2025-12-06 08:31:19 +00:00
wip map update (filter + icons (tbt)) + added section_page_detail
This commit is contained in:
parent
d9efad47f8
commit
cba728884f
@ -89,8 +89,6 @@ class _EventPopupState extends State<EventPopup> {
|
|||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final appContext = Provider.of<AppContext>(context);
|
final appContext = Provider.of<AppContext>(context);
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import 'package:tablet_app/Models/WeatherData.dart';
|
|||||||
import 'package:tablet_app/Screens/Agenda/agenda_view.dart';
|
import 'package:tablet_app/Screens/Agenda/agenda_view.dart';
|
||||||
import 'package:tablet_app/Screens/Article/article_view.dart';
|
import 'package:tablet_app/Screens/Article/article_view.dart';
|
||||||
import 'package:tablet_app/Screens/Configuration/config_view.dart';
|
import 'package:tablet_app/Screens/Configuration/config_view.dart';
|
||||||
|
import 'package:tablet_app/Screens/MainView/section_page_detail.dart';
|
||||||
import 'package:tablet_app/Screens/Weather/weather_view.dart';
|
import 'package:tablet_app/Screens/Weather/weather_view.dart';
|
||||||
import 'package:tablet_app/Screens/Map/map_context.dart';
|
import 'package:tablet_app/Screens/Map/map_context.dart';
|
||||||
import 'package:tablet_app/Screens/Map/map_view.dart';
|
import 'package:tablet_app/Screens/Map/map_view.dart';
|
||||||
@ -38,6 +39,9 @@ import 'package:tablet_app/Services/downloadService.dart';
|
|||||||
import 'package:tablet_app/app_context.dart';
|
import 'package:tablet_app/app_context.dart';
|
||||||
import 'package:tablet_app/constants.dart';
|
import 'package:tablet_app/constants.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:image/image.dart' as IMG;
|
||||||
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
import '../Quizz/quizz_view.dart';
|
import '../Quizz/quizz_view.dart';
|
||||||
import 'language_selection.dart';
|
import 'language_selection.dart';
|
||||||
@ -100,7 +104,7 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
/*if (!MQTTHelper.instance.isInstantiated)
|
/*if (!MQTTHelper.instance.isInstantiated)
|
||||||
MQTTHelper.instance.connect(appContext);*/
|
MQTTHelper.instance.connect(appContext);*/
|
||||||
|
|
||||||
if(sectionSelected != null) {
|
/*if(sectionSelected != null) {
|
||||||
var elementToShow;
|
var elementToShow;
|
||||||
print(sectionSelected!.type);
|
print(sectionSelected!.type);
|
||||||
switch (sectionSelected!.type) {
|
switch (sectionSelected!.type) {
|
||||||
@ -112,7 +116,22 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
longitude: null,
|
longitude: null,
|
||||||
title: '',
|
title: '',
|
||||||
description: '')),
|
description: '')),
|
||||||
child: MapViewWidget(section: sectionSelected!) /*FutureBuilder(
|
child: FutureBuilder(
|
||||||
|
future: getByteIcon(sectionSelected!),
|
||||||
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
|
return MapViewWidget(section: sectionSelected!, markerIcon: snapshot.data);
|
||||||
|
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||||
|
return Text("No data");
|
||||||
|
} else {
|
||||||
|
return Center(
|
||||||
|
child: Container(
|
||||||
|
child: LoadingCommon()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) /*FutureBuilder(
|
||||||
future: _url,
|
future: _url,
|
||||||
builder: (BuildContext context, AsyncSnapshot snapshot) => snapshot.hasData
|
builder: (BuildContext context, AsyncSnapshot snapshot) => snapshot.hasData
|
||||||
? WebViewWidget(url: snapshot.data,)
|
? WebViewWidget(url: snapshot.data,)
|
||||||
@ -195,27 +214,69 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
InkWell(
|
||||||
//color: Colors.grey,
|
onTap: () {
|
||||||
//width: size.width * 0.8,
|
Navigator.push(
|
||||||
child: Padding(
|
context,
|
||||||
padding: const EdgeInsets.only(left: 15.0, top: 10.0, bottom: 10.0),
|
MaterialPageRoute(
|
||||||
child: Container(
|
builder: (context) {
|
||||||
//color: Colors.grey,
|
return Scaffold(
|
||||||
child: AspectRatio(
|
body: ChangeNotifierProvider<MapContext>(
|
||||||
aspectRatio: 4 / 4,
|
create: (_) =>
|
||||||
child: isImageBackground ? Container(
|
MapContext(new MapMarker(
|
||||||
/*width: 125,
|
latitude: null,
|
||||||
height: 125,*/
|
longitude: null,
|
||||||
decoration: boxDecoration(appContext, sectionSelected!, true),
|
title: '',
|
||||||
) : Container(
|
description: '')),
|
||||||
decoration: BoxDecoration(
|
child: FutureBuilder(
|
||||||
color: sectionSelected!.imageSource == null ? kBackgroundLight : null, // default color if no image
|
future: getByteIcon(sectionSelected!),
|
||||||
shape: BoxShape.rectangle,
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
image: sectionSelected!.imageSource != null ? new DecorationImage(
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
fit: BoxFit.cover,
|
return MapViewWidget(section: sectionSelected!, markerIcon: snapshot.data);
|
||||||
image: ImageCustomProvider.getImageProvider(appContext, sectionSelected!.imageId!, sectionSelected!.imageSource!),
|
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||||
): null,
|
return Text("No data");
|
||||||
|
} else {
|
||||||
|
return Center(
|
||||||
|
child: Container(
|
||||||
|
child: LoadingCommon()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) /*FutureBuilder(
|
||||||
|
future: _url,
|
||||||
|
builder: (BuildContext context, AsyncSnapshot snapshot) => snapshot.hasData
|
||||||
|
? WebViewWidget(url: snapshot.data,)
|
||||||
|
: CircularProgressIndicator()),*/
|
||||||
|
)
|
||||||
|
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),// For pushAndRemoveUntil
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
color: Colors.grey,
|
||||||
|
//width: size.width * 0.8,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 15.0, top: 10.0, bottom: 10.0),
|
||||||
|
child: Container(
|
||||||
|
//color: Colors.grey,
|
||||||
|
child: AspectRatio(
|
||||||
|
aspectRatio: 4 / 4,
|
||||||
|
child: isImageBackground ? Container(
|
||||||
|
/*width: 125,
|
||||||
|
height: 125,*/
|
||||||
|
decoration: boxDecoration(appContext, sectionSelected!, true),
|
||||||
|
) : Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: sectionSelected!.imageSource == null ? kBackgroundLight : null, // default color if no image
|
||||||
|
shape: BoxShape.rectangle,
|
||||||
|
image: sectionSelected!.imageSource != null ? new DecorationImage(
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
image: ImageCustomProvider.getImageProvider(appContext, sectionSelected!.imageId!, sectionSelected!.imageSource!),
|
||||||
|
): null,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -327,7 +388,7 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
),
|
),
|
||||||
),*/
|
),*/
|
||||||
);
|
);
|
||||||
} else {
|
} else {*/
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
body: Container(
|
body: Container(
|
||||||
@ -384,7 +445,7 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
return Text("");
|
return Text("");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return getGridSections(appContext);
|
return getGridSections(appContext, textColor);
|
||||||
}
|
}
|
||||||
} else if (snapshot.connectionState == ConnectionState.none) {
|
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||||
return Text("No data");
|
return Text("No data");
|
||||||
@ -396,7 +457,7 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) : getGridSections(appContext),
|
) : getGridSections(appContext, textColor),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
/*if(configurationDTO.weatherCity != null && configurationDTO.weatherCity!.length > 2 && configurationDTO.weatherResult != null)
|
/*if(configurationDTO.weatherCity != null && configurationDTO.weatherCity!.length > 2 && configurationDTO.weatherResult != null)
|
||||||
@ -417,7 +478,7 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ConfigurationDTO?> getCurrentConfiguration(dynamic appContext) async {
|
Future<ConfigurationDTO?> getCurrentConfiguration(dynamic appContext) async {
|
||||||
@ -509,7 +570,7 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
return sectionsLocal;
|
return sectionsLocal;
|
||||||
}
|
}
|
||||||
|
|
||||||
getGridSections(AppContext appContext) {
|
getGridSections(AppContext appContext, Color textColor) {
|
||||||
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
|
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
|
||||||
|
|
||||||
if(sectionsLocal != null) {
|
if(sectionsLocal != null) {
|
||||||
@ -526,7 +587,16 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
sectionSelected = sectionsLocal![index];
|
//sectionSelected = sectionsLocal![index];
|
||||||
|
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) {
|
||||||
|
return SectionPageDetail(configurationDTO: configurationDTO, sectionDTO: sectionsLocal![index], textColor: textColor, isImageBackground: isImageBackground, elementToShow: getContent(sectionsLocal![index], isImageBackground));
|
||||||
|
},
|
||||||
|
),// For pushAndRemoveUntil
|
||||||
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
@ -599,21 +669,6 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double calculateFontSize(double parentWidth, double parentHeight, double baseSize) {
|
|
||||||
// La taille de base est basée sur la taille définie dans vos constantes (kWebMenuTitleDetailSize ou kMenuTitleDetailSize).
|
|
||||||
// Vous pouvez ajuster ce facteur en fonction de vos besoins.
|
|
||||||
double scaleFactor = 0.8;
|
|
||||||
|
|
||||||
// Calculez la taille de la police en fonction de la largeur et de la hauteur maximales disponibles
|
|
||||||
//double calculatedFontSize = parentWidth * scaleFactor;
|
|
||||||
|
|
||||||
// Vous pouvez également prendre en compte la hauteur ici si nécessaire
|
|
||||||
double calculatedFontSize = min(parentWidth, parentHeight) * scaleFactor;
|
|
||||||
|
|
||||||
// Utilisez la plus petite valeur entre la taille de base et la taille calculée
|
|
||||||
return calculatedFontSize < baseSize ? calculatedFontSize : baseSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) {
|
boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) {
|
||||||
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
|
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
|
||||||
return BoxDecoration(
|
return BoxDecoration(
|
||||||
@ -635,3 +690,118 @@ boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<Map<String, dynamic>>> getByteIcons(SectionDTO section) async {
|
||||||
|
var mapDTO = MapDTO.fromJson(jsonDecode(section.data!));
|
||||||
|
var selectedMarkerIcon;
|
||||||
|
|
||||||
|
if (mapDTO != null && mapDTO.iconSource != null) {
|
||||||
|
if (kIsWeb) {
|
||||||
|
Uint8List fileData = await http.readBytes(Uri.parse(mapDTO.iconSource!));
|
||||||
|
selectedMarkerIcon = resizeImage(fileData, 40);
|
||||||
|
} else {
|
||||||
|
final ByteData imageData = await NetworkAssetBundle(Uri.parse(mapDTO.iconSource!)).load("");
|
||||||
|
selectedMarkerIcon = await getBytesFromAsset(imageData, 50);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Icône par défaut
|
||||||
|
final ByteData bytes = await rootBundle.load('assets/icons/marker.png');
|
||||||
|
selectedMarkerIcon = await getBytesFromAsset(bytes, 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Map<String, dynamic>> icons = [];
|
||||||
|
|
||||||
|
icons.add({'id': null, 'icon': selectedMarkerIcon});
|
||||||
|
|
||||||
|
mapDTO!.categories!.forEach((cat) async {
|
||||||
|
if (cat.iconUrl != null) {
|
||||||
|
Uint8List categoryIcon;
|
||||||
|
if (kIsWeb) {
|
||||||
|
categoryIcon = await http.readBytes(Uri.parse(cat.iconUrl!));
|
||||||
|
} else {
|
||||||
|
final ByteData imageData = await NetworkAssetBundle(Uri.parse(cat.iconUrl!)).load("");
|
||||||
|
categoryIcon = await getBytesFromAsset(imageData, 50);
|
||||||
|
}
|
||||||
|
icons.add({'id': cat.id, 'icon': categoryIcon});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return icons;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Uint8List> getBytesFromAsset(ByteData data, int width) async {
|
||||||
|
//ByteData data = await rootBundle.load(path);
|
||||||
|
ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(),
|
||||||
|
targetWidth: width);
|
||||||
|
ui.FrameInfo fi = await codec.getNextFrame();
|
||||||
|
return (await fi.image.toByteData(format: ui.ImageByteFormat.png))
|
||||||
|
!.buffer
|
||||||
|
.asUint8List();
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint8List resizeImage(Uint8List data, int width) {
|
||||||
|
Uint8List resizedData = data;
|
||||||
|
IMG.Image img = IMG.decodeImage(data)!;
|
||||||
|
IMG.Image resized = IMG.copyResize(img, width: width);
|
||||||
|
resizedData = Uint8List.fromList(IMG.encodeJpg(resized));
|
||||||
|
return resizedData;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getContent(SectionDTO sectionSelected, bool isImageBackground) {
|
||||||
|
switch (sectionSelected.type) {
|
||||||
|
case SectionType.Map : // MAP
|
||||||
|
return ChangeNotifierProvider<MapContext>(
|
||||||
|
create: (_) =>
|
||||||
|
MapContext(new MapMarker(
|
||||||
|
latitude: null,
|
||||||
|
longitude: null,
|
||||||
|
title: '',
|
||||||
|
description: '')),
|
||||||
|
child: FutureBuilder(
|
||||||
|
future: getByteIcons(sectionSelected),
|
||||||
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
|
return MapViewWidget(section: sectionSelected, icons: snapshot.data);
|
||||||
|
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||||
|
return Text("No data");
|
||||||
|
} else {
|
||||||
|
return Center(
|
||||||
|
child: Container(
|
||||||
|
child: LoadingCommon()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) /*FutureBuilder(
|
||||||
|
future: _url,
|
||||||
|
builder: (BuildContext context, AsyncSnapshot snapshot) => snapshot.hasData
|
||||||
|
? WebViewWidget(url: snapshot.data,)
|
||||||
|
: CircularProgressIndicator()),*/
|
||||||
|
);
|
||||||
|
case SectionType.Web : // WEB
|
||||||
|
return WebView(section: sectionSelected);
|
||||||
|
case SectionType.Video : // Video
|
||||||
|
return VideoView(section: sectionSelected);
|
||||||
|
case SectionType.Slider :
|
||||||
|
return SliderView(section: sectionSelected);
|
||||||
|
case SectionType.Menu :
|
||||||
|
return MenuView(section: sectionSelected!, isImageBackground: isImageBackground);
|
||||||
|
case SectionType.Quizz :
|
||||||
|
return QuizzView(section: sectionSelected);
|
||||||
|
case SectionType.Pdf :
|
||||||
|
return PDFViewWidget(section: sectionSelected);
|
||||||
|
case SectionType.Puzzle :
|
||||||
|
return PuzzleView(section: sectionSelected);
|
||||||
|
case SectionType.Agenda :
|
||||||
|
return AgendaView(section: sectionSelected);
|
||||||
|
/*case SectionType.article : // TODO
|
||||||
|
elementToShow = ArticleView(section: sectionSelected);
|
||||||
|
break;*/
|
||||||
|
case SectionType.Weather :
|
||||||
|
return WeatherView(section: sectionSelected);
|
||||||
|
default:
|
||||||
|
return Text("Ce type n'est pas supporté");
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
247
lib/Screens/MainView/section_page_detail.dart
Normal file
247
lib/Screens/MainView/section_page_detail.dart
Normal file
@ -0,0 +1,247 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
import 'package:enum_to_string/enum_to_string.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
|
||||||
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
|
import 'package:manager_api/api.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:tablet_app/Components/loading_common.dart';
|
||||||
|
import 'package:tablet_app/Components/multi_select_container.dart';
|
||||||
|
import 'package:tablet_app/Helpers/ImageCustomProvider.dart';
|
||||||
|
import 'package:tablet_app/Helpers/translationHelper.dart';
|
||||||
|
import 'package:tablet_app/Models/map-marker.dart';
|
||||||
|
import 'package:tablet_app/Models/tabletContext.dart';
|
||||||
|
import 'package:tablet_app/Screens/Map/geo_point_filter.dart';
|
||||||
|
import 'package:tablet_app/Screens/Map/map_context.dart';
|
||||||
|
import 'package:html/parser.dart' show parse;
|
||||||
|
import 'package:tablet_app/app_context.dart';
|
||||||
|
import 'package:tablet_app/constants.dart';
|
||||||
|
|
||||||
|
class SectionPageDetail extends StatefulWidget {
|
||||||
|
final ConfigurationDTO configurationDTO;
|
||||||
|
final SectionDTO sectionDTO;
|
||||||
|
final Uint8List? selectedMarkerIcon;
|
||||||
|
final Color textColor;
|
||||||
|
final bool isImageBackground;
|
||||||
|
final Widget elementToShow;
|
||||||
|
const SectionPageDetail({
|
||||||
|
Key? key,
|
||||||
|
required this.configurationDTO,
|
||||||
|
required this.sectionDTO,
|
||||||
|
this.selectedMarkerIcon,
|
||||||
|
required this.textColor,
|
||||||
|
required this.isImageBackground,
|
||||||
|
required this.elementToShow,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_SectionPageDetailState createState() => _SectionPageDetailState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SectionPageDetailState extends State<SectionPageDetail> {
|
||||||
|
bool init = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final appContext = Provider.of<AppContext>(context);
|
||||||
|
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
|
||||||
|
Size size = MediaQuery.of(context).size;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
resizeToAvoidBottomInset: false,
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
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,
|
||||||
|
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,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Container(
|
||||||
|
decoration : BoxDecoration(
|
||||||
|
color: kBackgroundLight,
|
||||||
|
shape: BoxShape.rectangle,
|
||||||
|
borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30.0),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: kBackgroundSecondGrey,
|
||||||
|
spreadRadius: 0.5,
|
||||||
|
blurRadius: 5,
|
||||||
|
offset: Offset(0, 1.5), // changes position of shadow
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
//height: size.height * 0.1,
|
||||||
|
child: Container(
|
||||||
|
//color: Colors.greenAccent,
|
||||||
|
width: size.width,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
//color: Colors.grey,
|
||||||
|
//width: size.width * 0.8,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 15.0, top: 10.0, bottom: 10.0),
|
||||||
|
child: Container(
|
||||||
|
//color: Colors.grey,
|
||||||
|
child: AspectRatio(
|
||||||
|
aspectRatio: 4 / 4,
|
||||||
|
child: widget.isImageBackground ? Container(
|
||||||
|
/*width: 125,
|
||||||
|
height: 125,*/
|
||||||
|
decoration: boxDecoration(appContext, widget.sectionDTO, true),
|
||||||
|
) : Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: widget.sectionDTO.imageSource == null ? kBackgroundLight : null, // default color if no image
|
||||||
|
shape: BoxShape.rectangle,
|
||||||
|
image: widget.sectionDTO.imageSource != null ? new DecorationImage(
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
image: ImageCustomProvider.getImageProvider(appContext, widget.sectionDTO.imageId!, widget.sectionDTO.imageSource!),
|
||||||
|
): null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
//width: size.width,
|
||||||
|
//color: Colors.green,
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: HtmlWidget(
|
||||||
|
widget.sectionDTO.title!.firstWhere((translation) => translation.language == appContext.getContext().language).value!,
|
||||||
|
textStyle: new TextStyle(fontSize: kIsWeb ? kWebSectionTitleDetailSize : kSectionTitleDetailSize, color: widget.textColor, fontFamily: 'Roboto'),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
if(widget.sectionDTO.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null && widget.sectionDTO.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value!.trim().isNotEmpty)
|
||||||
|
Align(
|
||||||
|
//alignment: Alignment.center,
|
||||||
|
child: HtmlWidget(
|
||||||
|
widget.sectionDTO.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value!,
|
||||||
|
textStyle: new TextStyle(fontSize: kIsWeb? kWebSectionDescriptionDetailSize : kSectionDescriptionDetailSize, color: widget.textColor, fontFamily: 'Roboto'),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 15.0),
|
||||||
|
child: Container(
|
||||||
|
height: size.height *0.08,
|
||||||
|
width: size.width *0.08,
|
||||||
|
child: FittedBox(
|
||||||
|
child: FloatingActionButton.extended(
|
||||||
|
backgroundColor: kBackgroundColor,
|
||||||
|
focusColor: kBackgroundColor,
|
||||||
|
splashColor: kBackgroundColor,
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
icon: Icon(Icons.arrow_back, color: Colors.grey),
|
||||||
|
label: Text(TranslationHelper.getFromLocale("menu", appContext.getContext()), style: TextStyle(color: Colors.black))
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 9,
|
||||||
|
child: Padding(
|
||||||
|
padding: widget.sectionDTO.type != SectionType.Slider ? const EdgeInsets.only(left: 15.0, right: 15.0, top: 10.0) : const EdgeInsets.only(top: 10.0),
|
||||||
|
child: Container(
|
||||||
|
width: size.width,
|
||||||
|
//height: size.height * 0.9,
|
||||||
|
/*decoration: sectionSelected!.type != SectionType.Video && sectionSelected!.type != SectionType.Web && sectionSelected!.type != SectionType.Slider && sectionSelected!.type != SectionType.Map ? BoxDecoration(
|
||||||
|
//color: kBackgroundLight,
|
||||||
|
shape: BoxShape.rectangle,
|
||||||
|
borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30.0),
|
||||||
|
/*boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: kBackgroundSecondGrey,
|
||||||
|
spreadRadius: 0.5,
|
||||||
|
blurRadius: 5,
|
||||||
|
offset: Offset(0, 1.5), // changes position of shadow
|
||||||
|
),
|
||||||
|
],*/
|
||||||
|
) :null,*/
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 8.0),
|
||||||
|
child: widget.elementToShow),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
/*floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
|
||||||
|
floatingActionButton: Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 10.0),
|
||||||
|
child: Container(
|
||||||
|
height: size.height *0.08,
|
||||||
|
width: size.width *0.08,
|
||||||
|
child: FittedBox(
|
||||||
|
child: FloatingActionButton.extended(
|
||||||
|
backgroundColor: kBackgroundColor,
|
||||||
|
focusColor: kBackgroundColor,
|
||||||
|
splashColor: kBackgroundColor,
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
sectionSelected = null;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
icon: Icon(Icons.arrow_back, color: Colors.grey),
|
||||||
|
label: Text("Menu", style: TextStyle(color: Colors.black))
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),*/
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) {
|
||||||
|
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
|
||||||
|
return BoxDecoration(
|
||||||
|
color: !isSelected ? kBackgroundLight : section.imageSource == null ? kBackgroundLight : null,
|
||||||
|
shape: BoxShape.rectangle,
|
||||||
|
borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30.0),
|
||||||
|
image: section.imageSource != null ? new DecorationImage(
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
colorFilter: !isSelected? new ColorFilter.mode(kBackgroundLight.withOpacity(0.2), BlendMode.dstATop) : null,
|
||||||
|
image: ImageCustomProvider.getImageProvider(appContext, section.imageId!, section.imageSource!),
|
||||||
|
): null,
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: kBackgroundSecondGrey,
|
||||||
|
spreadRadius: 0.5,
|
||||||
|
blurRadius: 5,
|
||||||
|
offset: Offset(0, 1.5), // changes position of shadow
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -19,8 +19,9 @@ class GeoPointFilter extends StatefulWidget {
|
|||||||
final List<GeoPointDTO> geoPoints;
|
final List<GeoPointDTO> geoPoints;
|
||||||
final List<CategorieDTO> categories;
|
final List<CategorieDTO> categories;
|
||||||
final Function(List<GeoPointDTO>?) filteredPoints;
|
final Function(List<GeoPointDTO>?) filteredPoints;
|
||||||
|
final MapProvider provider;
|
||||||
|
|
||||||
GeoPointFilter({required this.language, required this.geoPoints, required this.categories, required this.filteredPoints});
|
GeoPointFilter({required this.language, required this.geoPoints, required this.categories, required this.filteredPoints, required this.provider});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_GeoPointFilterState createState() => _GeoPointFilterState();
|
_GeoPointFilterState createState() => _GeoPointFilterState();
|
||||||
@ -33,6 +34,7 @@ class _GeoPointFilterState extends State<GeoPointFilter> {
|
|||||||
late ValueNotifier<String> _searchTextNotifier;
|
late ValueNotifier<String> _searchTextNotifier;
|
||||||
final TextEditingController _searchController = TextEditingController();
|
final TextEditingController _searchController = TextEditingController();
|
||||||
FocusNode focusNode = new FocusNode();
|
FocusNode focusNode = new FocusNode();
|
||||||
|
bool _isExpanded = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -51,6 +53,12 @@ class _GeoPointFilterState extends State<GeoPointFilter> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _toggleExpansion() {
|
||||||
|
setState(() {
|
||||||
|
_isExpanded = !_isExpanded;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void _onSearchTextChanged() {
|
void _onSearchTextChanged() {
|
||||||
//filterNodes(_searchTextNotifier.value);
|
//filterNodes(_searchTextNotifier.value);
|
||||||
}
|
}
|
||||||
@ -100,10 +108,10 @@ class _GeoPointFilterState extends State<GeoPointFilter> {
|
|||||||
: _filterNodesBySearchText(searchText);
|
: _filterNodesBySearchText(searchText);
|
||||||
|
|
||||||
// if unfocus, then
|
// if unfocus, then
|
||||||
if(searchText.isEmpty && !focusNode.hasFocus) {
|
//if(searchText.isEmpty) {
|
||||||
// widget.filteredPoints = //todo
|
// widget.filteredPoints = //todo
|
||||||
sendFilteredGeoPoint();
|
sendFilteredGeoPoint();
|
||||||
}
|
//}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +165,7 @@ class _GeoPointFilterState extends State<GeoPointFilter> {
|
|||||||
|
|
||||||
return Positioned(
|
return Positioned(
|
||||||
left: 5,
|
left: 5,
|
||||||
top: 35,
|
top: widget.provider == MapProvider.Google ? 10 : 35,
|
||||||
child: Container(
|
child: Container(
|
||||||
width: size.width * 0.3,
|
width: size.width * 0.3,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -168,47 +176,70 @@ class _GeoPointFilterState extends State<GeoPointFilter> {
|
|||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Row(
|
||||||
padding: const EdgeInsets.only(bottom: 8.0, top: 4.0),
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
child: TextField(
|
children: [
|
||||||
focusNode: focusNode,
|
SizedBox(
|
||||||
controller: _searchController,
|
height: 60,
|
||||||
onChanged: (value) {
|
width: (size.width * 0.20),
|
||||||
filterNodes();
|
child: Padding(
|
||||||
},
|
padding: const EdgeInsets.only(left: 10.0, bottom: 8.0, top: 4.0),
|
||||||
cursorColor: Colors.black,
|
child: TextField(
|
||||||
style: TextStyle(color: Colors.black),
|
focusNode: focusNode,
|
||||||
decoration: InputDecoration(
|
controller: _searchController,
|
||||||
labelText: TranslationHelper.getFromLocale("map.search", appContext.getContext()),
|
onChanged: (value) {
|
||||||
labelStyle: TextStyle(
|
filterNodes();
|
||||||
color: focusNode.hasFocus ? primaryColor : Colors.black
|
},
|
||||||
),
|
cursorColor: Colors.black,
|
||||||
focusColor: primaryColor,
|
style: TextStyle(color: Colors.black),
|
||||||
focusedBorder: OutlineInputBorder(
|
decoration: InputDecoration(
|
||||||
borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)),
|
labelText: TranslationHelper.getFromLocale("map.search", appContext.getContext()),
|
||||||
borderSide: BorderSide(color: primaryColor)),
|
labelStyle: TextStyle(
|
||||||
//labelStyle: TextStyle(color: primaryColor),
|
color: focusNode.hasFocus ? primaryColor : Colors.black
|
||||||
suffixIcon: IconButton(
|
),
|
||||||
icon: _searchController.text.isNotEmpty ? Icon(Icons.close) : Icon(Icons.search),
|
focusColor: primaryColor,
|
||||||
onPressed: () {
|
focusedBorder: OutlineInputBorder(
|
||||||
if(_searchController.text.isNotEmpty) {
|
borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)),
|
||||||
_searchController.text = "";
|
borderSide: BorderSide(color: primaryColor)),
|
||||||
}
|
//labelStyle: TextStyle(color: primaryColor),
|
||||||
filterNodes();
|
suffixIcon: IconButton(
|
||||||
if(_searchController.text.isNotEmpty) {
|
icon: _searchController.text.isNotEmpty ? Icon(Icons.close) : Icon(Icons.search),
|
||||||
focusNode.unfocus();
|
onPressed: () {
|
||||||
}
|
if(_searchController.text.isNotEmpty) {
|
||||||
},
|
_searchController.text = "";
|
||||||
|
}
|
||||||
|
filterNodes();
|
||||||
|
if(_searchController.text.isNotEmpty) {
|
||||||
|
focusNode.unfocus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
SizedBox(
|
||||||
|
width: 50,
|
||||||
|
height: 60,
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: _toggleExpansion,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 4.0, right: 3.0),
|
||||||
|
child: Icon(_isExpanded ? Icons.expand_more : Icons.chevron_right, color: primaryColor),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
ValueListenableBuilder<String>(
|
ValueListenableBuilder<String>(
|
||||||
valueListenable: _searchTextNotifier,
|
valueListenable: _searchTextNotifier,
|
||||||
builder: (context, value, _) {
|
builder: (context, value, _) {
|
||||||
return Container(
|
return Container(
|
||||||
//color: Colors.greenAccent,
|
//color: Colors.greenAccent,
|
||||||
height: size.height * 0.65,
|
height: _isExpanded ? widget.provider == MapProvider.Google ? size.height * 0.68 : size.height * 0.65 : 0,
|
||||||
width: size.width * 0.3,
|
width: size.width * 0.3,
|
||||||
child: GenerateTree(
|
child: GenerateTree(
|
||||||
data: _filteredNodes,
|
data: _filteredNodes,
|
||||||
|
|||||||
@ -16,13 +16,13 @@ import 'package:tablet_app/app_context.dart';
|
|||||||
import 'package:tablet_app/constants.dart';
|
import 'package:tablet_app/constants.dart';
|
||||||
|
|
||||||
class GoogleMapView extends StatefulWidget {
|
class GoogleMapView extends StatefulWidget {
|
||||||
final MapDTO? mapDTO;
|
final MapDTO mapDTO;
|
||||||
final Uint8List? selectedMarkerIcon;
|
final List<Map<String, dynamic>> icons;
|
||||||
final String? language;
|
final String? language;
|
||||||
const GoogleMapView({
|
const GoogleMapView({
|
||||||
Key? key,
|
Key? key,
|
||||||
this.mapDTO,
|
required this.mapDTO,
|
||||||
this.selectedMarkerIcon,
|
required this.icons,
|
||||||
this.language,
|
this.language,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@ -59,7 +59,8 @@ class _GoogleMapViewState extends State<GoogleMapView> {
|
|||||||
double.tryParse(mapMarker.latitude!)!,
|
double.tryParse(mapMarker.latitude!)!,
|
||||||
double.tryParse(mapMarker.longitude!)!,
|
double.tryParse(mapMarker.longitude!)!,
|
||||||
),
|
),
|
||||||
icon: widget.selectedMarkerIcon != null ? BitmapDescriptor.fromBytes(widget.selectedMarkerIcon!) : BitmapDescriptor.defaultMarker,
|
icon: point.categorie == null ? BitmapDescriptor.fromBytes(widget.icons.where((i) => i['id'] == null).first['icon']) : widget.icons.any((i) => i['id'] == point.categorieId) ? BitmapDescriptor.fromBytes(widget.icons.where((i) => i['id'] == point.categorieId).first['icon']) : BitmapDescriptor.fromBytes(widget.icons.where((i) => i['id'] == null).first['icon']), //widget.selectedMarkerIcon,
|
||||||
|
//widget.selectedMarkerIcon != null ? BitmapDescriptor.fromBytes(widget.selectedMarkerIcon!) : BitmapDescriptor.defaultMarker,
|
||||||
/*icon: BitmapDescriptor.defaultMarkerWithHue(
|
/*icon: BitmapDescriptor.defaultMarkerWithHue(
|
||||||
BitmapDescriptor.hueYellow,
|
BitmapDescriptor.hueYellow,
|
||||||
),*/
|
),*/
|
||||||
@ -173,7 +174,7 @@ class _GoogleMapViewState extends State<GoogleMapView> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Positioned(
|
/*Positioned(
|
||||||
left: 5,
|
left: 5,
|
||||||
top: 35,
|
top: 35,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@ -214,7 +215,7 @@ class _GoogleMapViewState extends State<GoogleMapView> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),*/
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,13 +20,13 @@ import 'package:tablet_app/constants.dart';
|
|||||||
class MapBoxView extends StatefulWidget {
|
class MapBoxView extends StatefulWidget {
|
||||||
final MapDTO? mapDTO;
|
final MapDTO? mapDTO;
|
||||||
final List<GeoPointDTO> geoPoints;
|
final List<GeoPointDTO> geoPoints;
|
||||||
final Uint8List? selectedMarkerIcon;
|
final List<Map<String, dynamic>> icons;
|
||||||
final String? language;
|
final String? language;
|
||||||
const MapBoxView({
|
const MapBoxView({
|
||||||
Key? key,
|
Key? key,
|
||||||
this.mapDTO,
|
this.mapDTO,
|
||||||
required this.geoPoints,
|
required this.geoPoints,
|
||||||
this.selectedMarkerIcon,
|
required this.icons,
|
||||||
this.language,
|
this.language,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ class _MapBoxViewState extends State<MapBoxView> {
|
|||||||
symbolSortKey: 10,
|
symbolSortKey: 10,
|
||||||
iconColor: 0,
|
iconColor: 0,
|
||||||
iconImage: null,
|
iconImage: null,
|
||||||
image: widget.selectedMarkerIcon, //widget.selectedMarkerIcon,
|
image: point.categorie == null ? widget.icons.where((i) => i['id'] == null).first['icon'] : widget.icons.any((i) => i['id'] == point.categorieId) ? widget.icons.where((i) => i['id'] == point.categorieId).first['icon'] : widget.icons.where((i) => i['id'] == null).first['icon'], //widget.selectedMarkerIcon,
|
||||||
)); // ,
|
)); // ,
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
|||||||
@ -1,33 +1,34 @@
|
|||||||
import 'dart:async';
|
//import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:typed_data';
|
// 'dart:typed_data';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
// 'package:flutter/services.dart';
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
//import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
import 'package:manager_api/api.dart';
|
import 'package:manager_api/api.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tablet_app/Components/loading.dart';
|
/*import 'package:tablet_app/Components/loading.dart';
|
||||||
import 'package:tablet_app/Components/loading_common.dart';
|
import 'package:tablet_app/Components/loading_common.dart';*/
|
||||||
import 'package:tablet_app/Models/map-marker.dart';
|
import 'package:tablet_app/Models/map-marker.dart';
|
||||||
import 'dart:ui' as ui;
|
//import 'dart:ui' as ui;
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:tablet_app/Models/tabletContext.dart';
|
import 'package:tablet_app/Models/tabletContext.dart';
|
||||||
import 'package:tablet_app/Screens/Map/geo_point_filter.dart';
|
import 'package:tablet_app/Screens/Map/geo_point_filter.dart';
|
||||||
import 'package:tablet_app/Screens/Map/map_box_view.dart';
|
import 'package:tablet_app/Screens/Map/map_box_view.dart';
|
||||||
import 'package:tablet_app/Screens/Map/marker_view.dart';
|
import 'package:tablet_app/Screens/Map/marker_view.dart';
|
||||||
import 'package:http/http.dart' as http;
|
//import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
import '../../app_context.dart';
|
import '../../app_context.dart';
|
||||||
import 'google_map_view.dart';
|
import 'google_map_view.dart';
|
||||||
import 'package:image/image.dart' as IMG;
|
//import 'package:image/image.dart' as IMG;
|
||||||
|
|
||||||
//Set<Marker> markers = {};
|
//Set<Marker> markers = {};
|
||||||
List<MapMarker> markersList = [];
|
List<MapMarker> markersList = [];
|
||||||
|
|
||||||
class MapViewWidget extends StatefulWidget {
|
class MapViewWidget extends StatefulWidget {
|
||||||
final SectionDTO? section;
|
final SectionDTO section;
|
||||||
MapViewWidget({Key? key, this.section}) : super(key: key);
|
final List<Map<String, dynamic>> icons;
|
||||||
|
MapViewWidget({Key? key, required this.section, required this.icons}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_MapViewWidget createState() => _MapViewWidget();
|
_MapViewWidget createState() => _MapViewWidget();
|
||||||
@ -36,10 +37,10 @@ class MapViewWidget extends StatefulWidget {
|
|||||||
class _MapViewWidget extends State<MapViewWidget> {
|
class _MapViewWidget extends State<MapViewWidget> {
|
||||||
MapDTO? mapDTO;
|
MapDTO? mapDTO;
|
||||||
//Completer<GoogleMapController> _controller = Completer();
|
//Completer<GoogleMapController> _controller = Completer();
|
||||||
Uint8List? selectedMarkerIcon;
|
//Uint8List? selectedMarkerIcon;
|
||||||
late ValueNotifier<List<GeoPointDTO>> _geoPoints = ValueNotifier<List<GeoPointDTO>>([]);
|
late ValueNotifier<List<GeoPointDTO>> _geoPoints = ValueNotifier<List<GeoPointDTO>>([]);
|
||||||
|
|
||||||
Future<Uint8List> getBytesFromAsset(ByteData data, int width) async {
|
/*Future<Uint8List> getBytesFromAsset(ByteData data, int width) async {
|
||||||
//ByteData data = await rootBundle.load(path);
|
//ByteData data = await rootBundle.load(path);
|
||||||
ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(),
|
ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(),
|
||||||
targetWidth: width);
|
targetWidth: width);
|
||||||
@ -47,11 +48,11 @@ class _MapViewWidget extends State<MapViewWidget> {
|
|||||||
return (await fi.image.toByteData(format: ui.ImageByteFormat.png))
|
return (await fi.image.toByteData(format: ui.ImageByteFormat.png))
|
||||||
!.buffer
|
!.buffer
|
||||||
.asUint8List();
|
.asUint8List();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
mapDTO = MapDTO.fromJson(jsonDecode(widget.section!.data!));
|
mapDTO = MapDTO.fromJson(jsonDecode(widget.section.data!));
|
||||||
_geoPoints.value = mapDTO!.points!;
|
_geoPoints.value = mapDTO!.points!;
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
@ -73,41 +74,10 @@ class _MapViewWidget extends State<MapViewWidget> {
|
|||||||
//final mapContext = Provider.of<MapContext>(context);
|
//final mapContext = Provider.of<MapContext>(context);
|
||||||
final appContext = Provider.of<AppContext>(context);
|
final appContext = Provider.of<AppContext>(context);
|
||||||
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
|
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
|
||||||
return FutureBuilder(
|
/*return FutureBuilder(
|
||||||
future: getByteIcon(mapDTO!.iconSource),
|
future: getByteIcon(mapDTO!.iconSource),
|
||||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
return Stack(
|
|
||||||
children: <Widget>[
|
|
||||||
ValueListenableBuilder<List<GeoPointDTO>>(
|
|
||||||
valueListenable: _geoPoints,
|
|
||||||
builder: (context, value, _) {
|
|
||||||
switch(mapDTO!.mapProvider) {
|
|
||||||
case MapProvider.Google:
|
|
||||||
return GoogleMapView(language: appContext.getContext().language, mapDTO: mapDTO, selectedMarkerIcon: selectedMarkerIcon);
|
|
||||||
case MapProvider.MapBox:
|
|
||||||
return MapBoxView(language: appContext.getContext().language, geoPoints: value, mapDTO: mapDTO, selectedMarkerIcon: selectedMarkerIcon);
|
|
||||||
default:
|
|
||||||
// By default google
|
|
||||||
return GoogleMapView(language: appContext.getContext().language, mapDTO: mapDTO, selectedMarkerIcon: selectedMarkerIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
),
|
|
||||||
GeoPointFilter(
|
|
||||||
language: tabletAppContext.language!,
|
|
||||||
geoPoints: mapDTO!.points!,
|
|
||||||
categories: mapDTO!.categories!,
|
|
||||||
filteredPoints: (value) {
|
|
||||||
_geoPoints.value = value!;
|
|
||||||
}),
|
|
||||||
MarkerViewWidget(),
|
|
||||||
]
|
|
||||||
/*floatingActionButton: FloatingActionButton.extended(
|
|
||||||
onPressed: _goToTheLake,
|
|
||||||
label: Text('To the lake!'),
|
|
||||||
icon: Icon(Icons.directions_boat),
|
|
||||||
),*/
|
|
||||||
);
|
|
||||||
} else if (snapshot.connectionState == ConnectionState.none) {
|
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||||
return Text("No data");
|
return Text("No data");
|
||||||
} else {
|
} else {
|
||||||
@ -118,10 +88,42 @@ class _MapViewWidget extends State<MapViewWidget> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
);*/
|
||||||
|
return Stack(
|
||||||
|
children: <Widget>[
|
||||||
|
ValueListenableBuilder<List<GeoPointDTO>>(
|
||||||
|
valueListenable: _geoPoints,
|
||||||
|
builder: (context, value, _) {
|
||||||
|
switch(mapDTO!.mapProvider) {
|
||||||
|
case MapProvider.Google:
|
||||||
|
return GoogleMapView(language: appContext.getContext().language, mapDTO: mapDTO!, icons: widget.icons);
|
||||||
|
case MapProvider.MapBox:
|
||||||
|
return MapBoxView(language: appContext.getContext().language, geoPoints: value, mapDTO: mapDTO, icons: widget.icons);
|
||||||
|
default:
|
||||||
|
// By default google
|
||||||
|
return GoogleMapView(language: appContext.getContext().language, mapDTO: mapDTO!, icons: widget.icons);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
GeoPointFilter(
|
||||||
|
language: tabletAppContext.language!,
|
||||||
|
geoPoints: mapDTO!.points!,
|
||||||
|
categories: mapDTO!.categories!,
|
||||||
|
provider: mapDTO!.mapProvider!,
|
||||||
|
filteredPoints: (value) {
|
||||||
|
_geoPoints.value = value!;
|
||||||
|
}),
|
||||||
|
MarkerViewWidget(),
|
||||||
|
]
|
||||||
|
/*floatingActionButton: FloatingActionButton.extended(
|
||||||
|
onPressed: _goToTheLake,
|
||||||
|
label: Text('To the lake!'),
|
||||||
|
icon: Icon(Icons.directions_boat),
|
||||||
|
),*/
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getByteIcon(String? source) async {
|
/*getByteIcon(String? source) async {
|
||||||
if(source != null) {
|
if(source != null) {
|
||||||
if(kIsWeb) {
|
if(kIsWeb) {
|
||||||
Uint8List fileData = await http.readBytes(Uri.parse(source));
|
Uint8List fileData = await http.readBytes(Uri.parse(source));
|
||||||
@ -135,15 +137,15 @@ class _MapViewWidget extends State<MapViewWidget> {
|
|||||||
final ByteData bytes = await rootBundle.load('assets/icons/marker.png');
|
final ByteData bytes = await rootBundle.load('assets/icons/marker.png');
|
||||||
selectedMarkerIcon = await getBytesFromAsset(bytes, 25);
|
selectedMarkerIcon = await getBytesFromAsset(bytes, 25);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
Uint8List resizeImage(Uint8List data, int width) {
|
/*Uint8List resizeImage(Uint8List data, int width) {
|
||||||
Uint8List resizedData = data;
|
Uint8List resizedData = data;
|
||||||
IMG.Image img = IMG.decodeImage(data)!;
|
IMG.Image img = IMG.decodeImage(data)!;
|
||||||
IMG.Image resized = IMG.copyResize(img, width: width);
|
IMG.Image resized = IMG.copyResize(img, width: width);
|
||||||
resizedData = Uint8List.fromList(IMG.encodeJpg(resized));
|
resizedData = Uint8List.fromList(IMG.encodeJpg(resized));
|
||||||
return resizedData;
|
return resizedData;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/*Future<void> _goToTheLake() async {
|
/*Future<void> _goToTheLake() async {
|
||||||
final GoogleMapController controller = await _controller.future;
|
final GoogleMapController controller = await _controller.future;
|
||||||
|
|||||||
@ -6,10 +6,12 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
|
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
|
||||||
import 'package:manager_api/api.dart';
|
import 'package:manager_api/api.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:tablet_app/Components/loading_common.dart';
|
||||||
import 'package:tablet_app/Helpers/ImageCustomProvider.dart';
|
import 'package:tablet_app/Helpers/ImageCustomProvider.dart';
|
||||||
import 'package:tablet_app/Models/map-marker.dart';
|
import 'package:tablet_app/Models/map-marker.dart';
|
||||||
import 'package:tablet_app/Models/tabletContext.dart';
|
import 'package:tablet_app/Models/tabletContext.dart';
|
||||||
import 'package:tablet_app/Screens/Agenda/agenda_view.dart';
|
import 'package:tablet_app/Screens/Agenda/agenda_view.dart';
|
||||||
|
import 'package:tablet_app/Screens/MainView/main_view.dart';
|
||||||
import 'package:tablet_app/Screens/Map/map_context.dart';
|
import 'package:tablet_app/Screens/Map/map_context.dart';
|
||||||
import 'package:tablet_app/Screens/Map/map_view.dart';
|
import 'package:tablet_app/Screens/Map/map_view.dart';
|
||||||
import 'package:tablet_app/Screens/PDF/pdf_view.dart';
|
import 'package:tablet_app/Screens/PDF/pdf_view.dart';
|
||||||
@ -68,7 +70,22 @@ class _MenuView extends State<MenuView> {
|
|||||||
longitude: null,
|
longitude: null,
|
||||||
title: '',
|
title: '',
|
||||||
description: '')),
|
description: '')),
|
||||||
child: MapViewWidget(section: selectedSection) /*FutureBuilder(
|
child: FutureBuilder(
|
||||||
|
future: getByteIcons(selectedSection!),
|
||||||
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
|
return MapViewWidget(section: selectedSection!, icons: snapshot.data);
|
||||||
|
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||||
|
return Text("No data");
|
||||||
|
} else {
|
||||||
|
return Center(
|
||||||
|
child: Container(
|
||||||
|
child: LoadingCommon()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) /*FutureBuilder(
|
||||||
future: _url,
|
future: _url,
|
||||||
builder: (BuildContext context, AsyncSnapshot snapshot) => snapshot.hasData
|
builder: (BuildContext context, AsyncSnapshot snapshot) => snapshot.hasData
|
||||||
? WebViewWidget(url: snapshot.data,)
|
? WebViewWidget(url: snapshot.data,)
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:manager_api/api.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tablet_app/Models/map-marker.dart';
|
import 'package:tablet_app/Models/map-marker.dart';
|
||||||
import 'package:tablet_app/Screens/Map/map_context.dart';
|
import 'package:tablet_app/Screens/Map/map_context.dart';
|
||||||
@ -269,7 +270,7 @@ class _PreviousViewWidget extends State<PreviousViewWidget> with TickerProviderS
|
|||||||
longitude: null,
|
longitude: null,
|
||||||
title: '',
|
title: '',
|
||||||
description: '')),
|
description: '')),
|
||||||
child: MapViewWidget() /*FutureBuilder(
|
child: MapViewWidget(section: SectionDTO(), icons: []) /*FutureBuilder(
|
||||||
future: _url,
|
future: _url,
|
||||||
builder: (BuildContext context, AsyncSnapshot snapshot) => snapshot.hasData
|
builder: (BuildContext context, AsyncSnapshot snapshot) => snapshot.hasData
|
||||||
? WebViewWidget(url: snapshot.data,)
|
? WebViewWidget(url: snapshot.data,)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user