feat: secure home credentials
This commit is contained in:
@@ -30,37 +30,37 @@ class _SchedulesScreenState extends ConsumerState<SchedulesScreen> {
|
||||
final tasks = ref.watch(tasksProvider);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('РАСПИСАНИЯ'),
|
||||
),
|
||||
appBar: AppBar(title: const Text('РАСПИСАНИЯ')),
|
||||
body: _loading
|
||||
? const Center(child: CircularProgressIndicator(color: Colors.deepOrange))
|
||||
? const Center(
|
||||
child: CircularProgressIndicator(color: Colors.deepOrange),
|
||||
)
|
||||
: tasks.isEmpty
|
||||
? const Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.schedule, size: 64, color: Colors.white24),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
'Нет активных расписаний',
|
||||
style: TextStyle(color: Colors.white54, fontSize: 16),
|
||||
),
|
||||
],
|
||||
? const Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.schedule, size: 64, color: Colors.white24),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
'Нет активных расписаний',
|
||||
style: TextStyle(color: Colors.white54, fontSize: 16),
|
||||
),
|
||||
)
|
||||
: RefreshIndicator(
|
||||
color: Colors.deepOrange,
|
||||
onRefresh: () => ref.read(tasksProvider.notifier).load(),
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.all(12),
|
||||
itemCount: tasks.length,
|
||||
itemBuilder: (context, index) {
|
||||
final task = tasks[index];
|
||||
return _TaskCard(task: task);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: RefreshIndicator(
|
||||
color: Colors.deepOrange,
|
||||
onRefresh: () => ref.read(tasksProvider.notifier).load(),
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.all(12),
|
||||
itemCount: tasks.length,
|
||||
itemBuilder: (context, index) {
|
||||
final task = tasks[index];
|
||||
return _TaskCard(task: task);
|
||||
},
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
backgroundColor: Colors.deepOrange,
|
||||
onPressed: () => _showAddDialog(context),
|
||||
@@ -91,7 +91,9 @@ class _TaskCard extends ConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final map = task is Map ? Map<String, dynamic>.from(task) : <String, dynamic>{};
|
||||
final map = task is Map
|
||||
? Map<String, dynamic>.from(task)
|
||||
: <String, dynamic>{};
|
||||
final jobId = (map['id'] ?? map['job_id'] ?? '').toString();
|
||||
final targetId = (map['target_id'] ?? map['target'] ?? '').toString();
|
||||
final state = map['state'];
|
||||
@@ -102,8 +104,8 @@ class _TaskCard extends ConsumerWidget {
|
||||
final stateStr = state == true
|
||||
? 'Включить'
|
||||
: state == false
|
||||
? 'Выключить'
|
||||
: '?';
|
||||
? 'Выключить'
|
||||
: '?';
|
||||
|
||||
String subtitle = 'Цель: $targetId';
|
||||
if (runAt != null) subtitle += '\nЗапуск: $runAt';
|
||||
@@ -286,7 +288,9 @@ class _AddScheduleSheetState extends ConsumerState<_AddScheduleSheet> {
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _hourCtrl,
|
||||
decoration: const InputDecoration(labelText: 'Час (0-23)'),
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Час (0-23)',
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
),
|
||||
@@ -294,7 +298,9 @@ class _AddScheduleSheetState extends ConsumerState<_AddScheduleSheet> {
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _minuteCtrl,
|
||||
decoration: const InputDecoration(labelText: 'Минута (0-59)'),
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Минута (0-59)',
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
),
|
||||
@@ -336,13 +342,17 @@ class _AddScheduleSheetState extends ConsumerState<_AddScheduleSheet> {
|
||||
|
||||
try {
|
||||
if (_type == 'once') {
|
||||
await ref.read(tasksProvider.notifier).addOnce(
|
||||
await ref
|
||||
.read(tasksProvider.notifier)
|
||||
.addOnce(
|
||||
targetId: _selectedGroupId!,
|
||||
targetState: _targetState,
|
||||
hoursFromNow: _hoursFromNow,
|
||||
);
|
||||
} else {
|
||||
await ref.read(tasksProvider.notifier).addCron(
|
||||
await ref
|
||||
.read(tasksProvider.notifier)
|
||||
.addCron(
|
||||
targetId: _selectedGroupId!,
|
||||
hour: _hourCtrl.text.trim(),
|
||||
minute: _minuteCtrl.text.trim(),
|
||||
@@ -353,9 +363,9 @@ class _AddScheduleSheetState extends ConsumerState<_AddScheduleSheet> {
|
||||
if (mounted) Navigator.of(context).pop();
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Ошибка: $e')),
|
||||
);
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('Ошибка: $e')));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user