feat: app 端 ui 设计完成

This commit is contained in:
liqupan
2026-01-28 19:10:19 +08:00
commit a4e7898e94
149 changed files with 11302 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import 'dart:async';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../models/device_status.dart';
class DeviceNotifier extends Notifier<DeviceStatus> {
Timer? _timer;
@override
DeviceStatus build() {
_startSimulation();
ref.onDispose(() {
_timer?.cancel();
});
return const DeviceStatus(connected: true, battery: 82.0);
}
void _startSimulation() {
_timer = Timer.periodic(const Duration(seconds: 5), (timer) {
if (state.battery > 0) {
state = state.copyWith(
battery: state.connected ? state.battery - 0.05 : state.battery,
signalStrength: state.connected ? (85 + (timer.tick % 10)).toInt() : 0,
);
}
});
}
void toggleConnection() {
state = state.copyWith(connected: !state.connected);
}
}
final deviceProvider = NotifierProvider<DeviceNotifier, DeviceStatus>(DeviceNotifier.new);