Skip to content

Commit

Permalink
Display the loader only when opening the page for the first time
Browse files Browse the repository at this point in the history
  • Loading branch information
erdemyerebasmaz committed May 14, 2024
1 parent 3eca26c commit 7974b9c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
9 changes: 7 additions & 2 deletions lib/routes/fiat_currencies/fiat_currency_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class FiatCurrencySettings extends StatefulWidget {
class FiatCurrencySettingsState extends State<FiatCurrencySettings> {
final _scrollController = ScrollController();

bool isInit = false;

@override
Widget build(BuildContext context) {
final texts = context.texts();
Expand All @@ -49,7 +51,7 @@ class FiatCurrencySettingsState extends State<FiatCurrencySettings> {
return FutureBuilder(
future: artificialWait(),
builder: (context, snapshot) {
if (snapshot.connectionState != ConnectionState.done) {
if (isInit == false && snapshot.connectionState != ConnectionState.done) {
return const Center(
child: Loader(
color: Colors.white,
Expand Down Expand Up @@ -207,9 +209,12 @@ class FiatCurrencySettingsState extends State<FiatCurrencySettings> {
/// and blocks the UI thread. Since data retrieval is not the bottleneck, it
/// blocks the UI thread almost immediately on the screen navigating to this page.
/// Before the underlying performance issues are fixed on the library.
/// We've added an artificial wait to display the page route animation and spinnig
/// We've added an artificial wait to display the page route animation and spinning
/// loader before UI thread is blocked to convey a better UX as a workaround.
Future artificialWait() async {
setState(() {
isInit = true;
});
return await Future.delayed(const Duration(milliseconds: 800));
}
}
9 changes: 5 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,11 @@ packages:
drag_and_drop_lists:
dependency: "direct main"
description:
name: drag_and_drop_lists
sha256: "9a14595f9880be7953f23578aef88c15cc9b367eeb39dbc1f1bd6af52f70872b"
url: "https://pub.dev"
source: hosted
path: "."
ref: "38cc3155a6161730b4ec476d781873afb7ec4846"
resolved-ref: "38cc3155a6161730b4ec476d781873afb7ec4846"
url: "https://github.com/breez/DragAndDropLists"
source: git
version: "0.3.3"
duration:
dependency: "direct main"
Expand Down
5 changes: 4 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ dependencies:
csv: ^6.0.0
connectivity_plus: ^6.0.3
device_info_plus: ^10.1.0
drag_and_drop_lists: ^0.3.3
drag_and_drop_lists:
git:
url: https://github.com/breez/DragAndDropLists
ref: 38cc3155a6161730b4ec476d781873afb7ec4846
duration: ^3.0.13
email_validator: ^2.1.17
extended_image: ^8.2.0
Expand Down

0 comments on commit 7974b9c

Please sign in to comment.