loading indicater has been added

This commit is contained in:
Daniah Ayad Al-sultani
2026-02-17 17:19:53 +03:00
parent 5117fbdabe
commit 3a9e7ca8db
2 changed files with 260 additions and 237 deletions

View File

@@ -51,7 +51,6 @@ class _FinanceScreenState extends State<FinanceScreen> {
void _triggerLoad() { void _triggerLoad() {
if (_employeeId != null && _employeeId!.isNotEmpty) { if (_employeeId != null && _employeeId!.isNotEmpty) {
if (_financeBloc.state is FinanceInitial) {
_financeBloc.add( _financeBloc.add(
LoadFinanceDataEvent( LoadFinanceDataEvent(
employeeId: _employeeId!, 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 @override
@@ -71,9 +76,14 @@ class _FinanceScreenState extends State<FinanceScreen> {
child: Directionality( child: Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: SafeArea( child: SafeArea(
child: RefreshIndicator(
onRefresh: _onRefresh,
color: const Color(0xFF0A6B4A),
child: CustomScrollView( child: CustomScrollView(
controller: scrollController, controller: scrollController,
physics: const BouncingScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(
parent: BouncingScrollPhysics(),
),
slivers: [ slivers: [
SliverToBoxAdapter( SliverToBoxAdapter(
child: SettingsBar( child: SettingsBar(
@@ -130,7 +140,8 @@ class _FinanceScreenState extends State<FinanceScreen> {
); );
if (date != null && mounted) { if (date != null && mounted) {
setState(() => selectedDate = date); setState(() => selectedDate = date);
if (_employeeId != null && _employeeId!.isNotEmpty) { if (_employeeId != null &&
_employeeId!.isNotEmpty) {
_financeBloc.add( _financeBloc.add(
LoadFinanceDataEvent( LoadFinanceDataEvent(
employeeId: _employeeId!, employeeId: _employeeId!,
@@ -145,7 +156,8 @@ class _FinanceScreenState extends State<FinanceScreen> {
onCategoryChanged: (category) { onCategoryChanged: (category) {
if (category != null) { if (category != null) {
setState(() => currentCategory = category); setState(() => currentCategory = category);
if (_employeeId != null && _employeeId!.isNotEmpty) { if (_employeeId != null &&
_employeeId!.isNotEmpty) {
_financeBloc.add( _financeBloc.add(
LoadFinanceDataEvent( LoadFinanceDataEvent(
employeeId: _employeeId!, employeeId: _employeeId!,
@@ -213,6 +225,7 @@ class _FinanceScreenState extends State<FinanceScreen> {
), ),
), ),
), ),
),
); );
} }
} }

View File

@@ -223,6 +223,10 @@ class _HolidayScreenState extends State<HolidayScreen> {
); );
} }
Future<void> _onRefresh() async {
await Future.wait([_loadVacationsFromAPI(), _loadAdvancesFromAPI()]);
}
AdvanceRequest _convertAdvanceToAdvanceRequest(AdvanceDataModel advance) { AdvanceRequest _convertAdvanceToAdvanceRequest(AdvanceDataModel advance) {
// Convert state (0=waiting, 1=approved, 2=denied) to status string // Convert state (0=waiting, 1=approved, 2=denied) to status string
String status = "waiting"; String status = "waiting";
@@ -248,9 +252,14 @@ class _HolidayScreenState extends State<HolidayScreen> {
// ⭐ MAIN CONTENT - CUSTOM SCROLL VIEW // ⭐ MAIN CONTENT - CUSTOM SCROLL VIEW
// --------------------------------------------------------- // ---------------------------------------------------------
SafeArea( SafeArea(
child: RefreshIndicator(
onRefresh: _onRefresh,
color: const Color(0xFF0A6B4A),
child: CustomScrollView( child: CustomScrollView(
controller: _scrollController, controller: _scrollController,
physics: const BouncingScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(
parent: BouncingScrollPhysics(),
),
slivers: [ slivers: [
// SETTINGS BAR // SETTINGS BAR
SliverToBoxAdapter( SliverToBoxAdapter(
@@ -367,6 +376,7 @@ class _HolidayScreenState extends State<HolidayScreen> {
], ],
), ),
), ),
),
// --------------------------------------------------------- // ---------------------------------------------------------
// ⭐ FLOATING ACTION BUTTONS // ⭐ FLOATING ACTION BUTTONS