mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-09-30 13:09:35 +02:00
first pass at operator profiles
This commit is contained in:
1 parent
04a6d129b7
commit
208b3486f3
15 files changed
+669
-13
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import 'dart:convert';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../models/operator_profile.dart';
|
||||
|
||||
class OperatorProfileService {
|
||||
static const _key = 'operator_profiles';
|
||||
|
||||
Future<List<OperatorProfile>> load() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final jsonStr = prefs.getString(_key);
|
||||
if (jsonStr == null) return [];
|
||||
final list = jsonDecode(jsonStr) as List<dynamic>;
|
||||
return list.map((e) => OperatorProfile.fromJson(e)).toList();
|
||||
}
|
||||
|
||||
Future<void> save(List<OperatorProfile> profiles) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final encodable = profiles.map((p) => p.toJson()).toList();
|
||||
await prefs.setString(_key, jsonEncode(encodable));
|
||||
}
|
||||
}
|
||||
@@ -36,10 +36,7 @@ class Uploader {
|
||||
print('Uploader: Created changeset ID: $csId');
|
||||
|
||||
// 2. create or update node
|
||||
final mergedTags = Map<String, String>.from(p.profile.tags);
|
||||
if (p.profile.requiresDirection) {
|
||||
mergedTags['direction'] = p.direction.round().toString();
|
||||
}
|
||||
final mergedTags = p.getCombinedTags();
|
||||
final tagsXml = mergedTags.entries.map((e) =>
|
||||
'<tag k="${e.key}" v="${e.value}"/>').join('\n ');
|
||||
|
||||
|
||||
Reference in new issue
Block a user