Initial commit
This commit is contained in:
46
lib/widgets/brightness_slider.dart
Normal file
46
lib/widgets/brightness_slider.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BrightnessSlider extends StatelessWidget {
|
||||
final double value;
|
||||
final ValueChanged<double> onChanged;
|
||||
final ValueChanged<double>? onChangeEnd;
|
||||
|
||||
const BrightnessSlider({
|
||||
super.key,
|
||||
required this.value,
|
||||
required this.onChanged,
|
||||
this.onChangeEnd,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
const Icon(Icons.brightness_low, color: Colors.grey, size: 20),
|
||||
Expanded(
|
||||
child: SliderTheme(
|
||||
data: SliderTheme.of(context).copyWith(
|
||||
activeTrackColor: Colors.amber,
|
||||
thumbColor: Colors.amber,
|
||||
inactiveTrackColor: Colors.grey.shade800,
|
||||
),
|
||||
child: Slider(
|
||||
value: value,
|
||||
min: 0.0,
|
||||
max: 1.0,
|
||||
divisions: 20,
|
||||
onChanged: onChanged,
|
||||
onChangeEnd: onChangeEnd,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Icon(Icons.brightness_high, color: Colors.amber, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'${(value * 100).round()}%',
|
||||
style: TextStyle(color: Colors.grey.shade400, fontSize: 13),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
83
lib/widgets/status_button.dart
Normal file
83
lib/widgets/status_button.dart
Normal file
@@ -0,0 +1,83 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/busylight_status.dart';
|
||||
|
||||
class StatusButton extends StatelessWidget {
|
||||
final BusylightStatus status;
|
||||
final bool isActive;
|
||||
final bool isPending;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const StatusButton({
|
||||
super.key,
|
||||
required this.status,
|
||||
required this.isActive,
|
||||
required this.onTap,
|
||||
this.isPending = false,
|
||||
});
|
||||
|
||||
Color get _color {
|
||||
switch (status) {
|
||||
case BusylightStatus.available: return Colors.green;
|
||||
case BusylightStatus.away: return Colors.orange;
|
||||
case BusylightStatus.busy: return Colors.red;
|
||||
case BusylightStatus.on: return Colors.white;
|
||||
case BusylightStatus.off: return Colors.grey.shade700;
|
||||
case BusylightStatus.colored: return Colors.purple;
|
||||
}
|
||||
}
|
||||
|
||||
IconData get _icon {
|
||||
switch (status) {
|
||||
case BusylightStatus.available: return Icons.check_circle_outline;
|
||||
case BusylightStatus.away: return Icons.schedule;
|
||||
case BusylightStatus.busy: return Icons.do_not_disturb_on_outlined;
|
||||
case BusylightStatus.on: return Icons.lightbulb_outline;
|
||||
case BusylightStatus.off: return Icons.power_settings_new;
|
||||
case BusylightStatus.colored: return Icons.palette_outlined;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final activeColor = isActive || isPending ? _color : Colors.grey.shade600;
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: (isActive || isPending) ? _color.withOpacity(0.08) : Colors.transparent,
|
||||
border: Border.all(
|
||||
color: (isActive || isPending) ? _color.withOpacity(0.5) : Colors.grey.shade800,
|
||||
width: 1.5,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
isPending
|
||||
? SizedBox(
|
||||
width: 22,
|
||||
height: 22,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation(_color),
|
||||
),
|
||||
)
|
||||
: Icon(_icon, color: activeColor, size: 26),
|
||||
const SizedBox(height: 7),
|
||||
Text(
|
||||
status.label,
|
||||
style: TextStyle(
|
||||
color: activeColor,
|
||||
fontWeight: (isActive || isPending) ? FontWeight.w600 : FontWeight.w400,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user