mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
changed text style
This commit is contained in:
@ -12,72 +12,68 @@ class CounterWidget extends StatefulWidget {
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_CounterWidgetState createState() => _CounterWidgetState();
|
||||
State<CounterWidget> createState() => _CounterWidgetState();
|
||||
}
|
||||
|
||||
class _CounterWidgetState extends State<CounterWidget> {
|
||||
late int _counter = 0;
|
||||
late int _counter;
|
||||
|
||||
@override
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_counter = widget.initialCount;
|
||||
_counter = widget.initialCount;
|
||||
}
|
||||
|
||||
void _incrementCounter() {
|
||||
setState(() {
|
||||
_counter++;
|
||||
widget.onCountChanged(_counter);
|
||||
});
|
||||
}
|
||||
|
||||
void _decrementCounter() {
|
||||
setState(() {
|
||||
if (_counter > 0) {
|
||||
_counter--;
|
||||
widget.onCountChanged(_counter);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.counterBackgroundColor, // Background color for the counter
|
||||
borderRadius: BorderRadius.circular(20), // Rounded corners
|
||||
color: ColorsManager.counterBackgroundColor,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// Decrement button
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
if (_counter > 0) {
|
||||
_counter--;
|
||||
widget.onCountChanged(_counter);
|
||||
}
|
||||
});
|
||||
},
|
||||
child: const Icon(
|
||||
Icons.remove,
|
||||
color: ColorsManager.spaceColor, // Blue color
|
||||
size: 18, // Icon size
|
||||
),
|
||||
),
|
||||
_buildCounterButton(Icons.remove, _decrementCounter),
|
||||
const SizedBox(width: 8),
|
||||
// Counter value display
|
||||
Text(
|
||||
'$_counter',
|
||||
style: const TextStyle(
|
||||
color: ColorsManager.spaceColor, // Blue color
|
||||
fontSize: 16,
|
||||
),
|
||||
style: theme.textTheme.bodyLarge?.copyWith(color: ColorsManager.spaceColor),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
// Increment button
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_counter++;
|
||||
widget.onCountChanged(_counter);
|
||||
});
|
||||
},
|
||||
child: const Icon(
|
||||
Icons.add,
|
||||
color: ColorsManager.spaceColor, // Blue color
|
||||
size: 18, // Icon size
|
||||
),
|
||||
),
|
||||
_buildCounterButton(Icons.add, _incrementCounter),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCounterButton(IconData icon, VoidCallback onPressed) {
|
||||
return GestureDetector(
|
||||
onTap: onPressed,
|
||||
child: Icon(
|
||||
icon,
|
||||
color: ColorsManager.spaceColor,
|
||||
size: 18,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user