Skip to content

Commit d2f0e5f

Browse files
author
Alex
committed
πŸ“ Refine comments for clarity and readability
1 parent 59984b9 commit d2f0e5f

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

β€Žlib/presentation_layer/atoms/refresh_indicator_no_need.dart

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

5+
/// A custom refresh indicator widget that displays a message instead of the usual indicator
6+
///
7+
/// This widget wraps around a child widget and displays a custom indicator with a "no need" message.
58
class RefreshIndicatorNoNeed extends StatelessWidget {
69
final Widget child;
7-
final Future<void> Function() onRefresh;
10+
final Future<void> Function() onRefresh; // The callback function to trigger the refresh.
811

912
const RefreshIndicatorNoNeed({
1013
Key? key,
1114
required this.child,
12-
required this.onRefresh,
15+
required this.onRefresh, // Function that handles the refresh logic.
1316
}) : super(key: key);
1417

1518
@override
1619
Widget build(BuildContext context) {
1720
return CustomRefreshIndicator(
21+
// Custom builder for the refresh indicator.
1822
builder: (
1923
BuildContext context,
2024
Widget child,
@@ -23,49 +27,56 @@ class RefreshIndicatorNoNeed extends StatelessWidget {
2327
return Stack(
2428
children: <Widget>[
2529
_MyIndicator(
30+
// Pass the indicator's progress value and loading state to custom indicator widget.
2631
value: controller.value,
2732
loading: controller.state.isLoading,
2833
),
34+
// Translate the child widget vertically based on the progress of the refresh indicator.
2935
Transform.translate(
3036
offset: Offset(0, controller.value * 50),
3137
child: child,
3238
),
3339
],
3440
);
3541
},
42+
// Function to trigger the refresh when the user pulls to refresh.
3643
onRefresh: onRefresh,
37-
child: child,
44+
child: child, // Pass the child widget to be wrapped by the refresh indicator.
3845
);
3946
}
4047
}
4148

49+
/// A custom indicator widget that displays a message based on the refresh progress.
50+
///
51+
/// This widget is shown when the refresh indicator is active and shows a "no need" message.
4252
class _MyIndicator extends StatelessWidget {
43-
final double value;
44-
final bool loading;
53+
final double value; // The progress value of the refresh indicator.
54+
final bool loading; // The loading state of the refresh indicator.
4555

4656
const _MyIndicator({
4757
super.key,
48-
required this.value,
49-
required this.loading,
58+
required this.value, // The current progress value (from 0 to 1).
59+
required this.loading, // Whether the indicator is currently loading.
5060
});
5161

5262
@override
5363
Widget build(BuildContext context) {
54-
if (value == 0) return Container();
64+
if (value == 0) return Container(); // Return empty container if no progress is made.
65+
5566
return Padding(
5667
padding: const EdgeInsets.only(top: 28),
5768
child: Row(
58-
mainAxisAlignment: MainAxisAlignment.center,
69+
mainAxisAlignment: MainAxisAlignment.center,
5970
children: [
6071
Container(
61-
padding: const EdgeInsets.fromLTRB(20, 10, 20, 10),
72+
padding: const EdgeInsets.fromLTRB(20, 10, 20, 10),
6273
decoration: BoxDecoration(
63-
borderRadius: BorderRadius.circular(20),
64-
color: Palette.extraDarkGray,
74+
borderRadius: BorderRadius.circular(20),
75+
color: Palette.extraDarkGray,
6576
),
6677
child: const Text(
67-
'no need πŸ˜‰',
68-
style: TextStyle(color: Palette.white, fontSize: 18),
78+
'no need πŸ˜‰', // The custom message displayed when the refresh indicator is active.
79+
style: TextStyle(color: Palette.white, fontSize: 18), // Text style for the message.
6980
),
7081
),
7182
],

0 commit comments

Comments
Β (0)