feat(contacts): обмен контактами NFC→BLE

This commit is contained in:
klockky
2026-06-21 10:18:48 +00:00
parent f20a818825
commit 6b082a81fe
6 changed files with 490 additions and 16 deletions
+12 -6
View File
@@ -3,13 +3,14 @@ import 'dart:io';
import 'package:flutter/services.dart';
enum NfcEventType { received, cancelled }
enum NfcEventType { received, cancelled, error }
class NfcEvent {
final NfcEventType type;
final int? id;
final String? reason;
const NfcEvent(this.type, this.id);
const NfcEvent(this.type, this.id, {this.reason});
}
class NfcStatus {
@@ -59,9 +60,14 @@ class NfcExchangeService {
NfcEvent _decodeEvent(dynamic raw) {
final map = raw is Map ? raw : const {};
final id = map['id'];
final type = map['event'] == 'received'
? NfcEventType.received
: NfcEventType.cancelled;
return NfcEvent(type, id is int ? id : (id is num ? id.toInt() : null));
final parsedId = id is int ? id : (id is num ? id.toInt() : null);
switch (map['event']) {
case 'received':
return NfcEvent(NfcEventType.received, parsedId);
case 'error':
return NfcEvent(NfcEventType.error, null, reason: map['reason'] as String?);
default:
return const NfcEvent(NfcEventType.cancelled, null);
}
}
}