Skip to content

Commit 59984b9

Browse files
author
Alex
committed
📝 Refine comments for clarity and readability
1 parent dd5245c commit 59984b9

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed
Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,51 @@
1-
import 'package:camelus/config/palette.dart';
1+
import 'package:camelus/config/palette.dart';
22
import 'package:flutter/material.dart';
33

4+
/// Creates a custom long button widget.
5+
///
6+
/// This button is highly configurable with options for text,
7+
/// loading state and disabled state.
48
Widget longButton({
5-
required String name,
6-
required Function() onPressed,
7-
bool inverted = false,
8-
bool disabled = false,
9-
bool loading = false,
9+
required String name,
10+
required Function() onPressed, // Callback function for button press.
11+
bool inverted = false, // If true, swaps the color scheme for the button.
12+
bool disabled = false, // If true, disables the button.
13+
bool loading = false, // If true, displays a loading indicator instead of text.
1014
}) {
1115
return ElevatedButton(
16+
// Disable the button if `disabled` is true and not in a loading state.
1217
onPressed: disabled && !loading ? null : onPressed,
1318
style: ElevatedButton.styleFrom(
1419
disabledBackgroundColor: Palette.darkGray,
1520
foregroundColor: inverted ? Palette.black : Palette.lightGray,
1621
backgroundColor: inverted ? Palette.extraLightGray : Palette.black,
1722
shape: RoundedRectangleBorder(
18-
borderRadius: BorderRadius.circular(20),
19-
side: const BorderSide(color: Palette.white, width: 1),
23+
borderRadius: BorderRadius.circular(20),
24+
side: const BorderSide(color: Palette.white, width: 1),
2025
),
2126
),
27+
// Show a loading indicator if `loading` is true; otherwise, display text.
2228
child: loading
23-
? _progress()
29+
? _progress() // Widget to show a progress indicator.
2430
: Text(
25-
name,
31+
name, // Button text.
2632
style: TextStyle(
27-
color: inverted ? Palette.black : Palette.white,
28-
fontSize: 18,
33+
color: inverted ? Palette.black : Palette.white, // Text color.
34+
fontSize: 18, // Font size for the text.
2935
),
3036
),
3137
);
3238
}
3339

40+
/// Creates a loading indicator widget for the button.
41+
///
42+
/// This is a linear progress bar styled with colors defined in the `Palette`.
3443
Widget _progress() {
3544
return const Padding(
36-
padding: EdgeInsets.only(left: 10, right: 10),
45+
padding: EdgeInsets.only(left: 10, right: 10),
3746
child: LinearProgressIndicator(
38-
backgroundColor: Palette.gray,
39-
color: Palette.black,
47+
backgroundColor: Palette.gray,
48+
color: Palette.black,
4049
),
4150
);
4251
}

0 commit comments

Comments
 (0)