import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; import 'package:google_fonts/google_fonts.dart'; import '../widgets/glass_dialog.dart'; import '../widgets/animated_gradient_background.dart'; import '../widgets/ios_toast.dart'; import '../features/device/presentation/controllers/device_controller.dart'; class SettingsPage extends ConsumerStatefulWidget { const SettingsPage({super.key}); @override ConsumerState createState() => _SettingsPageState(); } class _SettingsPageState extends ConsumerState { // Local state — initialized from device detail String _deviceName = ''; String _userName = ''; double _volume = 50; double _brightness = 50; bool _allowInterrupt = true; bool _privacyMode = false; int? _userDeviceId; bool _initialized = false; @override Widget build(BuildContext context) { // Load current device's detail to populate settings final devicesAsync = ref.watch(deviceControllerProvider); final devices = devicesAsync.value ?? []; if (devices.isNotEmpty) { _userDeviceId = devices.first.id; final detailAsync = ref.watch( deviceDetailControllerProvider(_userDeviceId!), ); final detail = detailAsync.value; if (detail != null && !_initialized) { _initialized = true; final s = detail.settings; if (s != null) { _deviceName = s.nickname ?? detail.name; _userName = s.userName ?? ''; _volume = s.volume.toDouble(); _brightness = s.brightness.toDouble(); _allowInterrupt = s.allowInterrupt; _privacyMode = s.privacyMode; } else { _deviceName = detail.name; } } } return Scaffold( backgroundColor: Colors.transparent, body: Stack( children: [ const AnimatedGradientBackground(), SafeArea( child: Column( children: [ // Header Padding( padding: const EdgeInsets.symmetric( horizontal: 20, vertical: 12, ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ GestureDetector( onTap: () => Navigator.of(context).pop(), child: Container( width: 44, height: 44, decoration: BoxDecoration( // HTML icon-btn style: rgba(255, 255, 255, 0.25) but settings-header says transparent! // CSS .settings-header says: background: transparent !important; // And the button inside? HTML lines 885: