loading indicater has been added
This commit is contained in:
@@ -51,7 +51,6 @@ class _FinanceScreenState extends State<FinanceScreen> {
|
||||
|
||||
void _triggerLoad() {
|
||||
if (_employeeId != null && _employeeId!.isNotEmpty) {
|
||||
if (_financeBloc.state is FinanceInitial) {
|
||||
_financeBloc.add(
|
||||
LoadFinanceDataEvent(
|
||||
employeeId: _employeeId!,
|
||||
@@ -62,6 +61,12 @@ class _FinanceScreenState extends State<FinanceScreen> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onRefresh() async {
|
||||
_triggerLoad();
|
||||
await _financeBloc.stream.firstWhere(
|
||||
(state) => state is FinanceLoaded || state is FinanceError,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -71,9 +76,14 @@ class _FinanceScreenState extends State<FinanceScreen> {
|
||||
child: Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: SafeArea(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: _onRefresh,
|
||||
color: const Color(0xFF0A6B4A),
|
||||
child: CustomScrollView(
|
||||
controller: scrollController,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
physics: const AlwaysScrollableScrollPhysics(
|
||||
parent: BouncingScrollPhysics(),
|
||||
),
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: SettingsBar(
|
||||
@@ -130,7 +140,8 @@ class _FinanceScreenState extends State<FinanceScreen> {
|
||||
);
|
||||
if (date != null && mounted) {
|
||||
setState(() => selectedDate = date);
|
||||
if (_employeeId != null && _employeeId!.isNotEmpty) {
|
||||
if (_employeeId != null &&
|
||||
_employeeId!.isNotEmpty) {
|
||||
_financeBloc.add(
|
||||
LoadFinanceDataEvent(
|
||||
employeeId: _employeeId!,
|
||||
@@ -145,7 +156,8 @@ class _FinanceScreenState extends State<FinanceScreen> {
|
||||
onCategoryChanged: (category) {
|
||||
if (category != null) {
|
||||
setState(() => currentCategory = category);
|
||||
if (_employeeId != null && _employeeId!.isNotEmpty) {
|
||||
if (_employeeId != null &&
|
||||
_employeeId!.isNotEmpty) {
|
||||
_financeBloc.add(
|
||||
LoadFinanceDataEvent(
|
||||
employeeId: _employeeId!,
|
||||
@@ -213,6 +225,7 @@ class _FinanceScreenState extends State<FinanceScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,6 +223,10 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _onRefresh() async {
|
||||
await Future.wait([_loadVacationsFromAPI(), _loadAdvancesFromAPI()]);
|
||||
}
|
||||
|
||||
AdvanceRequest _convertAdvanceToAdvanceRequest(AdvanceDataModel advance) {
|
||||
// Convert state (0=waiting, 1=approved, 2=denied) to status string
|
||||
String status = "waiting";
|
||||
@@ -248,9 +252,14 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
||||
// ⭐ MAIN CONTENT - CUSTOM SCROLL VIEW
|
||||
// ---------------------------------------------------------
|
||||
SafeArea(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: _onRefresh,
|
||||
color: const Color(0xFF0A6B4A),
|
||||
child: CustomScrollView(
|
||||
controller: _scrollController,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
physics: const AlwaysScrollableScrollPhysics(
|
||||
parent: BouncingScrollPhysics(),
|
||||
),
|
||||
slivers: [
|
||||
// SETTINGS BAR
|
||||
SliverToBoxAdapter(
|
||||
@@ -367,6 +376,7 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// ⭐ FLOATING ACTION BUTTONS
|
||||
|
||||
Reference in New Issue
Block a user