Importált rétegek stílusának szerkesztése
This commit is contained in:
@@ -22,6 +22,29 @@ import '../controls/geojson_parser.dart';
|
||||
import '../core/kml_parser.dart';
|
||||
import '../services/project_service.dart';
|
||||
|
||||
class ImportedLayerStyle {
|
||||
final Color color;
|
||||
final double opacity;
|
||||
final double strokeWidth;
|
||||
|
||||
const ImportedLayerStyle({
|
||||
required this.color,
|
||||
this.opacity = 0.35,
|
||||
this.strokeWidth = 2.5,
|
||||
});
|
||||
|
||||
ImportedLayerStyle copyWith({
|
||||
Color? color,
|
||||
double? opacity,
|
||||
double? strokeWidth,
|
||||
}) =>
|
||||
ImportedLayerStyle(
|
||||
color: color ?? this.color,
|
||||
opacity: opacity ?? this.opacity,
|
||||
strokeWidth: strokeWidth ?? this.strokeWidth,
|
||||
);
|
||||
}
|
||||
|
||||
class LayerImportService extends GetxService {
|
||||
static LayerImportService get to => Get.find();
|
||||
|
||||
@@ -40,6 +63,7 @@ class LayerImportService extends GetxService {
|
||||
|
||||
String? _layerDir;
|
||||
static const _uuid = Uuid();
|
||||
final layerStyles = <String, ImportedLayerStyle>{}.obs;
|
||||
|
||||
// ── Inicializálás ──────────────────────────────────────────────────────────
|
||||
|
||||
@@ -137,6 +161,11 @@ class LayerImportService extends GetxService {
|
||||
final ext = meta.localPath.split('.').last;
|
||||
loaded.add(_parse(bytes, meta.name, meta.id, ext,
|
||||
isVisible: meta.isVisible));
|
||||
|
||||
final style = meta.getStyle();
|
||||
if (style != null) {
|
||||
layerStyles[meta.id] = style;
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('Réteg betöltés hiba (${meta.name}): $e');
|
||||
}
|
||||
@@ -271,4 +300,25 @@ class LayerImportService extends GetxService {
|
||||
'kmz' => LayerImportSourceType.kmz,
|
||||
_ => LayerImportSourceType.geoJson,
|
||||
};
|
||||
|
||||
void setLayerStyle(String id, ImportedLayerStyle style) async {
|
||||
layerStyles[id] = style;
|
||||
layerStyles.refresh();
|
||||
layers.refresh();
|
||||
|
||||
final metas = await AppDatabase.instance.listImportedLayers();
|
||||
final meta = metas.firstWhereOrNull((m) => m.id == id);
|
||||
|
||||
if (meta != null) {
|
||||
final hex =
|
||||
'#${style.color.value.toRadixString(16).padLeft(8, '0').substring(2).toUpperCase()}';
|
||||
|
||||
await AppDatabase.instance.updateImportedLayer(meta.copyWith(
|
||||
colorHex: hex,
|
||||
opacity: style.opacity,
|
||||
strokeWidth: style.strokeWidth));
|
||||
}
|
||||
}
|
||||
|
||||
ImportedLayerStyle? getLayerStyle(String id) => layerStyles[id];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user