Premier vrai build depuis avril. Le diagnostic des docs — « un seul défaut, purement Gradle, peut-être réglé par 5a6701d » — tenait parce que personne n'avait lancé la commande. K1 — dix crans d'outillage, chacun dicté par l'erreur du précédent : Gradle 7.5 → 8.11.1, AGP 7.2.0 → 8.9.1, Kotlin 1.9.0 → 2.3.10, enableUncompressedNativeLibs retirée (supprimée en AGP 8.1), jcenter → mavenCentral, heap 1536M → 4096M, Jetifier coupé, et retrait du resolutionStrategy qui forçait androidx.lifecycle à 2.4.0 « to fix mapbox issue » : il réglait un problème d'il y a trois ans et causait celui d'aujourd'hui, mapbox_maps_flutter 2.21.1 appelant setViewTreeLifecycleOwner. Les trois derniers crans étaient de simples alignements sur mymuseum-visitapp, qui utilise le même plugin sans ces problèmes. Le bloc buildscript commenté de android/build.gradle est supprimé : il déclarait une config qui n'était pas celle appliquée et a fait conclure deux fois à tort. K2 — les 132 erreurs Dart que le Gradle masquait. Trois causes : roundedValue, isDate, isHour, isSectionImageBackground et screenPercentageSectionsMainPage ont migré vers AppConfigurationLink ; GeoPointDTO.latitude/longitude sont devenus geometry ; le reste en découlait. Deux bugs latents trouvés au passage : - applicationInstanceDTO n'était assigné que si l'instance avait l'IA — il servait de drapeau d'assistant. Ce DTO portant désormais les AppConfigurationLink, les cinq réglages seraient retombés sur leurs défauts sur MDLF et le Fort, sans erreur ni log. Drapeau rendu explicite, en préservant le ET instance × canal. - ConfigurationDTO.isTablet ayant disparu, le filtre des configurations tablette n'avait plus de source : il porte sur les liens du canal AppType.Tablet. La formule de clé par coordonnées de geo_point_filter, dupliquée à quatre endroits alors que les deux côtés de l'appariement doivent produire la même valeur, ne vit plus qu'à un seul (Helpers/geo.dart). Ce fichier documente aussi les deux conventions de coordonnées du projet : [lng, lat] pour les GeoPoint, [lat, lng] pour les géométries de GuidedStep. K4 — l'écran Game repris de mymuseum-visitapp, Screens/Puzzle supprimé. La tablette gagne le puzzle glissant, le bouton d'indice et un dimensionnement au ratio de l'image. Les couleurs, codées en dur par flavor client chez mymuseum, sont dérivées de configuration.primaryColor : tablet-app n'a pas de flavor, un seul APK sert tous les clients. Reste à vérifier sur device : le rendu de l'écran Game, et l'écran de sélection de configuration, qui sera vide si les configurations ne sont pas rattachées au canal tablette. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
191 lines
7.5 KiB
Dart
191 lines
7.5 KiB
Dart
import 'dart:async';
|
|
import 'dart:ui' as ui;
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:manager_api_new/api.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:tablet_app/Components/loading_common.dart';
|
|
import 'package:tablet_app/Models/agenda.dart';
|
|
import 'package:tablet_app/Models/tabletContext.dart';
|
|
import 'package:tablet_app/Screens/Agenda/event_list_item.dart';
|
|
import 'package:tablet_app/Screens/Agenda/event_popup.dart';
|
|
import 'package:tablet_app/Screens/Agenda/month_filter.dart';
|
|
import 'package:tablet_app/app_context.dart';
|
|
import 'package:tablet_app/constants.dart';
|
|
|
|
|
|
class AgendaView extends StatefulWidget {
|
|
final AgendaDTO section;
|
|
AgendaView({required this.section});
|
|
|
|
@override
|
|
_AgendaView createState() => _AgendaView();
|
|
}
|
|
|
|
class _AgendaView extends State<AgendaView> {
|
|
AgendaDTO agendaDTO = AgendaDTO();
|
|
late Agenda agenda;
|
|
late ValueNotifier<List<EventAgenda>> filteredAgenda = ValueNotifier<List<EventAgenda>>([]);
|
|
late Uint8List mapIcon;
|
|
|
|
@override
|
|
void initState() {
|
|
/*print(widget.section!.data);
|
|
agendaDTO = AgendaDTO.fromJson(jsonDecode(widget.section!.data!))!;
|
|
print(agendaDTO);*/
|
|
agendaDTO = widget.section;
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
Future<Agenda?> getAndParseJsonInfo(TabletAppContext tabletAppContext) async {
|
|
try {
|
|
if (agendaDTO.id == null) return null;
|
|
final dtos = await tabletAppContext.clientAPI!.sectionAgendaApi!
|
|
.sectionAgendaGetUpcomingEvents(agendaDTO.id!);
|
|
|
|
if (dtos == null) return null;
|
|
|
|
final events = dtos
|
|
.map((dto) => EventAgenda.fromDto(dto, tabletAppContext.language ?? 'FR'))
|
|
.toList();
|
|
events.sort((a, b) {
|
|
if (a.dateFrom == null) return 1;
|
|
if (b.dateFrom == null) return -1;
|
|
return a.dateFrom!.compareTo(b.dateFrom!);
|
|
});
|
|
|
|
agenda = Agenda(events: events);
|
|
filteredAgenda.value = events;
|
|
|
|
mapIcon = await getByteIcon();
|
|
|
|
return agenda;
|
|
} catch (e) {
|
|
print("Erreur lors du parsing du json : ${e.toString()}");
|
|
return null;
|
|
}
|
|
}
|
|
|
|
getByteIcon() async {
|
|
final ByteData bytes = await rootBundle.load('assets/icons/marker.png');
|
|
var icon = await getBytesFromAsset(bytes, 25);
|
|
return icon;
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Size size = MediaQuery.of(context).size;
|
|
final TabletAppContext tabletAppContext = Provider.of<AppContext>(context).getContext();
|
|
|
|
return FutureBuilder(future: getAndParseJsonInfo(tabletAppContext),
|
|
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
|
|
if (snapshot.connectionState == ConnectionState.done) {
|
|
if (snapshot.data == null) {
|
|
return Center(
|
|
child: Text("Le fichier choisi n'est pas valide")
|
|
);
|
|
} else {
|
|
return Center(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
flex: 1,
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: kBackgroundColor,
|
|
borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.currentAppConfigurationLink?.roundedValue?.toDouble() ?? 30.0)),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: MonthFilter(
|
|
events: snapshot.data.events,
|
|
onMonthSelected: (filteredList) {
|
|
print('events sélectionné: $filteredList');
|
|
var result = filteredList != null ? filteredList : <EventAgenda>[];
|
|
result.sort((a, b) => a.dateFrom!.compareTo(b.dateFrom!));
|
|
filteredAgenda.value = result;
|
|
}),
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 4,
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(left: 8.0, bottom: 2.0, top: 2.0),
|
|
child: Container(
|
|
child: ValueListenableBuilder<List<EventAgenda>>(
|
|
valueListenable: filteredAgenda,
|
|
builder: (context, value, _) {
|
|
return GridView.builder(
|
|
scrollDirection: Axis.vertical, // Changer pour horizontal si nécessaire
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 4, // Nombre de colonnes dans la grid
|
|
crossAxisSpacing: 4.0, // Espace entre les colonnes
|
|
mainAxisSpacing: 4.0, // Espace entre les lignes
|
|
childAspectRatio: 0.75, // Aspect ratio des enfants de la grid
|
|
),
|
|
itemCount: value.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
EventAgenda eventAgenda = value[index];
|
|
|
|
return GestureDetector(
|
|
onTap: () {
|
|
print("${eventAgenda.name}");
|
|
(Provider.of<AppContext>(context, listen: false).getContext() as TabletAppContext)
|
|
.statisticsService?.track(
|
|
VisitEventType.agendaEventTap,
|
|
metadata: {'eventId': eventAgenda.name, 'eventTitle': eventAgenda.name},
|
|
);
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return EventPopup(eventAgenda: eventAgenda, mapProvider: agendaDTO.agendaMapProvider ?? MapProvider.Google, mapIcon: mapIcon);
|
|
},
|
|
);
|
|
},
|
|
child: EventListItem(
|
|
eventAgenda: eventAgenda,
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} else if (snapshot.connectionState == ConnectionState.none) {
|
|
return Text("No data");
|
|
} else {
|
|
return Center(
|
|
child: Container(
|
|
height: size.height * 0.2,
|
|
child: LoadingCommon()
|
|
)
|
|
);
|
|
}
|
|
},
|
|
);
|
|
}
|
|
} //_webView |