repair river station name for local storage
This commit is contained in:
parent
70bf72feaf
commit
c7b97ecd1a
@ -49,7 +49,18 @@ class _RiverInSituStep2SiteInfoState extends State<RiverInSituStep2SiteInfo> {
|
||||
setState(() => _isPickingImage = true);
|
||||
|
||||
final service = Provider.of<RiverInSituSamplingService>(context, listen: false);
|
||||
final file = await service.pickAndProcessImage(source, data: widget.data, imageInfo: imageInfo, isRequired: isRequired);
|
||||
|
||||
// ✅ FIX: Get the station code directly from the data model.
|
||||
final String? stationCode = widget.data.selectedStation?['sampling_station_code'];
|
||||
|
||||
// ✅ FIX: Pass the stationCode directly to the processing method.
|
||||
final file = await service.pickAndProcessImage(
|
||||
source,
|
||||
data: widget.data,
|
||||
imageInfo: imageInfo,
|
||||
isRequired: isRequired,
|
||||
stationCode: stationCode, // Pass the station code here
|
||||
);
|
||||
|
||||
if (file != null) {
|
||||
setState(() => setImageCallback(file));
|
||||
@ -69,7 +80,6 @@ class _RiverInSituStep2SiteInfoState extends State<RiverInSituStep2SiteInfo> {
|
||||
|
||||
_formKey.currentState!.save();
|
||||
|
||||
// UPDATED: Validation now checks for 3 required photos.
|
||||
if (widget.data.backgroundStationImage == null ||
|
||||
widget.data.upstreamRiverImage == null ||
|
||||
widget.data.downstreamRiverImage == null) {
|
||||
@ -130,8 +140,6 @@ class _RiverInSituStep2SiteInfoState extends State<RiverInSituStep2SiteInfo> {
|
||||
_buildImagePicker('Upstream River', 'UPSTREAM_RIVER', widget.data.upstreamRiverImage, (file) => widget.data.upstreamRiverImage = file, isRequired: true),
|
||||
_buildImagePicker('Downstream River', 'DOWNSTREAM_RIVER', widget.data.downstreamRiverImage, (file) => widget.data.downstreamRiverImage = file, isRequired: true),
|
||||
|
||||
// REMOVED: The "Sample Turbidity" image picker was here.
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
const SizedBox(height: 32),
|
||||
|
||||
@ -56,7 +56,18 @@ class _RiverInSituStep4AdditionalInfoState
|
||||
setState(() => _isPickingImage = true);
|
||||
|
||||
final service = Provider.of<RiverInSituSamplingService>(context, listen: false);
|
||||
final file = await service.pickAndProcessImage(source, data: widget.data, imageInfo: imageInfo, isRequired: isRequired);
|
||||
|
||||
// ✅ FIX: Get the station code directly from the data model.
|
||||
final String? stationCode = widget.data.selectedStation?['sampling_station_code'];
|
||||
|
||||
// ✅ FIX: Pass the stationCode directly to the processing method.
|
||||
final file = await service.pickAndProcessImage(
|
||||
source,
|
||||
data: widget.data,
|
||||
imageInfo: imageInfo,
|
||||
isRequired: isRequired,
|
||||
stationCode: stationCode, // Pass the station code here
|
||||
);
|
||||
|
||||
if (file != null) {
|
||||
setState(() => setImageCallback(file));
|
||||
@ -73,7 +84,6 @@ class _RiverInSituStep4AdditionalInfoState
|
||||
if (_formKey.currentState!.validate()) {
|
||||
_formKey.currentState!.save();
|
||||
|
||||
// ADDED: Validation for the moved required photo.
|
||||
if (widget.data.sampleTurbidityImage == null) {
|
||||
_showSnackBar('Please attach the Sample Turbidity photo before proceeding.', isError: true);
|
||||
return;
|
||||
@ -107,7 +117,6 @@ class _RiverInSituStep4AdditionalInfoState
|
||||
style: Theme.of(context).textTheme.headlineSmall),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// ADDED: The required "Sample Turbidity" photo moved from Step 2.
|
||||
Text("Required Photo *", style: Theme.of(context).textTheme.titleLarge),
|
||||
const SizedBox(height: 8),
|
||||
_buildImagePicker('Sample Turbidity', 'SAMPLE_TURBIDITY', widget.data.sampleTurbidityImage, (file) => widget.data.sampleTurbidityImage = file, isRequired: true),
|
||||
|
||||
@ -43,6 +43,7 @@ class RiverInSituSamplingService {
|
||||
required RiverInSituSamplingData data,
|
||||
required String imageInfo,
|
||||
bool isRequired = false,
|
||||
String? stationCode, // Accept station code for naming
|
||||
}) async {
|
||||
final picker = ImagePicker();
|
||||
final XFile? photo = await picker.pickImage(source: source, imageQuality: 85, maxWidth: 1024);
|
||||
@ -64,10 +65,9 @@ class RiverInSituSamplingService {
|
||||
img.drawString(originalImage, watermarkTimestamp, font: font, x: 10, y: 10, color: img.ColorRgb8(0, 0, 0));
|
||||
|
||||
final tempDir = await getTemporaryDirectory();
|
||||
// CHANGED: Assumes the station code key for rivers is 'r_man_station_code'. Adjust if necessary.
|
||||
final stationCode = data.selectedStation?['r_man_station_code'] ?? 'NA';
|
||||
final finalStationCode = stationCode ?? 'NA';
|
||||
final fileTimestamp = "${data.samplingDate}-${data.samplingTime}".replaceAll(':', '-');
|
||||
final newFileName = "${stationCode}_${fileTimestamp}_${imageInfo.replaceAll(' ', '')}.jpg";
|
||||
final newFileName = "${finalStationCode}_${fileTimestamp}_${imageInfo.replaceAll(' ', '')}.jpg";
|
||||
final filePath = path.join(tempDir.path, newFileName);
|
||||
|
||||
return File(filePath)..writeAsBytesSync(img.encodeJpg(originalImage));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user