changed text style

This commit is contained in:
hannathkadher
2024-11-23 20:28:50 +04:00
parent 797133e16e
commit 77d73270b0

View File

@ -12,11 +12,11 @@ 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
void initState() {
@ -24,60 +24,56 @@ class _CounterWidgetState extends State<CounterWidget> {
_counter = widget.initialCount;
}
@override
Widget build(BuildContext 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
),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Decrement button
GestureDetector(
onTap: () {
void _incrementCounter() {
setState(() {
_counter++;
widget.onCountChanged(_counter);
});
}
void _decrementCounter() {
setState(() {
if (_counter > 0) {
_counter--;
widget.onCountChanged(_counter);
}
});
},
child: const Icon(
Icons.remove,
color: ColorsManager.spaceColor, // Blue color
size: 18, // Icon size
),
}
@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,
borderRadius: BorderRadius.circular(20),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
_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,
),
);
}
}