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