import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:terepi_seged/models/measured_record.dart'; import 'package:terepi_seged/pages/measured_data/presentation/controllers/measured_data_controller.dart'; import 'package:terepi_seged/services/project_service.dart'; class MeasuredDataView extends GetView { const MeasuredDataView({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Obx(() => Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ const Text('Mérési adatok'), Text( ProjectService.to.activeProject.value?.name ?? '', style: const TextStyle(fontSize: 12.0), ), ], )), ), body: Column( children: [ Padding( padding: const EdgeInsets.all(12), child: Row( children: [ Expanded( flex: 2, child: TextField( decoration: const InputDecoration( prefixIcon: Icon(Icons.search), hintText: 'FFID / forráspont / vonal…', border: OutlineInputBorder(), isDense: true, ), onChanged: controller.onSearchChanged, ), ), const SizedBox(width: 8), Expanded( child: Obx(() => DropdownButtonFormField( value: controller.lineFilter.value, isExpanded: true, decoration: const InputDecoration( labelText: 'Vonal', isDense: true), items: [ const DropdownMenuItem( value: null, child: Text('Mind')), ...controller.availableLines.map((l) => DropdownMenuItem( value: l, child: Text(_fmtNum(l)))), ], onChanged: controller.setLineFilter, )), ), ], ), ), Expanded( child: Obx(() { if (controller.isLoading.value) { return const Center(child: CircularProgressIndicator()); } final list = controller.filteredRecords; if (list.isEmpty) { return const Center(child: Text('Nincs mérési adat.')); } return ListView.builder( itemCount: list.length, itemBuilder: (context, i) => _RecordTile(record: list[i]), ); }), ), ], ), ); } } String _fmtNum(double v) => v == v.roundToDouble() ? v.toInt().toString() : v.toString(); String _fmtDate(DateTime dt) { final local = dt.toLocal(); String two(int n) => n.toString().padLeft(2, '0'); return '${local.year}.${two(local.month)}.${two(local.day)} ' '${two(local.hour)}:${two(local.minute)}:${two(local.second)}'; } class _RecordTile extends StatelessWidget { final MeasuredRecord record; const _RecordTile({required this.record}); @override Widget build(BuildContext context) { final hasImage = record.hasImage; return ListTile( title: Text( 'FFID ${record.ffid ?? "—"} · VP ' '${record.sourcePointNumber != null ? _fmtNum(record.sourcePointNumber!) : "—"}', style: const TextStyle(fontWeight: FontWeight.w600), ), subtitle: Text( 'Vonal ${record.sourceLineNumber != null ? _fmtNum(record.sourceLineNumber!) : "—"}' '${record.geophoneRange != null ? " · Geofon ${record.geophoneRange}" : ""}' '\n${_fmtDate(record.measuredAt)}', ), isThreeLine: true, trailing: Icon( hasImage ? Icons.image_outlined : Icons.image_not_supported_outlined, color: hasImage ? null : Colors.grey.shade400, ), onTap: hasImage ? () => MeasuredDataController.to.showSeismicImage(record) : null, ); } }