diff --git a/.github/workflows/syrius_builder.yml b/.github/workflows/syrius_builder.yml new file mode 100644 index 00000000..103ace09 --- /dev/null +++ b/.github/workflows/syrius_builder.yml @@ -0,0 +1,171 @@ +name: Build and release syrius + +on: + push: + branches-ignore: + - master + pull_request: + branches: + - dev + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build-macos: + runs-on: macos-12 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup environment + run: | + brew install unzip create-dmg + brew cleanup + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + - name: Check flutter version + run: flutter --version + - name: Build syrius desktop + run: | + flutter config --enable-macos-desktop + flutter build macos --release + - name: Package into DMG + run: | + create-dmg --volname syrius \ + --volicon macos/dmg/volume.icns \ + --icon "s\ y\ r\ i\ u\ s.app" 210 175 \ + --icon-size 90 \ + --app-drop-link 390 175 \ + --text-size 14 \ + --background macos/dmg/background.png \ + --window-pos 300 200 \ + --window-size 600 325 \ + --hide-extension "s\ y\ r\ i\ u\ s.app" \ + --format ULFO \ + --hdiutil-verbose syrius-alphanet-macos-universal.dmg build/macos/Build/Products/Release/s\ y\ r\ i\ u\ s.app \ + syrius-alphanet-macos-universal.dmg build/macos/Build/Products/Release/s\ y\ r\ i\ u\ s.app + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: macos-artifacts + path: syrius-alphanet-macos-universal.dmg + build-windows: + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + - name: Check flutter version + run: flutter --version + - name: Build syrius desktop + run: | + flutter config --enable-windows-desktop + flutter build windows --release + - name: Package into zip + run: | + Compress-Archive -Path build\windows\runner\Release\* -DestinationPath .\syrius-alphanet-windows-amd64.zip + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: windows-artifacts + path: syrius-alphanet-windows-amd64.zip + build-linux: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Prepare environment + run: | + sudo apt update + sudo apt install -y curl clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev unzip xz-utils zip libnotify-dev libayatana-appindicator3-dev + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + - name: Check flutter version + run: flutter --version + - name: Build syrius desktop + run: | + flutter config --enable-linux-desktop + flutter build linux --release + - name: Package zip + run: | + cd build/linux/x64/release/bundle + zip -r ../../../../../syrius-alphanet-linux-amd64.zip * + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: linux-artifacts + path: syrius-alphanet-linux-amd64.zip + make-release: + needs: [build-macos, build-windows, build-linux] + runs-on: ubuntu-latest + if: github.event_name != 'pull_request' + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set variables + run: | + SYRIUS="v$(cat pubspec.yaml | grep version | sed 's/version://' | xargs)" + echo "Syrius Version: $SYRIUS" + echo "SYRIUS_VERSION=$SYRIUS" >> $GITHUB_ENV + GOZENON=$(curl -s https://raw.githubusercontent.com/zenon-network/go-zenon/master/metadata/version.go | grep Version | awk -F '"' '{print $2}') + echo "Go-Zenon Version: $GOZENON" + BODY=$(cat <> ${GITHUB_ENV} + echo "${BODY}" >> ${GITHUB_ENV} + echo "EOFMARKER" >> ${GITHUB_ENV} + - name: Prepare releases directory + run: mkdir releases + - name: Download macOS artifacts + uses: actions/download-artifact@v3 + with: + name: macos-artifacts + - name: Download Windows artifacts + uses: actions/download-artifact@v3 + with: + name: windows-artifacts + - name: Download Linux artifacts + uses: actions/download-artifact@v3 + with: + name: linux-artifacts + - name: Prepare releases + run: | + cp syrius-alphanet-windows-amd64.zip releases/ + cp syrius-alphanet-macos-universal.dmg releases/ + cp syrius-alphanet-linux-amd64.zip releases/ + - name: Generate checksums + run: | + cd releases/ + echo $(sha256sum *) + echo $(sha256sum *) >> SHA256CHECKSUMS.txt + - name: Upload files to a GitHub release + uses: svenstaro/upload-release-action@2.4.1 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: releases/* + release_name: ${{ env.SYRIUS_VERSION }} + tag: ${{ env.SYRIUS_VERSION }}-alphanet + file_glob: true + overwrite: true + body: ${{ env.BODY }} diff --git a/.github/workflows/syrius_lib_updater.yml b/.github/workflows/syrius_lib_updater.yml new file mode 100644 index 00000000..e17d614f --- /dev/null +++ b/.github/workflows/syrius_lib_updater.yml @@ -0,0 +1,63 @@ +name: Library updater for syrius + +on: + push: + branches-ignore: + - master + pull_request: + branches: + - dev + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + lib-builder: + runs-on: ubuntu-latest + steps: + - name: Prepare environment + run: | + sudo apt update + sudo apt install -y unzip + - name: Checkout + uses: actions/checkout@v3 + - name: Download libznn + uses: robinraju/release-downloader@v1.6 + with: + repository: "zenon-network/go-zenon" + latest: true + - name: Extract libznn library + run: | + tar -xvf libznn-linux-amd64.tar.gz + tar -xvf libznn-darwin-universal.tar.gz + unzip -j libznn-windows-amd64.zip -d ./ + - name: Check if changes are present + run: | + LIBZNN_LINUX_AMD64=$(sha256sum ./libznn-linux-amd64.so | head -c 64) + LIBZNN_LINUX_AMD64_LOCAL=$(sha256sum ./lib/embedded_node/blobs/libznn.so | head -c 64) + LIBZNN_WINDOWS_AMD64=$(sha256sum ./libznn-windows-amd64.dll | head -c 64) + LIBZNN_WINDOWS_AMD64_LOCAL=$(sha256sum ./lib/embedded_node/blobs/libznn.dll | head -c 64) + LIBZNN_DARWIN_UNIVERSAL=$(sha256sum ./libznn-darwin-universal.dylib | head -c 64) + LIBZNN_DARWIN_UNIVERSAL_LOCAL=$(sha256sum ./lib/embedded_node/blobs/libznn.dylib | head -c 64) + function check() { + if [[ "$LIBZNN_LINUX_AMD64" == "$LIBZNN_LINUX_AMD64_LOCAL" && "$LIBZNN_WINDOWS_AMD64" == "$LIBZNN_WINDOWS_AMD64_LOCAL" && "$LIBZNN_DARWIN_UNIVERSAL" == "$LIBZNN_DARWIN_UNIVERSAL_LOCAL" ]]; + then + echo "0" + else + echo "1" + fi + } + echo "CHANGED=$(check)" >> $GITHUB_ENV + - name: Move libznn native library to blobs directory + if: ${{ env.CHANGED == '1' }} + run: | + mv libznn-linux-amd64.so lib/embedded_node/blobs/libznn.so + mv libznn-darwin-universal.dylib lib/embedded_node/blobs/libznn.dylib + mv libznn-windows-amd64.dll lib/embedded_node/blobs/libznn.dll + - name: Push if changes are present + if: ${{ env.CHANGED == '1' }} + run: | + git config user.name "Github Actions" + git config user.email "GH-actions-ci@github.com" + git add -f lib/embedded_node/blobs/* + git commit -m "Updated native libraries" + git push origin ${GITHUB_REF##*/} \ No newline at end of file diff --git a/.gitignore b/.gitignore index ee0081f2..7cbd829e 100644 --- a/.gitignore +++ b/.gitignore @@ -170,4 +170,5 @@ app.*.map.json !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages -!/dev/ci/**/Gemfile.lock \ No newline at end of file +!/dev/ci/**/Gemfile.lock +!pubspec.lock \ No newline at end of file diff --git a/LICENSE b/LICENSE index b3ec6657..5241c29c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 The Zenon developers +Copyright (c) 2023 The Zenon developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 6b55241c..74e4e375 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # s y r i u s +[![Build and release syrius](https://github.com/zenon-network/syrius/actions/workflows/syrius_builder.yml/badge.svg?branch=cicd)](https://github.com/zenon-network/syrius/actions/workflows/syrius_builder.yml) [![Library updater for syrius](https://github.com/zenon-network/syrius/actions/workflows/syrius_lib_updater.yml/badge.svg?branch=cicd)](https://github.com/zenon-network/syrius/actions/workflows/syrius_lib_updater.yml) + Cross-platform non-custodial wallet designed for Alphanet - Network of Momentum Phase 0. Developed in Flutter using the [Zenon Dart SDK](https://github.com/zenon-network/znn_sdk_dart), `s y r i u s` wallet provides a simple and intuitive interface to interact with Network of Momentum Phase 0. @@ -29,6 +31,8 @@ Currently supported ``: `windows`, `macos`, `linux` git clone https://github.com/zenon-network/syrius.git flutter pub get flutter build +flutter build --release +flutter run --release ``` ## Contributing diff --git a/analysis_options.yaml b/analysis_options.yaml index ae08714c..fbd285ef 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -22,8 +22,19 @@ linter: # `// ignore_for_file: name_of_lint` syntax on the line or in the file # producing the lint. rules: - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule - + avoid_print: true # Uncomment to disable the `avoid_print` rule + prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + cancel_subscriptions: true + close_sinks: true + comment_references: true + one_member_abstracts: true + always_use_package_imports: true + avoid_empty_else: true + avoid_slow_async_io: true + avoid_web_libraries_in_flutter: true + control_flow_in_finally: true + empty_statements: true + depend_on_referenced_packages: true + secure_pubspec_urls: true # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options diff --git a/assets/images/tray_app_icon.ico b/assets/images/tray_app_icon.ico new file mode 100644 index 00000000..6d34a119 Binary files /dev/null and b/assets/images/tray_app_icon.ico differ diff --git a/assets/images/tray_app_icon.png b/assets/images/tray_app_icon.png new file mode 100644 index 00000000..d5651aa5 Binary files /dev/null and b/assets/images/tray_app_icon.png differ diff --git a/lib/blocs/accelerator/accelerator.dart b/lib/blocs/accelerator/accelerator.dart new file mode 100644 index 00000000..eb00346e --- /dev/null +++ b/lib/blocs/accelerator/accelerator.dart @@ -0,0 +1,11 @@ +library accelerator; + +export 'accelerator_balance_bloc.dart'; +export 'create_phase_bloc.dart'; +export 'create_project_bloc.dart'; +export 'project_list_bloc.dart'; +export 'project_vote_breakdown_bloc.dart'; +export 'refresh_project_bloc.dart'; +export 'submit_donation_bloc.dart'; +export 'update_phase_bloc.dart'; +export 'vote_project_bloc.dart'; diff --git a/lib/blocs/accelerator/accelerator_balance_bloc.dart b/lib/blocs/accelerator/accelerator_balance_bloc.dart index b6c82c9e..29a23350 100644 --- a/lib/blocs/accelerator/accelerator_balance_bloc.dart +++ b/lib/blocs/accelerator/accelerator_balance_bloc.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -16,8 +16,8 @@ class AcceleratorBalanceBloc extends BaseBloc { } else { throw 'Accelerator fund empty'; } - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/accelerator/create_phase_bloc.dart b/lib/blocs/accelerator/create_phase_bloc.dart index 31c27e04..7d98d37a 100644 --- a/lib/blocs/accelerator/create_phase_bloc.dart +++ b/lib/blocs/accelerator/create_phase_bloc.dart @@ -1,17 +1,17 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class CreatePhaseBloc extends BaseBloc { - void createPhase( + Future createPhase( Hash id, String name, String description, String url, int znnFundsNeeded, int qsrFundsNeeded, - ) { + ) async { try { addEvent(null); AccountBlockTemplate transactionParams = @@ -29,11 +29,11 @@ class CreatePhaseBloc extends BaseBloc { ) .onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/accelerator/create_project_bloc.dart b/lib/blocs/accelerator/create_project_bloc.dart index 0350a23a..aa00771f 100644 --- a/lib/blocs/accelerator/create_project_bloc.dart +++ b/lib/blocs/accelerator/create_project_bloc.dart @@ -1,7 +1,6 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class CreateProjectBloc extends BaseBloc { @@ -32,11 +31,11 @@ class CreateProjectBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/accelerator/project_list_bloc.dart b/lib/blocs/accelerator/project_list_bloc.dart index 08bdb5ab..b5e82ea1 100644 --- a/lib/blocs/accelerator/project_list_bloc.dart +++ b/lib/blocs/accelerator/project_list_bloc.dart @@ -1,18 +1,17 @@ import 'dart:async'; +import 'package:logging/logging.dart'; import 'package:rxdart/rxdart.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/infinite_scroll_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/refresh_bloc_mixin.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/logger.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/accelerator_widgets/project_list.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ProjectListBloc with RefreshBlocMixin { List? _allProjects; - final List selectedProjectsFilterTag = []; + final List selectedProjectsFilterTag = []; final PillarInfo? pillarInfo; @@ -88,8 +87,8 @@ class ProjectListBloc with RefreshBlocMixin { nextPageKey: nextPageKey, itemList: allItems, ); - } catch (e) { - Logger.logError(e); + } catch (e, stackTrace) { + Logger('ProjectListBloc').log(Level.WARNING, 'addError', e, stackTrace); yield InfiniteScrollBlocListingState( error: e, nextPageKey: lastListingState.nextPageKey, @@ -105,39 +104,26 @@ class ProjectListBloc with RefreshBlocMixin { _onPageRequest.close(); } - Future> _getDataBySearchTerm( - int pageKey, - int pageSize, - String searchTerm, - ) async { - _allProjects ??= (await zenon!.embedded.accelerator.getAll()).list; - Set results = - _filterProjectsBySearchKeyWord(_allProjects!, searchTerm); - List subListResults = results.toList().sublist( - pageKey * pageSize, - (pageKey + 1) * pageSize <= results.length - ? (pageKey + 1) * pageSize - : results.length, - ); - return _filterProjectsAccordingToPillarInfo( - await _filterProjectsByTags(subListResults)); - } - Future> getData( int pageKey, int pageSize, String? searchTerm, ) async { + _allProjects ??= (await zenon!.embedded.accelerator.getAll()).list; + List results = []; if (searchTerm != null && searchTerm.isNotEmpty) { - return _getDataBySearchTerm(pageKey, pageSize, searchTerm); + results = + _filterProjectsBySearchKeyWord(_allProjects!, searchTerm).toList(); + } else { + results = _allProjects!; } - List projectList = (await zenon!.embedded.accelerator.getAll( - pageIndex: pageKey, - pageSize: pageSize, - )) - .list; - return await _filterProjectsAccordingToPillarInfo( - await _filterProjectsByTags(projectList), + results = (await _filterProjectsAccordingToPillarInfo( + await _filterProjectsByTags(results))); + return results.sublist( + pageKey * pageSize, + (pageKey + 1) * pageSize <= results.length + ? (pageKey + 1) * pageSize + : results.length, ); } @@ -221,38 +207,30 @@ class ProjectListBloc with RefreshBlocMixin { Future> _filterProjectsByTags(List projects) async { if (selectedProjectsFilterTag.isNotEmpty) { Iterable? votedProjectIds; - var filteredProjects = const Iterable.empty(); - if (selectedProjectsFilterTag.contains(ProjectsFilterTag.myProjects)) { - filteredProjects = projects.where( + Iterable filteredProjects = projects; + if (selectedProjectsFilterTag.contains(AccProjectsFilterTag.myProjects)) { + filteredProjects = filteredProjects.where( (project) => kDefaultAddressList.contains(project.owner.toString()), ); } - if (selectedProjectsFilterTag.contains(ProjectsFilterTag.onlyAccepted)) { - if (filteredProjects.isNotEmpty) { - filteredProjects = filteredProjects.where( - (project) => project.status == AcceleratorProjectStatus.active); - } else { - filteredProjects = projects.where( - (project) => project.status == AcceleratorProjectStatus.active); - } + if (selectedProjectsFilterTag + .contains(AccProjectsFilterTag.onlyAccepted)) { + filteredProjects = filteredProjects.where( + (project) => project.status == AcceleratorProjectStatus.active); } - if (selectedProjectsFilterTag.contains(ProjectsFilterTag.votingOpened)) { - var projectsToBeChecked = - filteredProjects.isNotEmpty ? filteredProjects : projects; - votedProjectIds ??= - await _getVotedProjectIdsByPillar(projectsToBeChecked); - filteredProjects = projectsToBeChecked.where( + if (selectedProjectsFilterTag + .contains(AccProjectsFilterTag.votingOpened)) { + votedProjectIds ??= await _getVotedProjectIdsByPillar(filteredProjects); + filteredProjects = filteredProjects.where( (project) => project.status == AcceleratorProjectStatus.voting && !votedProjectIds!.contains(project.id), ); } - if (selectedProjectsFilterTag.contains(ProjectsFilterTag.alreadyVoted)) { - var projectsToBeChecked = - filteredProjects.isNotEmpty ? filteredProjects : projects; - votedProjectIds ??= - await _getVotedProjectIdsByPillar(projectsToBeChecked); - filteredProjects = projectsToBeChecked.where( + if (selectedProjectsFilterTag + .contains(AccProjectsFilterTag.alreadyVoted)) { + votedProjectIds ??= await _getVotedProjectIdsByPillar(filteredProjects); + filteredProjects = filteredProjects.where( (project) => votedProjectIds!.contains(project.id), ); } diff --git a/lib/blocs/accelerator/project_vote_breakdown_bloc.dart b/lib/blocs/accelerator/project_vote_breakdown_bloc.dart index a9fec309..cbb897b9 100644 --- a/lib/blocs/accelerator/project_vote_breakdown_bloc.dart +++ b/lib/blocs/accelerator/project_vote_breakdown_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/pair.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -22,8 +22,8 @@ class ProjectVoteBreakdownBloc ); } addEvent(Pair(voteBreakdown, pillarVoteList)); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/accelerator/refresh_project_bloc.dart b/lib/blocs/accelerator/refresh_project_bloc.dart index 5e38ef0a..e48c9574 100644 --- a/lib/blocs/accelerator/refresh_project_bloc.dart +++ b/lib/blocs/accelerator/refresh_project_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -9,8 +9,8 @@ class RefreshProjectBloc extends BaseBloc { addEvent( await zenon!.embedded.accelerator.getProjectById(projectId.toString()), ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/accelerator/submit_donation_bloc.dart b/lib/blocs/accelerator/submit_donation_bloc.dart index efd814f8..50198852 100644 --- a/lib/blocs/accelerator/submit_donation_bloc.dart +++ b/lib/blocs/accelerator/submit_donation_bloc.dart @@ -1,5 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/accelerator/accelerator_balance_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; @@ -22,8 +21,8 @@ class SubmitDonationBloc extends BaseBloc { kQsrCoin.tokenStandard, )); } - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } @@ -39,7 +38,7 @@ class SubmitDonationBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); } diff --git a/lib/blocs/accelerator/update_phase_bloc.dart b/lib/blocs/accelerator/update_phase_bloc.dart index db1478d1..e120c017 100644 --- a/lib/blocs/accelerator/update_phase_bloc.dart +++ b/lib/blocs/accelerator/update_phase_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -29,11 +29,11 @@ class UpdatePhaseBloc extends BaseBloc { ) .onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/accelerator/vote_project_bloc.dart b/lib/blocs/accelerator/vote_project_bloc.dart index a2f50b59..120dc012 100644 --- a/lib/blocs/accelerator/vote_project_bloc.dart +++ b/lib/blocs/accelerator/vote_project_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; @@ -27,11 +27,11 @@ class VoteProjectBloc extends BaseBloc { ) .onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/auto_receive_tx_worker.dart b/lib/blocs/auto_receive_tx_worker.dart index 14b214bd..4e54bbe5 100644 --- a/lib/blocs/auto_receive_tx_worker.dart +++ b/lib/blocs/auto_receive_tx_worker.dart @@ -2,10 +2,10 @@ import 'dart:async'; import 'dart:collection'; import 'package:json_rpc_2/json_rpc_2.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:logging/logging.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; @@ -46,7 +46,9 @@ class AutoReceiveTxWorker extends BaseBloc { waitForRequiredPlasma: true, ); _sendSuccessNotification(response, toAddress); - } on RpcException catch (e) { + } on RpcException catch (e, stackTrace) { + Logger('AutoReceiveTxWorker') + .log(Level.WARNING, 'autoReceive', e, stackTrace); if (e.message.compareTo('account-block from-block already received') != 0) { pool.addFirst(currentHash); @@ -80,7 +82,7 @@ class AutoReceiveTxWorker extends BaseBloc { ); } - void addHash(Hash hash) { + Future addHash(Hash hash) async { if (!processedHashes.contains(hash)) { zenon!.stats.syncInfo().then((syncInfo) { if (!processedHashes.contains(hash) && diff --git a/lib/blocs/base_bloc.dart b/lib/blocs/base_bloc.dart index 5fe88cbb..b5bee582 100644 --- a/lib/blocs/base_bloc.dart +++ b/lib/blocs/base_bloc.dart @@ -1,8 +1,8 @@ import 'dart:async'; +import 'package:logging/logging.dart'; import 'package:rxdart/rxdart.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/logger.dart'; abstract class BaseBloc extends BaseViewModel { final BehaviorSubject _controller = BehaviorSubject(); @@ -15,9 +15,9 @@ abstract class BaseBloc extends BaseViewModel { if (!_controller.isClosed) _sink.add(event); } - void addError(error) { + void addError(error, stackTrace) { + Logger('BaseBloc').log(Level.WARNING, 'addError', error, stackTrace); if (!_controller.isClosed) { - Logger.logError(error); _sink.addError(error); } } diff --git a/lib/blocs/base_bloc_for_reloading_indicator.dart b/lib/blocs/base_bloc_for_reloading_indicator.dart index c15863c7..05a62ebc 100644 --- a/lib/blocs/base_bloc_for_reloading_indicator.dart +++ b/lib/blocs/base_bloc_for_reloading_indicator.dart @@ -1,7 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/refresh_bloc_mixin.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -22,13 +21,13 @@ abstract class BaseBlocForReloadingIndicator extends BaseBloc } else { throw noConnectionException; } - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } @override - dispose() { + dispose() async { cancelStreamSubscription(); super.dispose(); } diff --git a/lib/blocs/base_bloc_with_refresh_mixin.dart b/lib/blocs/base_bloc_with_refresh_mixin.dart index f42583b7..8e806aac 100644 --- a/lib/blocs/base_bloc_with_refresh_mixin.dart +++ b/lib/blocs/base_bloc_with_refresh_mixin.dart @@ -1,7 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/refresh_bloc_mixin.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -21,8 +20,8 @@ abstract class BaseBlocWithRefreshMixin extends BaseBloc } else { throw noConnectionException; } - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } diff --git a/lib/blocs/blocs.dart b/lib/blocs/blocs.dart new file mode 100644 index 00000000..1b1ecb40 --- /dev/null +++ b/lib/blocs/blocs.dart @@ -0,0 +1,24 @@ +library blocs; + +export 'auto_receive_tx_worker.dart'; +export 'base_bloc.dart'; +export 'base_bloc_for_reloading_indicator.dart'; +export 'base_bloc_with_refresh_mixin.dart'; +export 'decrypt_key_store_bloc.dart'; +export 'hide_widget_status_bloc.dart'; +export 'infinite_scroll_bloc.dart'; +export 'key_store_path_bloc.dart'; +export 'lock_bloc.dart'; +export 'node_sync_status_bloc.dart'; +export 'notifications_bloc.dart'; +export 'pow_generating_status_bloc.dart'; +export 'refresh_bloc_mixin.dart'; +export 'accelerator/accelerator.dart'; +export 'dashboard/dashboard.dart'; +export 'pillars/pillars.dart'; +export 'plasma/plasma.dart'; +export 'sentinels/sentinels.dart'; +export 'settings/settings.dart'; +export 'staking/staking.dart'; +export 'tokens/tokens.dart'; +export 'transfer/transfer.dart'; diff --git a/lib/blocs/dashboard/balance_bloc.dart b/lib/blocs/dashboard/balance_bloc.dart index c7c9f5dc..69cde008 100644 --- a/lib/blocs/dashboard/balance_bloc.dart +++ b/lib/blocs/dashboard/balance_bloc.dart @@ -1,7 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/refresh_bloc_mixin.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -27,8 +26,8 @@ class BalanceBloc extends BaseBloc?> addressBalanceMap[accountInfo.address!] = accountInfo; } addEvent(addressBalanceMap); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } diff --git a/lib/blocs/dashboard/balance_dashboard_bloc.dart b/lib/blocs/dashboard/balance_dashboard_bloc.dart index e2c81ee1..3ff0f364 100644 --- a/lib/blocs/dashboard/balance_dashboard_bloc.dart +++ b/lib/blocs/dashboard/balance_dashboard_bloc.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/dashboard_base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/dashboard/dashboard.dart b/lib/blocs/dashboard/dashboard.dart new file mode 100644 index 00000000..1c36d94f --- /dev/null +++ b/lib/blocs/dashboard/dashboard.dart @@ -0,0 +1,12 @@ +library dashboard; + +export 'balance_bloc.dart'; +export 'balance_dashboard_bloc.dart'; +export 'dashboard_base_bloc.dart'; +export 'delegation_bloc.dart'; +export 'dual_coin_stats_bloc.dart'; +export 'pillars_bloc.dart'; +export 'realtime_statistics_bloc.dart'; +export 'sentinels_bloc.dart'; +export 'staking_bloc.dart'; +export 'total_hourly_transactions_bloc.dart'; diff --git a/lib/blocs/dashboard/dashboard_base_bloc.dart b/lib/blocs/dashboard/dashboard_base_bloc.dart index 60c3de66..5daabf45 100644 --- a/lib/blocs/dashboard/dashboard_base_bloc.dart +++ b/lib/blocs/dashboard/dashboard_base_bloc.dart @@ -1,7 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/refresh_bloc_mixin.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -30,8 +29,8 @@ abstract class DashboardBaseBloc extends BaseBloc with RefreshBlocMixin { } else { throw noConnectionException; } - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } finally { if (_autoRefresher == null) { _autoRefresher = _getAutoRefreshTimer(); diff --git a/lib/blocs/dashboard/delegation_bloc.dart b/lib/blocs/dashboard/delegation_bloc.dart index a70edc5a..e2864534 100644 --- a/lib/blocs/dashboard/delegation_bloc.dart +++ b/lib/blocs/dashboard/delegation_bloc.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/dashboard_base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/dashboard/dual_coin_stats_bloc.dart b/lib/blocs/dashboard/dual_coin_stats_bloc.dart index 8d2bec35..5a477c4f 100644 --- a/lib/blocs/dashboard/dual_coin_stats_bloc.dart +++ b/lib/blocs/dashboard/dual_coin_stats_bloc.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/dashboard_base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/dashboard/pillars_bloc.dart b/lib/blocs/dashboard/pillars_bloc.dart index 3eb70e9e..87db9358 100644 --- a/lib/blocs/dashboard/pillars_bloc.dart +++ b/lib/blocs/dashboard/pillars_bloc.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/dashboard_base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; diff --git a/lib/blocs/dashboard/realtime_statistics_bloc.dart b/lib/blocs/dashboard/realtime_statistics_bloc.dart index 8b1895dd..8ae8e4cb 100644 --- a/lib/blocs/dashboard/realtime_statistics_bloc.dart +++ b/lib/blocs/dashboard/realtime_statistics_bloc.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/dashboard_base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; @@ -12,15 +12,37 @@ class RealtimeStatisticsBloc extends DashboardBaseBloc> { int chainHeight = (await zenon!.ledger.getFrontierMomentum()).height; int height = chainHeight - kMomentumsPerWeek > 0 ? chainHeight - kMomentumsPerWeek - : 2; - List response = (await zenon!.ledger.getAccountBlocksByHeight( - Address.parse(kSelectedAddress!), - height == 0 ? 0 : height - 1, - )) - .list ?? - []; - if (response.isNotEmpty) { - return response; + : 1; + int pageIndex = 0; + int pageSize = 10; + bool isLastPage = false; + List blockList = []; + + while (!isLastPage) { + List response = (await zenon!.ledger.getAccountBlocksByPage( + Address.parse(kSelectedAddress!), + pageIndex: pageIndex, + pageSize: pageSize, + )) + .list ?? + []; + + if (response.isEmpty) { + break; + } + + blockList.addAll(response); + + if (response.last.confirmationDetail!.momentumHeight <= height) { + break; + } + + pageIndex += 1; + isLastPage = response.length < pageSize; + } + + if (blockList.isNotEmpty) { + return blockList; } else { throw 'No available data'; } diff --git a/lib/blocs/dashboard/sentinels_bloc.dart b/lib/blocs/dashboard/sentinels_bloc.dart index 7fa9e064..0217a02c 100644 --- a/lib/blocs/dashboard/sentinels_bloc.dart +++ b/lib/blocs/dashboard/sentinels_bloc.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/dashboard_base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/dashboard/staking_bloc.dart b/lib/blocs/dashboard/staking_bloc.dart index 925c4866..46cef2b0 100644 --- a/lib/blocs/dashboard/staking_bloc.dart +++ b/lib/blocs/dashboard/staking_bloc.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/dashboard_base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; diff --git a/lib/blocs/dashboard/total_hourly_transactions_bloc.dart b/lib/blocs/dashboard/total_hourly_transactions_bloc.dart index ac3a120a..c1a2cf78 100644 --- a/lib/blocs/dashboard/total_hourly_transactions_bloc.dart +++ b/lib/blocs/dashboard/total_hourly_transactions_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/dashboard_base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/decrypt_key_store_bloc.dart b/lib/blocs/decrypt_key_store_bloc.dart index e4c38559..323ac64b 100644 --- a/lib/blocs/decrypt_key_store_bloc.dart +++ b/lib/blocs/decrypt_key_store_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/keystore_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -9,8 +9,8 @@ class DecryptKeyStoreBloc extends BaseBloc { KeyStore keyStore = await KeyStoreUtils.decryptKeyStoreFile(path, password); addEvent(keyStore); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/hide_widget_status_bloc.dart b/lib/blocs/hide_widget_status_bloc.dart index c786cabc..58776961 100644 --- a/lib/blocs/hide_widget_status_bloc.dart +++ b/lib/blocs/hide_widget_status_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; @@ -20,9 +20,9 @@ class HideWidgetStatusBloc extends BaseBloc { await _markWidgetAsHidden(widgetTitle, isHidden); addEvent(isHidden); } on IncorrectPasswordException { - addError(kIncorrectPasswordNotificationTitle); - } catch (e) { - addError(e); + addError(kIncorrectPasswordNotificationTitle, null); + } catch (e, stackTrace) { + addError(e, stackTrace); } } diff --git a/lib/blocs/infinite_scroll_bloc.dart b/lib/blocs/infinite_scroll_bloc.dart index c2d9c306..19c19964 100644 --- a/lib/blocs/infinite_scroll_bloc.dart +++ b/lib/blocs/infinite_scroll_bloc.dart @@ -1,8 +1,8 @@ import 'dart:async'; +import 'package:logging/logging.dart'; import 'package:rxdart/rxdart.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/refresh_bloc_mixin.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/logger.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; abstract class InfiniteScrollBloc with RefreshBlocMixin { InfiniteScrollBloc() { @@ -69,8 +69,9 @@ abstract class InfiniteScrollBloc with RefreshBlocMixin { nextPageKey: nextPageKey, itemList: allItems, ); - } catch (e) { - Logger.logError(e); + } catch (e, stackTrace) { + Logger('InfiniteScrollBloc') + .log(Level.WARNING, '_fetchList', e, stackTrace); yield InfiniteScrollBlocListingState( error: e, nextPageKey: lastListingState.nextPageKey, diff --git a/lib/blocs/key_store_path_bloc.dart b/lib/blocs/key_store_path_bloc.dart index 9124dda6..31f98cae 100644 --- a/lib/blocs/key_store_path_bloc.dart +++ b/lib/blocs/key_store_path_bloc.dart @@ -1,23 +1,21 @@ import 'dart:async'; -import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/keystore_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/init_utils.dart'; class KeyStorePathBloc extends BaseBloc { Future getKeyStorePath( - BuildContext context, String mnemonic, String passphrase, ) async { try { await KeyStoreUtils.createKeyStore(mnemonic, passphrase); - await Utils.initWalletAfterDecryption(context); + await InitUtils.initWalletAfterDecryption(); addEvent(kKeyStorePath); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/lock_bloc.dart b/lib/blocs/lock_bloc.dart index a81639f3..990adad8 100644 --- a/lib/blocs/lock_bloc.dart +++ b/lib/blocs/lock_bloc.dart @@ -1,6 +1,6 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/main_app_container.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; enum LockEvent { countDown, diff --git a/lib/blocs/node_sync_status_bloc.dart b/lib/blocs/node_sync_status_bloc.dart index ce9e0c4e..c012338d 100644 --- a/lib/blocs/node_sync_status_bloc.dart +++ b/lib/blocs/node_sync_status_bloc.dart @@ -1,7 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/auto_receive_tx_worker.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/dashboard_base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/node_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/notifications_bloc.dart b/lib/blocs/notifications_bloc.dart index 8aa5800a..cf8c3212 100644 --- a/lib/blocs/notifications_bloc.dart +++ b/lib/blocs/notifications_bloc.dart @@ -1,9 +1,10 @@ import 'dart:async'; import 'package:hive/hive.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; +import 'package:local_notifier/local_notifier.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; class NotificationsBloc extends BaseBloc { @@ -17,9 +18,16 @@ class NotificationsBloc extends BaseBloc { } } await notificationsBox.add(notification); + if (notification != null && _areDesktopNotificationsEnabled()) { + LocalNotification localNotification = LocalNotification( + title: notification.title ?? 'Empty title', + body: notification.details ?? 'No details available', + ); + localNotification.show(); + } addEvent(notification); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } @@ -45,4 +53,9 @@ class NotificationsBloc extends BaseBloc { ), ); } + + bool _areDesktopNotificationsEnabled() => sharedPrefsService!.get( + kEnableDesktopNotificationsKey, + defaultValue: kEnableDesktopNotificationsDefaultValue, + ); } diff --git a/lib/blocs/pillars/delegate_button_bloc.dart b/lib/blocs/pillars/delegate_button_bloc.dart index 1967c65b..63145e32 100644 --- a/lib/blocs/pillars/delegate_button_bloc.dart +++ b/lib/blocs/pillars/delegate_button_bloc.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; @@ -26,11 +26,11 @@ class DelegateButtonBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/pillars/delegation_info_bloc.dart b/lib/blocs/pillars/delegation_info_bloc.dart index 991fa8f5..25175034 100644 --- a/lib/blocs/pillars/delegation_info_bloc.dart +++ b/lib/blocs/pillars/delegation_info_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc_with_refresh_mixin.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/pillars/disassemble_pillar_bloc.dart b/lib/blocs/pillars/disassemble_pillar_bloc.dart index 7318e9b3..a41d9640 100644 --- a/lib/blocs/pillars/disassemble_pillar_bloc.dart +++ b/lib/blocs/pillars/disassemble_pillar_bloc.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; @@ -26,11 +26,11 @@ class DisassemblePillarBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/pillars/get_legacy_pillars_bloc.dart b/lib/blocs/pillars/get_legacy_pillars_bloc.dart deleted file mode 100644 index 72d5ea37..00000000 --- a/lib/blocs/pillars/get_legacy_pillars_bloc.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -class GetLegacyPillarsBloc extends BaseBloc?> { - Future checkForLegacyPillar() async { - try { - addEvent(null); - addEvent(await zenon!.embedded.swap.getLegacyPillars()); - } catch (e) { - addError(e); - } - } -} diff --git a/lib/blocs/pillars/get_pillar_by_owner_bloc.dart b/lib/blocs/pillars/get_pillar_by_owner_bloc.dart index 38d089e0..5a65c5f7 100644 --- a/lib/blocs/pillars/get_pillar_by_owner_bloc.dart +++ b/lib/blocs/pillars/get_pillar_by_owner_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc_with_refresh_mixin.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/pillars/pillar_rewards_history_bloc.dart b/lib/blocs/pillars/pillar_rewards_history_bloc.dart index 95c4645e..550725ab 100644 --- a/lib/blocs/pillars/pillar_rewards_history_bloc.dart +++ b/lib/blocs/pillars/pillar_rewards_history_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc_for_reloading_indicator.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; diff --git a/lib/blocs/pillars/pillar_uncollected_rewards_bloc.dart b/lib/blocs/pillars/pillar_uncollected_rewards_bloc.dart index 46cf32c9..407291d9 100644 --- a/lib/blocs/pillars/pillar_uncollected_rewards_bloc.dart +++ b/lib/blocs/pillars/pillar_uncollected_rewards_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc_for_reloading_indicator.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/pillars/pillars.dart b/lib/blocs/pillars/pillars.dart new file mode 100644 index 00000000..9b8d7f82 --- /dev/null +++ b/lib/blocs/pillars/pillars.dart @@ -0,0 +1,15 @@ +library pillars; + +export 'delegate_button_bloc.dart'; +export 'delegation_info_bloc.dart'; +export 'disassemble_pillar_bloc.dart'; +export 'get_pillar_by_owner_bloc.dart'; +export 'pillar_rewards_history_bloc.dart'; +export 'pillar_uncollected_rewards_bloc.dart'; +export 'pillars_deploy_bloc.dart'; +export 'pillars_deposit_qsr_bloc.dart'; +export 'pillars_list_bloc.dart'; +export 'pillars_qsr_info_bloc.dart'; +export 'pillars_withdraw_qsr_bloc.dart'; +export 'undelegate_button_bloc.dart'; +export 'update_pillar_bloc.dart'; diff --git a/lib/blocs/pillars/pillars_deploy_bloc.dart b/lib/blocs/pillars/pillars_deploy_bloc.dart index 0d668e3a..f44777ca 100644 --- a/lib/blocs/pillars/pillars_deploy_bloc.dart +++ b/lib/blocs/pillars/pillars_deploy_bloc.dart @@ -1,10 +1,10 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/pillars_widgets/pillars_stepper_container.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PillarsDeployBloc extends BaseBloc { @@ -23,24 +23,13 @@ class PillarsDeployBloc extends BaseBloc { if (await _pillarNameAlreadyExists(pillarName)) { throw 'Pillar name already exists'; } - AccountBlockTemplate transactionParams = - pillarType != PillarType.legacyPillar - ? zenon!.embedded.pillar.register( - pillarName, - Address.parse(blockProducingAddress), - Address.parse(rewardAddress), - giveBlockRewardPercentage, - giveDelegateRewardPercentage, - ) - : zenon!.embedded.pillar.registerLegacy( - pillarName, - Address.parse(blockProducingAddress), - Address.parse(rewardAddress), - publicKey!, - signature!, - giveBlockRewardPercentage, - giveDelegateRewardPercentage, - ); + AccountBlockTemplate transactionParams = zenon!.embedded.pillar.register( + pillarName, + Address.parse(blockProducingAddress), + Address.parse(rewardAddress), + giveBlockRewardPercentage, + giveDelegateRewardPercentage, + ); AccountBlockUtils.createAccountBlock( transactionParams, 'register Pillar', @@ -52,11 +41,11 @@ class PillarsDeployBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } diff --git a/lib/blocs/pillars/pillars_deposit_qsr_bloc.dart b/lib/blocs/pillars/pillars_deposit_qsr_bloc.dart index 36960fa6..9bfd15e7 100644 --- a/lib/blocs/pillars/pillars_deposit_qsr_bloc.dart +++ b/lib/blocs/pillars/pillars_deposit_qsr_bloc.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; @@ -35,12 +35,12 @@ class PillarsDepositQsrBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); } - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/pillars/pillars_list_bloc.dart b/lib/blocs/pillars/pillars_list_bloc.dart index a655f029..3c045850 100644 --- a/lib/blocs/pillars/pillars_list_bloc.dart +++ b/lib/blocs/pillars/pillars_list_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/infinite_scroll_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/pillars/pillars_qsr_info_bloc.dart b/lib/blocs/pillars/pillars_qsr_info_bloc.dart index c97f3286..e0751c7e 100644 --- a/lib/blocs/pillars/pillars_qsr_info_bloc.dart +++ b/lib/blocs/pillars/pillars_qsr_info_bloc.dart @@ -1,8 +1,8 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/pillars_qsr_info.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/pillars_widgets/pillars_stepper_container.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PillarsQsrInfoBloc extends BaseBloc { @@ -18,9 +18,7 @@ class PillarsQsrInfoBloc extends BaseBloc { .addDecimals( qsrDecimals, ); - num cost = (pillarType == PillarType.legacyPillar - ? pillarRegisterQsrAmount - : await zenon!.embedded.pillar.getQsrRegistrationCost()) + num cost = (await zenon!.embedded.pillar.getQsrRegistrationCost()) .addDecimals(qsrDecimals); addEvent( PillarsQsrInfo( @@ -28,8 +26,8 @@ class PillarsQsrInfoBloc extends BaseBloc { cost: cost, ), ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/pillars/pillars_withdraw_qsr_bloc.dart b/lib/blocs/pillars/pillars_withdraw_qsr_bloc.dart index a52990f2..d511c1d6 100644 --- a/lib/blocs/pillars/pillars_withdraw_qsr_bloc.dart +++ b/lib/blocs/pillars/pillars_withdraw_qsr_bloc.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; @@ -26,11 +26,11 @@ class PillarsWithdrawQsrBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/pillars/undelegate_button_bloc.dart b/lib/blocs/pillars/undelegate_button_bloc.dart index ffc8c274..6366b9de 100644 --- a/lib/blocs/pillars/undelegate_button_bloc.dart +++ b/lib/blocs/pillars/undelegate_button_bloc.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; @@ -22,11 +22,11 @@ class UndelegateButtonBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/pillars/update_pillar_bloc.dart b/lib/blocs/pillars/update_pillar_bloc.dart index 96e8e99d..d1a20f38 100644 --- a/lib/blocs/pillars/update_pillar_bloc.dart +++ b/lib/blocs/pillars/update_pillar_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -30,11 +30,11 @@ class UpdatePillarBloc extends BaseBloc { ) .onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/plasma/cancel_plasma_bloc.dart b/lib/blocs/plasma/cancel_plasma_bloc.dart index 5a4975f7..eb1f546d 100644 --- a/lib/blocs/plasma/cancel_plasma_bloc.dart +++ b/lib/blocs/plasma/cancel_plasma_bloc.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; @@ -21,11 +21,11 @@ class CancelPlasmaBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/plasma/plasma.dart b/lib/blocs/plasma/plasma.dart new file mode 100644 index 00000000..d7c6a287 --- /dev/null +++ b/lib/blocs/plasma/plasma.dart @@ -0,0 +1,6 @@ +library plasma; + +export 'cancel_plasma_bloc.dart'; +export 'plasma_list_bloc.dart'; +export 'plasma_options_bloc.dart'; +export 'plasma_stats_bloc.dart'; diff --git a/lib/blocs/plasma/plasma_list_bloc.dart b/lib/blocs/plasma/plasma_list_bloc.dart index f6a77303..5ed813b0 100644 --- a/lib/blocs/plasma/plasma_list_bloc.dart +++ b/lib/blocs/plasma/plasma_list_bloc.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/infinite_scroll_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/plasma/plasma_options_bloc.dart b/lib/blocs/plasma/plasma_options_bloc.dart index 52bcb4f6..e6d31034 100644 --- a/lib/blocs/plasma/plasma_options_bloc.dart +++ b/lib/blocs/plasma/plasma_options_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; @@ -25,11 +25,11 @@ class PlasmaOptionsBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/plasma/plasma_stats_bloc.dart b/lib/blocs/plasma/plasma_stats_bloc.dart index de5444a0..6f487c69 100644 --- a/lib/blocs/plasma/plasma_stats_bloc.dart +++ b/lib/blocs/plasma/plasma_stats_bloc.dart @@ -1,9 +1,8 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/refresh_bloc_mixin.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/plasma_info_wrapper.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -19,8 +18,8 @@ class PlasmaStatsBloc extends BaseBloc> kDefaultAddressList.map((e) => _getPlasma(e!)).toList(), ); addEvent(plasmaInfoWrapper); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } @@ -30,7 +29,8 @@ class PlasmaStatsBloc extends BaseBloc> Address.parse(address), ); return PlasmaInfoWrapper(address: address, plasmaInfo: plasmaInfo); - } catch (e) { + } catch (e, stackTrace) { + addError(e, stackTrace); rethrow; } } diff --git a/lib/blocs/pow_generating_status_bloc.dart b/lib/blocs/pow_generating_status_bloc.dart index a6a63f80..bd013828 100644 --- a/lib/blocs/pow_generating_status_bloc.dart +++ b/lib/blocs/pow_generating_status_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PowGeneratingStatusBloc extends BaseBloc {} diff --git a/lib/blocs/sentinels/disassemble_button_bloc.dart b/lib/blocs/sentinels/disassemble_button_bloc.dart index 1e411bfb..29c25321 100644 --- a/lib/blocs/sentinels/disassemble_button_bloc.dart +++ b/lib/blocs/sentinels/disassemble_button_bloc.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; @@ -22,11 +22,11 @@ class DisassembleButtonBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/sentinels/get_sentinel_by_owner_bloc.dart b/lib/blocs/sentinels/get_sentinel_by_owner_bloc.dart index 8515b047..ad507117 100644 --- a/lib/blocs/sentinels/get_sentinel_by_owner_bloc.dart +++ b/lib/blocs/sentinels/get_sentinel_by_owner_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc_with_refresh_mixin.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/sentinels/sentinel_deposit_qsr_bloc.dart b/lib/blocs/sentinels/sentinel_deposit_qsr_bloc.dart index 67ec9f34..5827162e 100644 --- a/lib/blocs/sentinels/sentinel_deposit_qsr_bloc.dart +++ b/lib/blocs/sentinels/sentinel_deposit_qsr_bloc.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; @@ -35,12 +35,12 @@ class SentinelsDepositQsrBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); } - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/sentinels/sentinel_list_bloc.dart b/lib/blocs/sentinels/sentinel_list_bloc.dart index 8c2463b4..a31aad78 100644 --- a/lib/blocs/sentinels/sentinel_list_bloc.dart +++ b/lib/blocs/sentinels/sentinel_list_bloc.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/infinite_scroll_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/sentinels/sentinel_qsr_info_bloc.dart b/lib/blocs/sentinels/sentinel_qsr_info_bloc.dart index 8fe0dcb1..8380be1a 100644 --- a/lib/blocs/sentinels/sentinel_qsr_info_bloc.dart +++ b/lib/blocs/sentinels/sentinel_qsr_info_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -14,8 +14,8 @@ class SentinelsQsrInfoBloc extends BaseBloc { qsrDecimals, ); addEvent(response); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/sentinels/sentinel_register_bloc.dart b/lib/blocs/sentinels/sentinel_register_bloc.dart index a5db9cf3..1f2fc0f6 100644 --- a/lib/blocs/sentinels/sentinel_register_bloc.dart +++ b/lib/blocs/sentinels/sentinel_register_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; @@ -21,11 +21,11 @@ class SentinelsDeployBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/sentinels/sentinel_rewards_history_bloc.dart b/lib/blocs/sentinels/sentinel_rewards_history_bloc.dart index 7adfb702..6ca0f6f0 100644 --- a/lib/blocs/sentinels/sentinel_rewards_history_bloc.dart +++ b/lib/blocs/sentinels/sentinel_rewards_history_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc_for_reloading_indicator.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; diff --git a/lib/blocs/sentinels/sentinel_uncollected_rewards_bloc.dart b/lib/blocs/sentinels/sentinel_uncollected_rewards_bloc.dart index 32fc2a95..0b9e2be9 100644 --- a/lib/blocs/sentinels/sentinel_uncollected_rewards_bloc.dart +++ b/lib/blocs/sentinels/sentinel_uncollected_rewards_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc_for_reloading_indicator.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/sentinels/sentinel_withdraw_qsr_bloc.dart b/lib/blocs/sentinels/sentinel_withdraw_qsr_bloc.dart index acf57958..1cde3f50 100644 --- a/lib/blocs/sentinels/sentinel_withdraw_qsr_bloc.dart +++ b/lib/blocs/sentinels/sentinel_withdraw_qsr_bloc.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; @@ -26,11 +26,11 @@ class SentinelsWithdrawQsrBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/sentinels/sentinels.dart b/lib/blocs/sentinels/sentinels.dart new file mode 100644 index 00000000..23523180 --- /dev/null +++ b/lib/blocs/sentinels/sentinels.dart @@ -0,0 +1,11 @@ +library sentinels; + +export 'disassemble_button_bloc.dart'; +export 'get_sentinel_by_owner_bloc.dart'; +export 'sentinel_deposit_qsr_bloc.dart'; +export 'sentinel_list_bloc.dart'; +export 'sentinel_qsr_info_bloc.dart'; +export 'sentinel_register_bloc.dart'; +export 'sentinel_rewards_history_bloc.dart'; +export 'sentinel_uncollected_rewards_bloc.dart'; +export 'sentinel_withdraw_qsr_bloc.dart'; diff --git a/lib/blocs/settings/account_chain_stats_bloc.dart b/lib/blocs/settings/account_chain_stats_bloc.dart index 1deb4a58..6583266b 100644 --- a/lib/blocs/settings/account_chain_stats_bloc.dart +++ b/lib/blocs/settings/account_chain_stats_bloc.dart @@ -1,6 +1,6 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc_for_reloading_indicator.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/account_chain_stats.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -13,20 +13,29 @@ class AccountChainStatsBloc kSelectedAddress!, ), ); - List blocks = (await zenon!.ledger.getAccountBlocksByHeight( - Address.parse( - kSelectedAddress!, - ), - 1, - accountInfo.blockCount! + 1, - )) - .list ?? - []; - if (accountInfo.blockCount! > 0) { + + int pageSize = accountInfo.blockCount!; + int pageCount = ((pageSize + 1) / rpcMaxPageSize).ceil(); + + if (pageSize > 0) { + List allBlocks = []; + + for (var i = 0; i < pageCount; i++) { + allBlocks.addAll((await zenon!.ledger.getAccountBlocksByHeight( + Address.parse( + kSelectedAddress!, + ), + (rpcMaxPageSize * i) + 1, + rpcMaxPageSize, + )) + .list ?? + []); + } + return AccountChainStats( - firstHash: blocks.isNotEmpty ? blocks.first.hash : '' as Hash, - blockCount: accountInfo.blockCount!, - blockTypeNumOfBlocksMap: _getNumOfBlocksForEachBlockType(blocks), + firstHash: allBlocks.isNotEmpty ? allBlocks.first.hash : emptyHash, + blockCount: pageSize, + blockTypeNumOfBlocksMap: _getNumOfBlocksForEachBlockType(allBlocks), ); } else { throw 'Empty account-chain'; diff --git a/lib/blocs/settings/general_stats_bloc.dart b/lib/blocs/settings/general_stats_bloc.dart index 29384047..b94a0579 100644 --- a/lib/blocs/settings/general_stats_bloc.dart +++ b/lib/blocs/settings/general_stats_bloc.dart @@ -1,8 +1,8 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc_with_refresh_mixin.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/general_stats.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class GeneralStatsBloc extends BaseBlocWithRefreshMixin { @@ -10,7 +10,7 @@ class GeneralStatsBloc extends BaseBlocWithRefreshMixin { @override Future getDataAsync() async { - GeneralStats _generalStats = GeneralStats( + GeneralStats generalStats = GeneralStats( frontierMomentum: await zenon!.ledger.getFrontierMomentum(), processInfo: await zenon!.stats.processInfo(), networkInfo: await zenon!.stats.networkInfo(), @@ -18,7 +18,7 @@ class GeneralStatsBloc extends BaseBlocWithRefreshMixin { if (_timer == null || !_timer!.isActive) { _timer = _getTimer(); } - return _generalStats; + return generalStats; } @override diff --git a/lib/blocs/settings/peers_bloc.dart b/lib/blocs/settings/peers_bloc.dart index 1ec08867..2823cac0 100644 --- a/lib/blocs/settings/peers_bloc.dart +++ b/lib/blocs/settings/peers_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc_with_refresh_mixin.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/settings/settings.dart b/lib/blocs/settings/settings.dart new file mode 100644 index 00000000..dbde5077 --- /dev/null +++ b/lib/blocs/settings/settings.dart @@ -0,0 +1,5 @@ +library settings; + +export 'account_chain_stats_bloc.dart'; +export 'general_stats_bloc.dart'; +export 'peers_bloc.dart'; diff --git a/lib/blocs/staking/cancel_stake_bloc.dart b/lib/blocs/staking/cancel_stake_bloc.dart index 81a5d4bb..58e6700f 100644 --- a/lib/blocs/staking/cancel_stake_bloc.dart +++ b/lib/blocs/staking/cancel_stake_bloc.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; @@ -23,11 +23,11 @@ class CancelStakeBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/staking/staking.dart b/lib/blocs/staking/staking.dart new file mode 100644 index 00000000..dd177baa --- /dev/null +++ b/lib/blocs/staking/staking.dart @@ -0,0 +1,7 @@ +library staking; + +export 'cancel_stake_bloc.dart'; +export 'staking_list_bloc.dart'; +export 'staking_options_bloc.dart'; +export 'staking_rewards_history_bloc.dart'; +export 'staking_uncollected_rewards_bloc.dart'; diff --git a/lib/blocs/staking/staking_list_bloc.dart b/lib/blocs/staking/staking_list_bloc.dart index dadc626c..86327c54 100644 --- a/lib/blocs/staking/staking_list_bloc.dart +++ b/lib/blocs/staking/staking_list_bloc.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/infinite_scroll_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/staking/staking_options_bloc.dart b/lib/blocs/staking/staking_options_bloc.dart index 09e549f1..130d9e5d 100644 --- a/lib/blocs/staking/staking_options_bloc.dart +++ b/lib/blocs/staking/staking_options_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; @@ -25,11 +25,11 @@ class StakingOptionsBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/staking/staking_rewards_history_bloc.dart b/lib/blocs/staking/staking_rewards_history_bloc.dart index ec5b5325..860875d7 100644 --- a/lib/blocs/staking/staking_rewards_history_bloc.dart +++ b/lib/blocs/staking/staking_rewards_history_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc_for_reloading_indicator.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; diff --git a/lib/blocs/staking/staking_uncollected_rewards_bloc.dart b/lib/blocs/staking/staking_uncollected_rewards_bloc.dart index 23c793b2..6ca983d6 100644 --- a/lib/blocs/staking/staking_uncollected_rewards_bloc.dart +++ b/lib/blocs/staking/staking_uncollected_rewards_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc_for_reloading_indicator.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/swap/get_assets_bloc.dart b/lib/blocs/swap/get_assets_bloc.dart deleted file mode 100644 index 2504ea58..00000000 --- a/lib/blocs/swap/get_assets_bloc.dart +++ /dev/null @@ -1,47 +0,0 @@ -import 'dart:async'; - -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/pair.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; -import 'package:znn_swap_utility/znn_swap_utility.dart'; - -class GetAssetsBloc - extends BaseBloc, List>?> { - Future getAssetAndSwapFileEntries( - List swapFileEntries, - ) async { - try { - addEvent(null); - List swapAssetEntries = []; - Iterable keyIds = swapFileEntries.map((e) => e.keyIdHashHex); - Map keyIdAssetsMap = - await zenon!.embedded.swap.getAssets(); - for (var key in keyIds) { - if (keyIdAssetsMap.containsKey(key)) { - keyIdAssetsMap[key]!.keyIdHash = Hash.parse(key); - swapAssetEntries.add(keyIdAssetsMap[key]!); - } - } - var filteredSwapFileEntries = swapFileEntries - .where((swapFileEntry) => swapAssetEntries - .map((e) => e.keyIdHash.toString()) - .toList() - .contains(swapFileEntry.keyIdHashHex)) - .toList(); - if (swapAssetEntries.length > kDefaultAddressList.length) { - int numOfAddressesNeeded = - swapAssetEntries.length - kDefaultAddressList.length; - await Future.forEach( - List.generate(numOfAddressesNeeded, (index) => null), - (element) async => await AddressUtils.generateNewAddress(), - ); - } - addEvent(Pair(swapAssetEntries, filteredSwapFileEntries)); - } catch (e) { - addError(e); - } - } -} diff --git a/lib/blocs/swap/read_wallet_bloc.dart b/lib/blocs/swap/read_wallet_bloc.dart deleted file mode 100644 index 6aa2307c..00000000 --- a/lib/blocs/swap/read_wallet_bloc.dart +++ /dev/null @@ -1,72 +0,0 @@ -import 'dart:async'; -import 'dart:io'; - -import 'package:path/path.dart' as path; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/file_utils.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; -import 'package:znn_swap_utility/znn_swap_utility.dart' as znn_swap; - -class ReadWalletBloc extends BaseBloc?> { - Future readWallet(String walletDatPath, String walletPass) async { - try { - addEvent(null); - List swapFileEntries = - await znn_swap.readSwapFile( - await _getSwpFilePath(walletDatPath, walletPass), - ); - await swapFileEntries[0].canDecryptWithAsync(walletPass); - addEvent(swapFileEntries); - } catch (e) { - addError(e); - } - } - - Future _getSwpFilePath( - String walletDatPath, String walletPass) async { - String swapWalletDirectoryPath = path.join( - znnDefaultDirectory.path, - kSwapWalletTempDirectory, - ); - if (await Directory(swapWalletDirectoryPath).exists()) { - await FileUtils.deleteDirectory(swapWalletDirectoryPath); - } - String walletSwpFilePath = path.join( - swapWalletDirectoryPath, - kNameWalletFile, - ); - String walletSwapFilePathWithExtension = path.setExtension( - walletSwpFilePath, - '.swp', - ); - if (!(await File(walletSwapFilePathWithExtension).exists())) { - await _makeDatFileCopy(walletDatPath, swapWalletDirectoryPath); - String response = - await znn_swap.exportSwapFile(swapWalletDirectoryPath, walletPass); - if (response.isNotEmpty) { - throw response; - } - } - return walletSwapFilePathWithExtension; - } - - Future _makeDatFileCopy( - String walletDatPath, - String swapWalletDirectoryPath, - ) async { - String walletDatCopyName = kNameWalletFile; - String walletDatCopyPath = path.join( - swapWalletDirectoryPath, - walletDatCopyName, - ); - String walletDatPathWithExtension = path.setExtension( - walletDatCopyPath, - '.dat', - ); - if (!(await File(walletDatPathWithExtension).exists())) { - await File(walletDatPathWithExtension).create(recursive: true); - await File(walletDatPath).copy(walletDatPathWithExtension); - } - } -} diff --git a/lib/blocs/swap/transfer_balance_bloc.dart b/lib/blocs/swap/transfer_balance_bloc.dart deleted file mode 100644 index 423375cf..00000000 --- a/lib/blocs/swap/transfer_balance_bloc.dart +++ /dev/null @@ -1,47 +0,0 @@ -import 'dart:async'; - -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; -import 'package:znn_swap_utility/znn_swap_utility.dart'; - -class TransferBalanceBloc extends BaseBloc { - Future transferBalanceToNewAddresses( - SwapFileEntry swapFileEntry, - Future futureBlockSigningKeyPair, - String passphrase, - ) async { - try { - addEvent(null); - KeyPair? blockSigningKeyPair = await futureBlockSigningKeyPair; - Address? alphaNetAddress = await blockSigningKeyPair!.address; - String signature = await swapFileEntry.signAssetsAsync( - passphrase, - alphaNetAddress!.toString(), - ); - AccountBlockTemplate transactionParams = - zenon!.embedded.swap.retrieveAssets( - swapFileEntry.pubKeyB64, - signature, - ); - AccountBlockUtils.createAccountBlock( - transactionParams, - 'transfer balance to new address', - blockSigningKey: blockSigningKeyPair, - waitForRequiredPlasma: true, - ).then( - (value) => addEvent(swapFileEntry), - onError: (error) { - addError(error); - }, - ).onError( - (error, stackTrace) { - addError(error.toString()); - }, - ); - } catch (e) { - addError(e); - } - } -} diff --git a/lib/blocs/tokens/burn_token_bloc.dart b/lib/blocs/tokens/burn_token_bloc.dart index 30f89699..98e22ab6 100644 --- a/lib/blocs/tokens/burn_token_bloc.dart +++ b/lib/blocs/tokens/burn_token_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; @@ -24,11 +24,11 @@ class BurnTokenBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/tokens/issue_token_bloc.dart b/lib/blocs/tokens/issue_token_bloc.dart index 7fa56fce..3ff959fa 100644 --- a/lib/blocs/tokens/issue_token_bloc.dart +++ b/lib/blocs/tokens/issue_token_bloc.dart @@ -1,7 +1,7 @@ import 'package:hive/hive.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/new_token_data.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; @@ -34,11 +34,11 @@ class IssueTokenBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/tokens/mint_token_bloc.dart b/lib/blocs/tokens/mint_token_bloc.dart index b3a10ff7..15d3d5a7 100644 --- a/lib/blocs/tokens/mint_token_bloc.dart +++ b/lib/blocs/tokens/mint_token_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; @@ -27,11 +27,11 @@ class MintTokenBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/tokens/token_map_bloc.dart b/lib/blocs/tokens/token_map_bloc.dart index 33b438b9..9756e1ad 100644 --- a/lib/blocs/tokens/token_map_bloc.dart +++ b/lib/blocs/tokens/token_map_bloc.dart @@ -1,13 +1,12 @@ import 'dart:async'; import 'package:hive/hive.dart'; +import 'package:logging/logging.dart'; import 'package:rxdart/rxdart.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/infinite_scroll_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/refresh_bloc_mixin.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/logger.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -81,8 +80,8 @@ class TokenMapBloc with RefreshBlocMixin { nextPageKey: nextPageKey, itemList: allItems, ); - } catch (e) { - Logger.logError(e); + } catch (e, stackTrace) { + Logger('TokenMapBloc').log(Level.WARNING, '_fetchList', e, stackTrace); yield InfiniteScrollBlocListingState( error: e, nextPageKey: lastListingState.nextPageKey, @@ -114,7 +113,7 @@ class TokenMapBloc with RefreshBlocMixin { } List _sortByIfTokenCreatedByUser(List tokens) { - List _sortedTokens = tokens + List sortedTokens = tokens .where( (token) => kDefaultAddressList.contains( token.owner.toString(), @@ -122,7 +121,7 @@ class TokenMapBloc with RefreshBlocMixin { ) .toList(); - _sortedTokens.addAll(tokens + sortedTokens.addAll(tokens .where( (token) => !kDefaultAddressList.contains( token.owner.toString(), @@ -130,29 +129,29 @@ class TokenMapBloc with RefreshBlocMixin { ) .toList()); - return _sortedTokens; + return sortedTokens; } List _sortByIfTokenIsInFavorites(List tokens) { - Box _favoriteTokens = Hive.box(kFavoriteTokensBox); + Box favoriteTokens = Hive.box(kFavoriteTokensBox); - List _sortedTokens = tokens + List sortedTokens = tokens .where( - (token) => _favoriteTokens.values.contains( + (token) => favoriteTokens.values.contains( token.tokenStandard.toString(), ), ) .toList(); - _sortedTokens.addAll(tokens + sortedTokens.addAll(tokens .where( - (token) => !_favoriteTokens.values.contains( + (token) => !favoriteTokens.values.contains( token.tokenStandard.toString(), ), ) .toList()); - return _sortedTokens; + return sortedTokens; } Future> getData( diff --git a/lib/blocs/tokens/tokens.dart b/lib/blocs/tokens/tokens.dart new file mode 100644 index 00000000..6587db06 --- /dev/null +++ b/lib/blocs/tokens/tokens.dart @@ -0,0 +1,8 @@ +library tokens; + +export 'burn_token_bloc.dart'; +export 'issue_token_bloc.dart'; +export 'mint_token_bloc.dart'; +export 'token_map_bloc.dart'; +export 'tokens_bloc.dart'; +export 'transfer_ownership_bloc.dart'; diff --git a/lib/blocs/tokens/tokens_bloc.dart b/lib/blocs/tokens/tokens_bloc.dart index 6bf7be48..a89556de 100644 --- a/lib/blocs/tokens/tokens_bloc.dart +++ b/lib/blocs/tokens/tokens_bloc.dart @@ -1,5 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/refresh_bloc_mixin.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -18,8 +17,8 @@ class TokensBloc extends BaseBloc?> with RefreshBlocMixin { try { addEvent(null); addEvent((await zenon!.embedded.token.getAll()).list); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/tokens/transfer_ownership_bloc.dart b/lib/blocs/tokens/transfer_ownership_bloc.dart index 64814f83..a5c7ca14 100644 --- a/lib/blocs/tokens/transfer_ownership_bloc.dart +++ b/lib/blocs/tokens/transfer_ownership_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -28,11 +28,11 @@ class TransferOwnershipBloc extends BaseBloc { ) .onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/transfer/latest_transactions_bloc.dart b/lib/blocs/transfer/latest_transactions_bloc.dart index 4a90e571..4295b556 100644 --- a/lib/blocs/transfer/latest_transactions_bloc.dart +++ b/lib/blocs/transfer/latest_transactions_bloc.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/infinite_scroll_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; diff --git a/lib/blocs/transfer/send_payment_bloc.dart b/lib/blocs/transfer/send_payment_bloc.dart index b13d9ff9..f8f1914f 100644 --- a/lib/blocs/transfer/send_payment_bloc.dart +++ b/lib/blocs/transfer/send_payment_bloc.dart @@ -1,4 +1,4 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; @@ -36,11 +36,11 @@ class SendPaymentBloc extends BaseBloc { }, ).onError( (error, stackTrace) { - addError(error.toString()); + addError(error, stackTrace); }, ); - } catch (e) { - addError(e.toString()); + } catch (e, stackTrace) { + addError(e, stackTrace); } } } diff --git a/lib/blocs/transfer/transfer.dart b/lib/blocs/transfer/transfer.dart new file mode 100644 index 00000000..525ca70a --- /dev/null +++ b/lib/blocs/transfer/transfer.dart @@ -0,0 +1,5 @@ +library transfer; + +export 'latest_transactions_bloc.dart'; +export 'send_payment_bloc.dart'; +export 'transfer_widgets_balance_bloc.dart'; diff --git a/lib/blocs/transfer/transfer_widgets_balance_bloc.dart b/lib/blocs/transfer/transfer_widgets_balance_bloc.dart index ef961c19..7192d31e 100644 --- a/lib/blocs/transfer/transfer_widgets_balance_bloc.dart +++ b/lib/blocs/transfer/transfer_widgets_balance_bloc.dart @@ -1,7 +1,6 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/base_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/refresh_bloc_mixin.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -25,8 +24,8 @@ class TransferWidgetsBalanceBloc extends BaseBloc?> addressBalanceMap[accountInfo.address!] = accountInfo; } addEvent(addressBalanceMap); - } catch (e) { - addError(e); + } catch (e, stackTrace) { + addError(e, stackTrace); } } diff --git a/lib/embedded_node/blobs/libznn.dll b/lib/embedded_node/blobs/libznn.dll old mode 100644 new mode 100755 index 14bb7e65..2ecd8e6c Binary files a/lib/embedded_node/blobs/libznn.dll and b/lib/embedded_node/blobs/libznn.dll differ diff --git a/lib/embedded_node/blobs/libznn.dylib b/lib/embedded_node/blobs/libznn.dylib old mode 100644 new mode 100755 index 31f9694f..980a1117 Binary files a/lib/embedded_node/blobs/libznn.dylib and b/lib/embedded_node/blobs/libznn.dylib differ diff --git a/lib/embedded_node/blobs/libznn.so b/lib/embedded_node/blobs/libznn.so old mode 100644 new mode 100755 index 111437ca..48581586 Binary files a/lib/embedded_node/blobs/libznn.so and b/lib/embedded_node/blobs/libznn.so differ diff --git a/lib/embedded_node/embedded_node.dart b/lib/embedded_node/embedded_node.dart index da383fe1..5e20532c 100644 --- a/lib/embedded_node/embedded_node.dart +++ b/lib/embedded_node/embedded_node.dart @@ -21,20 +21,26 @@ _RunNodeFunc? _runNodeFunction; class EmbeddedNode { static void initializeNodeLib() { - var insideSdk = path.join('wallet', 'lib', 'embedded_node', 'blobs'); + var insideSdk = path.join('syrius', 'lib', 'embedded_node', 'blobs'); var currentPathListParts = path.split(Directory.current.path); currentPathListParts.removeLast(); var executablePathListParts = path.split(Platform.resolvedExecutable); executablePathListParts.removeLast(); var possiblePaths = List.empty(growable: true); possiblePaths.add(Directory.current.path); + possiblePaths.add( + path.join( + Directory.current.path, + 'lib', + 'embedded_node', + 'blobs', + ), + ); possiblePaths.add(path.joinAll(executablePathListParts)); executablePathListParts.removeLast(); possiblePaths .add(path.join(path.joinAll(executablePathListParts), 'Resources')); possiblePaths.add(path.join(path.joinAll(currentPathListParts), insideSdk)); - possiblePaths.add( - path.join(path.joinAll(currentPathListParts), 'packages', insideSdk)); var libraryPath = ''; var found = false; @@ -57,7 +63,7 @@ class EmbeddedNode { } } - logger.info('Loading libznn from path ' + libraryPath); + logger.info('Loading libznn from path $libraryPath'); if (!found) { throw invalidZnnLibPathException; @@ -79,7 +85,7 @@ class EmbeddedNode { ReceivePort commandsPort = ReceivePort(); SendPort sendPort = commandsPort.sendPort; - IsolateNameServer.registerPortWithName(sendPort, "embeddedIsolate"); + IsolateNameServer.registerPortWithName(sendPort, 'embeddedIsolate'); if (_runNodeFunction == null) { initializeNodeLib(); @@ -89,7 +95,7 @@ class EmbeddedNode { Completer embeddedIsolateCompleter = Completer(); commandsPort.listen((event) { _stopNodeFunction!(); - IsolateNameServer.removePortNameMapping("embeddedIsolate"); + IsolateNameServer.removePortNameMapping('embeddedIsolate'); commandsPort.close(); embeddedIsolateCompleter.complete(); }); @@ -105,9 +111,9 @@ class EmbeddedNode { static bool stopNode() { SendPort? embeddedIsolate = - IsolateNameServer.lookupPortByName("embeddedIsolate"); + IsolateNameServer.lookupPortByName('embeddedIsolate'); if (embeddedIsolate != null) { - embeddedIsolate.send("stop"); + embeddedIsolate.send('stop'); return true; } return false; diff --git a/lib/main.dart b/lib/main.dart index edfb2197..2efb0a70 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,46 +1,25 @@ import 'dart:io'; import 'dart:isolate'; -import 'package:feedback/feedback.dart'; import 'package:flutter/foundation.dart' - show debugDefaultTargetPlatformOverride; + show debugDefaultTargetPlatformOverride, kDebugMode; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:get_it/get_it.dart'; import 'package:hive/hive.dart'; import 'package:layout/layout.dart'; +import 'package:local_notifier/local_notifier.dart'; +import 'package:logging/logging.dart'; import 'package:overlay_support/overlay_support.dart'; import 'package:provider/provider.dart'; +import 'package:tray_manager/tray_manager.dart'; import 'package:window_manager/window_manager.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/accelerator/accelerator_balance_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/auto_receive_tx_worker.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/balance_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/lock_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/plasma/plasma_stats_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pow_generating_status_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/transfer/transfer_widgets_balance_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; -import 'package:zenon_syrius_wallet_flutter/model/navigation_arguments.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/node_management_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/onboarding/access_wallet_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/splash_screen.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; import 'package:zenon_syrius_wallet_flutter/services/shared_prefs_service.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_theme.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/keyboard_fixer.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/network_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/node_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/notifiers/app_theme_notifier.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/notifiers/default_address_notifier.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/notifiers/plasma_beneficiary_address_notifier.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/notifiers/plasma_generated_notifier.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/notifiers/text_scaling_notifier.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/main_app_container.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; Zenon? zenon; @@ -54,6 +33,16 @@ main() async { Provider.debugCheckInvalidValueType = null; debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; + // Setup logger + Logger.root.level = Level.ALL; + Logger.root.onRecord.listen((record) { + if (kDebugMode) { + print( + '${record.level.name} ${record.loggerName} ${record.message} ${record.time}: ' + '${record.error} ${record.stackTrace}\n'); + } + }); + ensureDirectoriesExist(); Hive.init(znnDefaultPaths.cache.path.toString()); @@ -63,6 +52,16 @@ main() async { // Setup services setup(); + // Setup local_notifier + await localNotifier.setup( + appName: 's y r i u s', + // The parameter shortcutPolicy only works on Windows + shortcutPolicy: ShortcutPolicy.requireCreate, + ); + + // Setup tray manager + await _setupTrayManager(); + // Register Hive adapters Hive.registerAdapter(NotificationTypeAdapter()); Hive.registerAdapter(WalletNotificationAdapter()); @@ -106,20 +105,39 @@ main() async { } }); - runApp(BetterFeedback( - child: Builder( - builder: (_) => const MyApp(), + runApp( + const MyApp(), + ); +} + +Future _setupTrayManager() async { + if (!Platform.isWindows) { + await trayManager.setTitle('s y r i u s'); + } + await trayManager.setIcon( + Platform.isWindows + ? 'assets/images/tray_app_icon.ico' + : 'assets/images/tray_app_icon.png', + ); + if (Platform.isMacOS) { + await trayManager.setToolTip('s y r i u s'); + } + List items = [ + MenuItem( + key: 'show_wallet', + label: 'Show wallet', ), - theme: FeedbackThemeData( - background: Colors.black, - activeFeedbackModeColor: AppColors.znnColor, - drawColors: [ - AppColors.znnColor, - AppColors.qsrColor, - AppColors.errorColor, - ], + MenuItem( + key: 'hide_wallet', + label: 'Hide wallet', + ), + MenuItem.separator(), + MenuItem( + key: 'exit', + label: 'Exit wallet', ), - )); + ]; + await trayManager.setContextMenu(Menu(items: items)); } void setup() { @@ -154,10 +172,11 @@ class MyApp extends StatefulWidget { } } -class _MyAppState extends State with WindowListener { +class _MyAppState extends State with WindowListener, TrayListener { @override void initState() { windowManager.addListener(this); + trayManager.addListener(this); initPlatformState(); super.initState(); } @@ -225,37 +244,36 @@ class _MyAppState extends State with WindowListener { onKey: (RawKeyEvent event) { lockBloc.addEvent(LockEvent.resetTimer); }, - child: KeyboardFixer( - child: Layout( - child: MaterialApp( - title: 's y r i u s', - debugShowCheckedModeBanner: false, - theme: AppTheme.lightTheme, - darkTheme: AppTheme.darkTheme, - themeMode: appThemeNotifier.currentThemeMode, - initialRoute: SplashScreen.route, - routes: { - AccessWalletScreen.route: (context) => - const AccessWalletScreen(), - SplashScreen.route: (context) => - const SplashScreen(), - MainAppContainer.route: (context) => - const MainAppContainer(), - NodeManagementScreen.route: (_) => - const NodeManagementScreen(), - }, - onGenerateRoute: (settings) { - if (settings.name == SyriusErrorWidget.route) { - final args = settings.arguments - as CustomSyriusErrorWidgetArguments; - return MaterialPageRoute( - builder: (context) => - SyriusErrorWidget(args.errorText), - ); - } - return null; - }, - ), + child: Layout( + child: MaterialApp( + title: 's y r i u s', + debugShowCheckedModeBanner: false, + theme: AppTheme.lightTheme, + darkTheme: AppTheme.darkTheme, + themeMode: appThemeNotifier.currentThemeMode, + initialRoute: SplashScreen.route, + scrollBehavior: RemoveOverscrollEffect(), + routes: { + AccessWalletScreen.route: (context) => + const AccessWalletScreen(), + SplashScreen.route: (context) => + const SplashScreen(), + MainAppContainer.route: (context) => + const MainAppContainer(), + NodeManagementScreen.route: (_) => + const NodeManagementScreen(), + }, + onGenerateRoute: (settings) { + if (settings.name == SyriusErrorWidget.route) { + final args = settings.arguments + as CustomSyriusErrorWidgetArguments; + return MaterialPageRoute( + builder: (context) => + SyriusErrorWidget(args.errorText), + ); + } + return null; + }, ), ), ), @@ -303,16 +321,47 @@ class _MyAppState extends State with WindowListener { sl().wsClient.stop(); Future.delayed(const Duration(seconds: 60)).then((value) => exit(0)); await NodeUtils.closeEmbeddedNode(); + await sl.reset(); super.onWindowClose(); deactivate(); dispose(); exit(0); } + @override + void onTrayIconMouseDown() { + trayManager.popUpContextMenu(); + } + + @override + void onTrayIconRightMouseDown() {} + + @override + void onTrayIconRightMouseUp() {} + + @override + void onTrayMenuItemClick(MenuItem menuItem) async { + switch (menuItem.key) { + case 'show_wallet': + windowManager.show(); + break; + case 'hide_wallet': + if (!await windowManager.isMinimized()) { + windowManager.minimize(); + } + break; + case 'exit': + windowManager.destroy(); + break; + default: + break; + } + } + @override void dispose() { windowManager.removeListener(this); - sl.unregister(); + trayManager.removeListener(this); super.dispose(); } } diff --git a/lib/model/database/wallet_notification.dart b/lib/model/database/wallet_notification.dart index c7eb0906..5189d964 100644 --- a/lib/model/database/wallet_notification.dart +++ b/lib/model/database/wallet_notification.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:hive/hive.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; diff --git a/lib/model/model.dart b/lib/model/model.dart new file mode 100644 index 00000000..1e49dae3 --- /dev/null +++ b/lib/model/model.dart @@ -0,0 +1,8 @@ +export 'account_chain_stats.dart'; +export 'database/notification_type.dart'; +export 'database/wallet_notification.dart'; +export 'general_stats.dart'; +export 'navigation_arguments.dart'; +export 'new_token_data.dart'; +export 'pillars_qsr_info.dart'; +export 'plasma_info_wrapper.dart'; diff --git a/lib/screens/change_wallet_password_screen.dart b/lib/screens/change_wallet_password_screen.dart index e3a7ac39..929a6a01 100644 --- a/lib/screens/change_wallet_password_screen.dart +++ b/lib/screens/change_wallet_password_screen.dart @@ -1,18 +1,8 @@ import 'package:flutter/material.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/decrypt_key_store_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/file_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/keystore_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/onboarding_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dotted_border_info_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/password_input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/notification_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/progress_bars.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ChangeWalletPasswordScreen extends StatefulWidget { @@ -24,7 +14,7 @@ class ChangeWalletPasswordScreen extends StatefulWidget { }) : super(key: key); @override - _ChangeWalletPasswordScreenState createState() => + State createState() => _ChangeWalletPasswordScreenState(); } @@ -60,7 +50,7 @@ class _ChangeWalletPasswordScreenState ), Text( 'Change wallet password', - style: Theme.of(context).textTheme.headline1, + style: Theme.of(context).textTheme.headlineLarge, ), Column( children: [ @@ -160,11 +150,11 @@ class _ChangeWalletPasswordScreenState await KeyStoreUtils.createKeyStore( mnemonic, newPassword, - keyStoreName: (await kKeyStore!.getKeyPair(0).address).toString() + - '_' + - DateTime.now().millisecondsSinceEpoch.toString(), + keyStoreName: + '${await kKeyStore!.getKeyPair(0).address}_${DateTime.now().millisecondsSinceEpoch}', ); await FileUtils.deleteFile(oldKeyStorePath); + if (!mounted) return; Navigator.pop(context); } @@ -180,7 +170,7 @@ class _ChangeWalletPasswordScreenState Widget _getDecryptKeyStoreFileViewModel() { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen((keyStore) async { if (keyStore != null) { setState(() { diff --git a/lib/screens/dump_mnemonic_screen.dart b/lib/screens/dump_mnemonic_screen.dart index 96b49ebb..48c8f5f2 100644 --- a/lib/screens/dump_mnemonic_screen.dart +++ b/lib/screens/dump_mnemonic_screen.dart @@ -1,18 +1,13 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/keystore_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/onboarding_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/password_input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/seed/seed_grid.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class DumpMnemonicScreen extends StatefulWidget { const DumpMnemonicScreen({Key? key}) : super(key: key); @override - _DumpMnemonicScreenState createState() => _DumpMnemonicScreenState(); + State createState() => _DumpMnemonicScreenState(); } class _DumpMnemonicScreenState extends State { @@ -41,7 +36,7 @@ class _DumpMnemonicScreenState extends State { visible: _seedWords == null, child: Text( 'Enter the wallet password to dump the mnemonic', - style: Theme.of(context).textTheme.headline1, + style: Theme.of(context).textTheme.headlineLarge, ), ), Visibility( diff --git a/lib/screens/export/export.dart b/lib/screens/export/export.dart new file mode 100644 index 00000000..0445e076 --- /dev/null +++ b/lib/screens/export/export.dart @@ -0,0 +1,4 @@ +library export; + +export 'export_wallet_info_screen.dart'; +export 'export_wallet_password_screen.dart'; diff --git a/lib/screens/export/export_wallet_info_screen.dart b/lib/screens/export/export_wallet_info_screen.dart index bc22cbe4..2b4c3f99 100644 --- a/lib/screens/export/export_wallet_info_screen.dart +++ b/lib/screens/export/export_wallet_info_screen.dart @@ -1,12 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/export/export_wallet_password_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/onboarding_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/progress_bars.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class ExportWalletInfoScreen extends StatefulWidget { final String seed; @@ -19,7 +16,7 @@ class ExportWalletInfoScreen extends StatefulWidget { }) : super(key: key); @override - _ExportWalletInfoScreenState createState() => _ExportWalletInfoScreenState(); + State createState() => _ExportWalletInfoScreenState(); } class _ExportWalletInfoScreenState extends State { @@ -43,13 +40,14 @@ class _ExportWalletInfoScreenState extends State { color: Colors.transparent, child: SvgPicture.asset( 'assets/svg/ic_export_seed.svg', - color: AppColors.znnColor, + colorFilter: + const ColorFilter.mode(AppColors.znnColor, BlendMode.srcIn), height: 55.0, ), ), Text( 'Export Seed Vault', - style: Theme.of(context).textTheme.headline1, + style: Theme.of(context).textTheme.headlineLarge, ), _getSeedFieldsGrid(), _getSecureSeedInfo(), @@ -83,7 +81,7 @@ class _ExportWalletInfoScreenState extends State { ), child: Text( text, - style: Theme.of(context).textTheme.bodyText1!.copyWith( + style: Theme.of(context).textTheme.bodyLarge!.copyWith( color: Colors.white, ), textAlign: TextAlign.justify, @@ -103,7 +101,8 @@ class _ExportWalletInfoScreenState extends State { color: Colors.transparent, child: SvgPicture.asset( 'assets/svg/ic_seed.svg', - color: AppColors.qsrColor, + colorFilter: const ColorFilter.mode( + AppColors.qsrColor, BlendMode.srcIn), height: 50.0, ), ), @@ -112,7 +111,7 @@ class _ExportWalletInfoScreenState extends State { ), Text( 'Seed', - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ) ], ), @@ -128,7 +127,7 @@ class _ExportWalletInfoScreenState extends State { ), Text( 'Seed Vault Key', - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ) ], ), @@ -138,7 +137,8 @@ class _ExportWalletInfoScreenState extends State { color: Colors.transparent, child: SvgPicture.asset( 'assets/svg/ic_vault_seed.svg', - color: AppColors.znnColor, + colorFilter: const ColorFilter.mode( + AppColors.znnColor, BlendMode.srcIn), height: 50.0, ), ), @@ -147,7 +147,7 @@ class _ExportWalletInfoScreenState extends State { ), Text( 'Seed Vault', - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ) ], ), @@ -172,7 +172,7 @@ class _ExportWalletInfoScreenState extends State { ), Text( 'I will securely store the Seed Vault & Seed Vault Key', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ) ], ); diff --git a/lib/screens/export/export_wallet_password_screen.dart b/lib/screens/export/export_wallet_password_screen.dart index fe22ef6f..bd5936cd 100644 --- a/lib/screens/export/export_wallet_password_screen.dart +++ b/lib/screens/export/export_wallet_password_screen.dart @@ -1,24 +1,16 @@ import 'dart:io'; -import 'package:file_selector_platform_interface/file_selector_platform_interface.dart'; +import 'package:file_selector/file_selector.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:path/path.dart' as path; import 'package:path_provider/path_provider.dart'; import 'package:provider/provider.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/onboarding_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dotted_border_info_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/password_input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/progress_bars.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ExportWalletPasswordScreen extends StatefulWidget { @@ -32,7 +24,7 @@ class ExportWalletPasswordScreen extends StatefulWidget { }) : super(key: key); @override - _ExportWalletPasswordScreenState createState() => + State createState() => _ExportWalletPasswordScreenState(); } @@ -66,19 +58,20 @@ class _ExportWalletPasswordScreenState color: Colors.transparent, child: SvgPicture.asset( 'assets/svg/ic_export_seed.svg', - color: AppColors.znnColor, + colorFilter: const ColorFilter.mode( + AppColors.znnColor, BlendMode.srcIn), height: 55.0, ), ), kVerticalSpacing, Text( 'Export Seed Vault', - style: Theme.of(context).textTheme.headline1, + style: Theme.of(context).textTheme.headlineLarge, ), kVerticalSpacing, Text( 'Please enter a strong Seed Vault Key to encrypt your Seed', - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineMedium, ), const SizedBox( height: 50.0, @@ -151,9 +144,9 @@ class _ExportWalletPasswordScreenState initialDirectory = (await getApplicationDocumentsDirectory()).path; } - final _path = await FileSelectorPlatform.instance.getSavePath( + final walletPath = await getSavePath( acceptedTypeGroups: [ - XTypeGroup( + const XTypeGroup( label: 'file', extensions: ['json'], ), @@ -165,23 +158,24 @@ class _ExportWalletPasswordScreenState dateFormat: 'yyyy-MM-dd-HHmm', )}.json', ); - if (_path != null) { + if (walletPath != null) { KeyStoreManager keyStoreManager = KeyStoreManager( walletPath: Directory( - path.dirname(_path), + path.dirname(walletPath), ), ); KeyStore keyStore = KeyStore.fromMnemonic(widget.seed); await keyStoreManager.saveKeyStore( keyStore, _passwordController.text, - name: path.basename(_path), + name: path.basename(walletPath), ); if (widget.backupWalletFlow) { - _sendSuccessNotification(_path); + _sendSuccessNotification(walletPath); } else { _updateExportedSeedList(); } + if (!mounted) return; NavigationUtils.popRepeated(context, 2); } } @@ -203,12 +197,12 @@ class _ExportWalletPasswordScreenState ).value = exportedSeeds; } - void _sendSuccessNotification(String _path) { + void _sendSuccessNotification(String path) { sl.get().addNotification( WalletNotification( title: 'Seed Vault successfully exported', timestamp: DateTime.now().millisecondsSinceEpoch, - details: 'The Seed Vault was successfully exported to ' + _path, + details: 'The Seed Vault was successfully exported to $path', type: NotificationType.paymentSent, ), ); diff --git a/lib/screens/node_management_screen.dart b/lib/screens/node_management_screen.dart index d116590b..d9f04321 100644 --- a/lib/screens/node_management_screen.dart +++ b/lib/screens/node_management_screen.dart @@ -1,23 +1,15 @@ +import 'dart:io'; import 'dart:isolate'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import 'package:wakelock/wakelock.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/embedded_node/embedded_node.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/node_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/main_app_container.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/notification_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/settings_node.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class NodeManagementScreen extends StatefulWidget { final VoidCallback? nodeConfirmationCallback; @@ -30,7 +22,7 @@ class NodeManagementScreen extends StatefulWidget { }) : super(key: key); @override - _NodeManagementScreenState createState() => _NodeManagementScreenState(); + State createState() => _NodeManagementScreenState(); } class _NodeManagementScreenState extends State { @@ -42,10 +34,13 @@ class _NodeManagementScreenState extends State { TextEditingController _newNodeController = TextEditingController(); GlobalKey _newNodeKey = GlobalKey(); + late String _selectedNodeConfirmed; + @override void didChangeDependencies() { super.didChangeDependencies(); _selectedNode ??= kCurrentNode!; + _selectedNodeConfirmed = _selectedNode!; } @override @@ -62,13 +57,13 @@ class _NodeManagementScreenState extends State { const NotificationWidget(), Text( 'Node Management', - style: Theme.of(context).textTheme.headline1, + style: Theme.of(context).textTheme.headlineLarge, textAlign: TextAlign.center, ), kVerticalSpacing, Text( 'By default Syrius connects to its own built-in full node, which is called the Embedded Node. If you want to connect to a different node, you can add one below. Otherwise just connect and continue.', - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineMedium, textAlign: TextAlign.center, ), SizedBox( @@ -86,13 +81,13 @@ class _NodeManagementScreenState extends State { children: [ Text( 'Node selection', - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), _getNodeSelectionColumn(), kVerticalSpacing, Text( 'Add node', - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), kVerticalSpacing, _getAddNodeColumn(), @@ -134,7 +129,7 @@ class _NodeManagementScreenState extends State { Future _onConfirmNodeButtonPressed() async { // Acquire WakeLock - if (!await Wakelock.enabled) { + if (!Platform.isLinux && !await Wakelock.enabled) { Wakelock.enable(); } @@ -143,11 +138,11 @@ class _NodeManagementScreenState extends State { String url = _selectedNode == 'Embedded Node' ? kLocalhostDefaultNodeUrl : _selectedNode!; - bool _isConnectionEstablished = + bool isConnectionEstablished = await NodeUtils.establishConnectionToNode(url); if (_selectedNode == 'Embedded Node') { // Check if node is already running - if (!_isConnectionEstablished) { + if (!isConnectionEstablished) { // Initialize local full node await Isolate.spawn(EmbeddedNode.runNode, [''], onExit: sl(instanceName: 'embeddedStoppedPort') @@ -155,17 +150,17 @@ class _NodeManagementScreenState extends State { kEmbeddedNodeRunning = true; // The node needs a couple of seconds to actually start await Future.delayed(kEmbeddedConnectionDelay); - _isConnectionEstablished = + isConnectionEstablished = await NodeUtils.establishConnectionToNode(url); } } else { - _isConnectionEstablished = + isConnectionEstablished = await NodeUtils.establishConnectionToNode(url); - if (_isConnectionEstablished) { + if (isConnectionEstablished) { await NodeUtils.closeEmbeddedNode(); } } - if (_isConnectionEstablished) { + if (isConnectionEstablished) { await sharedPrefsService!.put( kSelectedNodeKey, _selectedNode, @@ -251,7 +246,7 @@ class _NodeManagementScreenState extends State { await Hive.openBox(kNodesBox); } Hive.box(kNodesBox).add(_newNodeController.text); - await NodeUtils.loadDbNodes(context); + await NodeUtils.loadDbNodes(); _sendAddNodeSuccessNotification(); setState(() { _newNodeController = TextEditingController(); @@ -295,6 +290,7 @@ class _NodeManagementScreenState extends State { onChangedOrDeletedNode: () { setState(() {}); }, + currentNode: _selectedNodeConfirmed, ), ), ], diff --git a/lib/screens/onboarding/access_wallet_screen.dart b/lib/screens/onboarding/access_wallet_screen.dart index c92a6ae9..35b2f6e4 100644 --- a/lib/screens/onboarding/access_wallet_screen.dart +++ b/lib/screens/onboarding/access_wallet_screen.dart @@ -1,10 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/onboarding/import_wallet/import_wallet_seed_choice_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/onboarding/new_wallet/new_wallet_seed_choice_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/access_wallet_fluid_cell.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class AccessWalletScreen extends StatefulWidget { static const String route = 'access-wallet-screen'; @@ -12,7 +9,7 @@ class AccessWalletScreen extends StatefulWidget { const AccessWalletScreen({Key? key}) : super(key: key); @override - _AccessWalletScreenState createState() => _AccessWalletScreenState(); + State createState() => _AccessWalletScreenState(); } class _AccessWalletScreenState extends State { @@ -27,12 +24,12 @@ class _AccessWalletScreenState extends State { children: [ Text( 'Welcome', - style: Theme.of(context).textTheme.headline1, + style: Theme.of(context).textTheme.headlineLarge, ), kVerticalSpacing, Text( 'Select an option to access your wallet', - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineMedium, ), const SizedBox( height: 50.0, diff --git a/lib/screens/onboarding/create_key_store_screen.dart b/lib/screens/onboarding/create_key_store_screen.dart index 235d906a..778a2971 100644 --- a/lib/screens/onboarding/create_key_store_screen.dart +++ b/lib/screens/onboarding/create_key_store_screen.dart @@ -1,11 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/key_store_path_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/node_management_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/onboarding/wallet_success_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/progress_bars.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class CreateKeyStoreScreen extends StatefulWidget { final String seed; @@ -31,7 +28,6 @@ class _CreateKeyStoreScreenState extends State { super.initState(); _keyStorePathBloc = KeyStorePathBloc() ..getKeyStorePath( - context, widget.seed, widget.password, ); diff --git a/lib/screens/onboarding/import_wallet/import_wallet.dart b/lib/screens/onboarding/import_wallet/import_wallet.dart new file mode 100644 index 00000000..8783568f --- /dev/null +++ b/lib/screens/onboarding/import_wallet/import_wallet.dart @@ -0,0 +1,5 @@ +library import_wallet; + +export 'import_wallet_decrypt_screen.dart'; +export 'import_wallet_password_screen.dart'; +export 'import_wallet_seed_choice_screen.dart'; diff --git a/lib/screens/onboarding/import_wallet/import_wallet_decrypt_screen.dart b/lib/screens/onboarding/import_wallet/import_wallet_decrypt_screen.dart index 0393bceb..65db377a 100644 --- a/lib/screens/onboarding/import_wallet/import_wallet_decrypt_screen.dart +++ b/lib/screens/onboarding/import_wallet/import_wallet_decrypt_screen.dart @@ -1,13 +1,9 @@ import 'package:flutter/material.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/decrypt_key_store_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/onboarding/import_wallet/import_wallet_password_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/onboarding_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/password_input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/progress_bars.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ImportWalletDecryptScreen extends StatefulWidget { @@ -16,7 +12,7 @@ class ImportWalletDecryptScreen extends StatefulWidget { const ImportWalletDecryptScreen(this.path, {Key? key}) : super(key: key); @override - _ImportWalletDecryptScreenState createState() => + State createState() => _ImportWalletDecryptScreenState(); } @@ -49,12 +45,12 @@ class _ImportWalletDecryptScreenState extends State { ), Text( 'Unlock your Seed Vault', - style: Theme.of(context).textTheme.headline1, + style: Theme.of(context).textTheme.headlineLarge, ), kVerticalSpacing, Text( 'Input the Seed Vault Key to continue', - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineMedium, ), ], ), @@ -112,7 +108,7 @@ class _ImportWalletDecryptScreenState extends State { _getDecryptKeyStoreFileViewModel() { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen((keyStore) { if (keyStore != null) { _loadingButtonKey.currentState!.animateReverse(); diff --git a/lib/screens/onboarding/import_wallet/import_wallet_password_screen.dart b/lib/screens/onboarding/import_wallet/import_wallet_password_screen.dart index 3f0879d4..f46b2215 100644 --- a/lib/screens/onboarding/import_wallet/import_wallet_password_screen.dart +++ b/lib/screens/onboarding/import_wallet/import_wallet_password_screen.dart @@ -1,12 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/onboarding/create_key_store_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/onboarding_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dotted_border_info_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/password_input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/progress_bars.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class ImportWalletPasswordScreen extends StatefulWidget { final String seed; @@ -19,7 +14,7 @@ class ImportWalletPasswordScreen extends StatefulWidget { }) : super(key: key); @override - _ImportWalletPasswordScreenState createState() => + State createState() => _ImportWalletPasswordScreenState(); } @@ -53,12 +48,12 @@ class _ImportWalletPasswordScreenState ), Text( 'Create a wallet password', - style: Theme.of(context).textTheme.headline1, + style: Theme.of(context).textTheme.headlineLarge, ), kVerticalSpacing, Text( 'This is the password that will be required to unlock the wallet', - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineMedium, ), const SizedBox( height: 100.0, diff --git a/lib/screens/onboarding/import_wallet/import_wallet_seed_choice_screen.dart b/lib/screens/onboarding/import_wallet/import_wallet_seed_choice_screen.dart index 64fc4524..e4c0037e 100644 --- a/lib/screens/onboarding/import_wallet/import_wallet_seed_choice_screen.dart +++ b/lib/screens/onboarding/import_wallet/import_wallet_seed_choice_screen.dart @@ -1,22 +1,15 @@ import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/onboarding/access_wallet_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/onboarding/import_wallet/import_wallet_decrypt_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/onboarding/import_wallet/import_wallet_password_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/onboarding_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/progress_bars.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/seed/seed_choice.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/seed/seed_grid.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/select_file_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ImportWalletSeedChoiceScreen extends StatefulWidget { const ImportWalletSeedChoiceScreen({Key? key}) : super(key: key); @override - _ImportWalletSeedChoiceScreenState createState() => + State createState() => _ImportWalletSeedChoiceScreenState(); } @@ -56,12 +49,12 @@ class _ImportWalletSeedChoiceScreenState ), Text( 'Import your wallet', - style: Theme.of(context).textTheme.headline1, + style: Theme.of(context).textTheme.headlineLarge, ), kVerticalSpacing, Text( 'Input your seed or import the Seed Vault', - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineMedium, ), kVerticalSpacing, SizedBox( diff --git a/lib/screens/onboarding/new_wallet/new_wallet.dart b/lib/screens/onboarding/new_wallet/new_wallet.dart new file mode 100644 index 00000000..98471eae --- /dev/null +++ b/lib/screens/onboarding/new_wallet/new_wallet.dart @@ -0,0 +1,5 @@ +library new_wallet; + +export 'new_wallet_confirm_seed_screen.dart'; +export 'new_wallet_password_screen.dart'; +export 'new_wallet_seed_choice_screen.dart'; diff --git a/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart b/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart index eb3ae62e..5599c8bf 100644 --- a/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart +++ b/lib/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart @@ -1,15 +1,9 @@ import 'dart:math'; import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/onboarding/new_wallet/new_wallet_password_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/onboarding_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/standard_tooltip_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/progress_bars.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/seed/seed_grid.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class NewWalletConfirmSeedScreen extends StatefulWidget { final List seedWords; @@ -20,7 +14,7 @@ class NewWalletConfirmSeedScreen extends StatefulWidget { }) : super(key: key); @override - _NewWalletConfirmSeedScreenState createState() => + State createState() => _NewWalletConfirmSeedScreenState(); } @@ -76,7 +70,7 @@ class _NewWalletConfirmSeedScreenState ), Text( 'Confirm your seed', - style: Theme.of(context).textTheme.headline1, + style: Theme.of(context).textTheme.headlineLarge, ), kVerticalSpacing, Row( @@ -84,10 +78,11 @@ class _NewWalletConfirmSeedScreenState children: [ Text( 'Drag & drop the words in the correct order', - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineMedium, ), const StandardTooltipIcon( 'You can drag & drop words on empty boxes or incorrect words', + Icons.help, ), ], ), @@ -160,11 +155,11 @@ class _NewWalletConfirmSeedScreenState Widget _seedFieldWidget(SeedGridElement seedGridElement) { int seedGridElementIndex = _seedGridElements.indexOf(seedGridElement); - final TextEditingController _controller = TextEditingController(); - _controller.text = seedGridElement.word; + final TextEditingController controller = TextEditingController(); + controller.text = seedGridElement.word; if (_textCursor == seedGridElementIndex) { - _controller.selection = TextSelection.collapsed( - offset: _controller.text.length, + controller.selection = TextSelection.collapsed( + offset: controller.text.length, ); } @@ -208,7 +203,7 @@ class _NewWalletConfirmSeedScreenState child: Center( child: Text( '${seedGridElementIndex + 1}', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), ), ), @@ -234,7 +229,7 @@ class _NewWalletConfirmSeedScreenState builder: (BuildContext context, accepted, rejected) { return TextField( enabled: false, - controller: _controller, + controller: controller, obscureText: _randomIndexes.contains(seedGridElementIndex) ? false : !seedGridElement.isShown || @@ -291,31 +286,9 @@ class _NewWalletConfirmSeedScreenState if (!_foundMissingRandomElementsIndexes.contains(index)) { list.add( Draggable( - child: ElevatedButton( - style: ElevatedButton.styleFrom( - primary: _draggedValue == seedWords[index] - ? Theme.of(context) - .colorScheme - .secondaryContainer - .withOpacity(0.5) - : Theme.of(context).colorScheme.secondaryContainer, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5.0), - ), - ), - onPressed: () {}, - child: Text( - seedWords[index], - style: Theme.of(context).textTheme.bodyText1!.copyWith( - color: _draggedValue == seedWords[index] - ? Colors.white.withOpacity(0.7) - : Colors.white, - ), - ), - ), feedback: ElevatedButton( style: ElevatedButton.styleFrom( - primary: AppColors.darkSecondary, + foregroundColor: AppColors.darkSecondary, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(5.0), ), @@ -323,7 +296,7 @@ class _NewWalletConfirmSeedScreenState onPressed: () {}, child: Text( seedWords[index], - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), ), data: seedWords[index], @@ -337,16 +310,38 @@ class _NewWalletConfirmSeedScreenState _draggedValue = null; }); }, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + foregroundColor: _draggedValue == seedWords[index] + ? Theme.of(context) + .colorScheme + .secondaryContainer + .withOpacity(0.5) + : Theme.of(context).colorScheme.secondaryContainer, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5.0), + ), + ), + onPressed: () {}, + child: Text( + seedWords[index], + style: Theme.of(context).textTheme.bodyLarge!.copyWith( + color: _draggedValue == seedWords[index] + ? Colors.white.withOpacity(0.7) + : Colors.white, + ), + ), + ), ), ); } } return Wrap( - children: list, crossAxisAlignment: WrapCrossAlignment.start, alignment: WrapAlignment.start, direction: Axis.horizontal, spacing: 5.0, + children: list, ); } diff --git a/lib/screens/onboarding/new_wallet/new_wallet_password_screen.dart b/lib/screens/onboarding/new_wallet/new_wallet_password_screen.dart index 435cf197..c42f7e28 100644 --- a/lib/screens/onboarding/new_wallet/new_wallet_password_screen.dart +++ b/lib/screens/onboarding/new_wallet/new_wallet_password_screen.dart @@ -1,12 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/onboarding/create_key_store_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/onboarding_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dotted_border_info_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/password_input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/progress_bars.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class NewWalletPasswordScreen extends StatefulWidget { final List seedWords; @@ -14,7 +9,7 @@ class NewWalletPasswordScreen extends StatefulWidget { const NewWalletPasswordScreen(this.seedWords, {Key? key}) : super(key: key); @override - _NewWalletPasswordScreenState createState() => + State createState() => _NewWalletPasswordScreenState(); } @@ -45,11 +40,11 @@ class _NewWalletPasswordScreenState extends State { height: 30.0, ), Text('Create a wallet password', - style: Theme.of(context).textTheme.headline1), + style: Theme.of(context).textTheme.headlineLarge), kVerticalSpacing, Text( 'This is the password that will be required to unlock the wallet', - style: Theme.of(context).textTheme.headline4), + style: Theme.of(context).textTheme.headlineMedium), const SizedBox( height: 65.0, ), diff --git a/lib/screens/onboarding/new_wallet/new_wallet_seed_choice_screen.dart b/lib/screens/onboarding/new_wallet/new_wallet_seed_choice_screen.dart index 42e81b8c..6577847f 100644 --- a/lib/screens/onboarding/new_wallet/new_wallet_seed_choice_screen.dart +++ b/lib/screens/onboarding/new_wallet/new_wallet_seed_choice_screen.dart @@ -2,16 +2,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:hive/hive.dart'; import 'package:provider/provider.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/export/export_wallet_info_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/onboarding/access_wallet_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/onboarding/new_wallet/new_wallet_confirm_seed_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/onboarding_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/progress_bars.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/seed/seed_choice.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/seed/seed_grid.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class NewWalletSeedChoiceScreen extends StatefulWidget { @@ -20,7 +13,7 @@ class NewWalletSeedChoiceScreen extends StatefulWidget { const NewWalletSeedChoiceScreen({Key? key, this.export}) : super(key: key); @override - _NewWalletSeedChoiceScreenState createState() => + State createState() => _NewWalletSeedChoiceScreenState(); } @@ -63,12 +56,12 @@ class _NewWalletSeedChoiceScreenState extends State { _isSeed12Selected ? 'This is your 12 words seed' : 'This is your 24 words seed', - style: Theme.of(context).textTheme.headline1, + style: Theme.of(context).textTheme.headlineLarge, ), kVerticalSpacing, Text( 'Please carefully write down your seed and export it to a safe location', - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineMedium, ), kVerticalSpacing, SizedBox( @@ -172,7 +165,9 @@ class _NewWalletSeedChoiceScreenState extends State { color: Colors.transparent, child: SvgPicture.asset( 'assets/svg/ic_export_seed.svg', - color: Theme.of(context).textTheme.headline6!.color, + colorFilter: ColorFilter.mode( + Theme.of(context).textTheme.headlineSmall!.color!, + BlendMode.srcIn), height: 18.0, ), ), @@ -181,7 +176,7 @@ class _NewWalletSeedChoiceScreenState extends State { ), Text( 'Export Seed', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), ], ), @@ -225,7 +220,7 @@ class _NewWalletSeedChoiceScreenState extends State { ), Text( 'I have backed up my seed in a safe location', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ) ], ); @@ -289,7 +284,7 @@ class _NewWalletSeedChoiceScreenState extends State { ), Text( 'I have written down my seed', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), ], ); diff --git a/lib/screens/onboarding/onboarding.dart b/lib/screens/onboarding/onboarding.dart new file mode 100644 index 00000000..cf3484e6 --- /dev/null +++ b/lib/screens/onboarding/onboarding.dart @@ -0,0 +1,7 @@ +library onboarding; + +export 'access_wallet_screen.dart'; +export 'create_key_store_screen.dart'; +export 'wallet_success_screen.dart'; +export 'import_wallet/import_wallet.dart'; +export 'new_wallet/new_wallet.dart'; diff --git a/lib/screens/onboarding/wallet_success_screen.dart b/lib/screens/onboarding/wallet_success_screen.dart index 3aa3d940..9f4a274c 100644 --- a/lib/screens/onboarding/wallet_success_screen.dart +++ b/lib/screens/onboarding/wallet_success_screen.dart @@ -1,12 +1,8 @@ import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/onboarding/access_wallet_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/swap/swap_info_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/main_app_container.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/onboarding_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/progress_bars.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class WalletSuccessScreen extends StatefulWidget { final int progressBarNumLevels; @@ -17,7 +13,7 @@ class WalletSuccessScreen extends StatefulWidget { }) : super(key: key); @override - _WalletSuccessScreenState createState() => _WalletSuccessScreenState(); + State createState() => _WalletSuccessScreenState(); } class _WalletSuccessScreenState extends State { @@ -47,12 +43,12 @@ class _WalletSuccessScreenState extends State { ), Text( 'You\'re all set', - style: Theme.of(context).textTheme.headline1, + style: Theme.of(context).textTheme.headlineLarge, ), kVerticalSpacing, Text( 'The wallet has been successfully created', - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineMedium, ), ], ), @@ -64,13 +60,7 @@ class _WalletSuccessScreenState extends State { ), ), ), - Column( - children: [ - _getAccessWalletActionButton(), - kVerticalSpacing, - _getSwapWalletButton(), - ], - ), + _getAccessWalletActionButton(), ], ); } @@ -92,16 +82,4 @@ class _WalletSuccessScreenState extends State { text: 'Access wallet', ); } - - Widget _getSwapWalletButton() { - return OnboardingButton( - onPressed: () { - NavigationUtils.push( - context, - const SwapInfoScreen(), - ); - }, - text: 'Swap wallet', - ); - } } diff --git a/lib/screens/project_details_screen.dart b/lib/screens/project_details_screen.dart index c640fc33..700a9dc8 100644 --- a/lib/screens/project_details_screen.dart +++ b/lib/screens/project_details_screen.dart @@ -1,14 +1,9 @@ import 'package:flutter/material.dart'; import 'package:layout/layout.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/accelerator/refresh_project_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/accelerator_widgets/create_phase.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/accelerator_widgets/phase_list.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/accelerator_widgets/projects_stats.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ProjectDetailsScreen extends StatefulWidget { @@ -24,7 +19,7 @@ class ProjectDetailsScreen extends StatefulWidget { }) : super(key: key); @override - _ProjectDetailsScreenState createState() => _ProjectDetailsScreenState(); + State createState() => _ProjectDetailsScreenState(); } class _ProjectDetailsScreenState extends State { @@ -117,7 +112,7 @@ class _ProjectDetailsScreenState extends State { Widget _getStreamBuilder() { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.refreshProject(widget.project.id); }, builder: (_, model, __) => StreamBuilder( diff --git a/lib/screens/reset_wallet_screen.dart b/lib/screens/reset_wallet_screen.dart index e1c8bbd1..3604612b 100644 --- a/lib/screens/reset_wallet_screen.dart +++ b/lib/screens/reset_wallet_screen.dart @@ -1,18 +1,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/splash_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/node_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/outlined_button.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class ResetWalletScreen extends StatefulWidget { const ResetWalletScreen({Key? key}) : super(key: key); @override - _ResetWalletScreenState createState() => _ResetWalletScreenState(); + State createState() => _ResetWalletScreenState(); } class _ResetWalletScreenState extends State { @@ -48,7 +44,7 @@ class _ResetWalletScreenState extends State { kVerticalSpacing, Text( 'Reset wallet', - style: Theme.of(context).textTheme.headline1, + style: Theme.of(context).textTheme.headlineLarge, ), kVerticalSpacing, SizedBox( @@ -58,7 +54,7 @@ class _ResetWalletScreenState extends State { 'you have a backup of your mnemonic or Seed Vault & Seed Vault Key before you proceed ' 'with erasing the wallet', textAlign: TextAlign.center, - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineMedium, ), ), ], diff --git a/lib/screens/screens.dart b/lib/screens/screens.dart new file mode 100644 index 00000000..f0687cce --- /dev/null +++ b/lib/screens/screens.dart @@ -0,0 +1,11 @@ +library screens; + +export 'change_wallet_password_screen.dart'; +export 'dump_mnemonic_screen.dart'; +export 'node_management_screen.dart'; +export 'project_details_screen.dart'; +export 'reset_wallet_screen.dart'; +export 'splash_screen.dart'; +export 'stepper_screen.dart'; +export 'export/export.dart'; +export 'onboarding/onboarding.dart'; diff --git a/lib/screens/splash_screen.dart b/lib/screens/splash_screen.dart index d2992960..142653c1 100644 --- a/lib/screens/splash_screen.dart +++ b/lib/screens/splash_screen.dart @@ -4,17 +4,12 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import 'package:lottie/lottie.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/navigation_arguments.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/node_management_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/onboarding/access_wallet_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/file_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/main_app_container.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class SplashScreen extends StatefulWidget { static const String route = 'splash-screen'; @@ -29,7 +24,7 @@ class SplashScreen extends StatefulWidget { }) : super(key: key); @override - _SplashScreenState createState() => _SplashScreenState(); + State createState() => _SplashScreenState(); } class _SplashScreenState extends State @@ -64,7 +59,7 @@ class _SplashScreenState extends State ? await _resetWallet() : widget.deleteCacheFlow ? await _deleteCache().then((value) => exit(0)) - : await Utils.initApp(context); + : await InitUtils.initApp(context); _navigateToNextScreen(); } on Exception catch (e) { Navigator.pushReplacementNamed( @@ -106,7 +101,8 @@ class _SplashScreenState extends State await sl.get().addNotification(null); await _deleteKeyStoreFile(); await Hive.deleteFromDisk(); - await Utils.initApp(context); + if (!mounted) return; + await InitUtils.initApp(context); } Future _deleteCache() async => Future.forEach( diff --git a/lib/screens/stepper_screen.dart b/lib/screens/stepper_screen.dart index 6643d0a2..1b3b46c2 100644 --- a/lib/screens/stepper_screen.dart +++ b/lib/screens/stepper_screen.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/notification_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class StepperScreen extends StatelessWidget { final VoidCallback onStepperNotificationSeeMorePressed; diff --git a/lib/screens/swap/swap_import_screen.dart b/lib/screens/swap/swap_import_screen.dart deleted file mode 100644 index b5e13451..00000000 --- a/lib/screens/swap/swap_import_screen.dart +++ /dev/null @@ -1,93 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/swap/swap_password_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/onboarding_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/progress_bars.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/select_file_widget.dart'; - -class SwapImportScreen extends StatefulWidget { - const SwapImportScreen({Key? key}) : super(key: key); - - @override - _SwapImportScreenState createState() => _SwapImportScreenState(); -} - -class _SwapImportScreenState extends State { - String? _path; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Container( - padding: const EdgeInsets.symmetric( - vertical: 30.0, - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - const ProgressBar( - currentLevel: 2, - numLevels: 4, - ), - Text( - 'Swap wallet', - style: Theme.of(context).textTheme.headline1, - ), - Text( - 'Click browse to select your legacy \'wallet.dat\' file', - style: Theme.of(context).textTheme.headline4, - ), - _getUploadWalletFileContainer(), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - _getPassiveButton(), - kSpacingBetweenActionButtons, - _getActionButton() - ], - ), - ], - ), - ), - ); - } - - Widget _getUploadWalletFileContainer() { - return Container( - margin: const EdgeInsets.symmetric( - horizontal: 20.0, - ), - child: SelectFileWidget( - fileExtension: 'dat', - onPathFoundCallback: (String path) { - setState(() { - _path = path; - }); - }), - ); - } - - Widget _getActionButton() { - return OnboardingButton( - onPressed: _path != null - ? () { - NavigationUtils.push( - context, - SwapPasswordScreen(_path!), - ); - } - : null, - text: 'Continue', - ); - } - - Widget _getPassiveButton() { - return OnboardingButton( - onPressed: () { - Navigator.pop(context); - }, - text: 'Go back', - ); - } -} diff --git a/lib/screens/swap/swap_info_screen.dart b/lib/screens/swap/swap_info_screen.dart deleted file mode 100644 index ce174478..00000000 --- a/lib/screens/swap/swap_info_screen.dart +++ /dev/null @@ -1,82 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_svg/svg.dart'; -import 'package:flutter_vector_icons/flutter_vector_icons.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/swap/swap_import_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/elevated_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/onboarding_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/progress_bars.dart'; - -class SwapInfoScreen extends StatelessWidget { - const SwapInfoScreen({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Container( - padding: const EdgeInsets.symmetric( - vertical: 30.0, - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - const ProgressBar( - currentLevel: 1, - numLevels: 4, - ), - Text( - 'Swap wallet', - style: Theme.of(context).textTheme.headline1, - ), - SizedBox( - width: 500.0, - child: Text( - 'This procedure will swap your funds from the legacy network ' - 'to Alphanet - Network of Momentum Phase 0. Please make sure you ' - 'have wallet backups before proceeding', - style: Theme.of(context).textTheme.headline4, - textAlign: TextAlign.center, - ), - ), - const Icon( - MaterialCommunityIcons.swap_horizontal, - color: AppColors.znnColor, - size: 200.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - OnboardingButton( - text: 'Go back', - onPressed: () { - Navigator.pop(context); - }, - ), - const SizedBox( - width: 70.0, - ), - SizedBox( - width: 360.0, - child: SyriusElevatedButton( - onPressed: () { - NavigationUtils.push( - context, - const SwapImportScreen(), - ); - }, - text: 'Start Swap', - initialFillColor: AppColors.znnColor, - icon: SvgPicture.asset( - 'assets/svg/ic_swap_icon.svg', - ), - ), - ), - ], - ), - ], - ), - ), - ); - } -} diff --git a/lib/screens/swap/swap_password_screen.dart b/lib/screens/swap/swap_password_screen.dart deleted file mode 100644 index 3a9a0d6f..00000000 --- a/lib/screens/swap/swap_password_screen.dart +++ /dev/null @@ -1,166 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/swap/get_assets_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/swap/read_wallet_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/swap/swap_transfer_balance_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/onboarding_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/password_input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/progress_bars.dart'; - -class SwapPasswordScreen extends StatefulWidget { - final String path; - - const SwapPasswordScreen(this.path, {Key? key}) : super(key: key); - - @override - _SwapPasswordScreenState createState() => _SwapPasswordScreenState(); -} - -class _SwapPasswordScreenState extends State { - final TextEditingController _passwordController = TextEditingController(); - - final GlobalKey _loadingButtonKey = GlobalKey(); - - String? _errorText; - - late LoadingButton _loadingButton; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Container( - margin: const EdgeInsets.symmetric( - vertical: 30.0, - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - const ProgressBar( - currentLevel: 3, - numLevels: 4, - ), - Text( - 'Swap wallet', - style: Theme.of(context).textTheme.headline1, - ), - Text( - 'Please input the password for the \'.dat\' wallet file in ' - 'order to continue', - style: Theme.of(context).textTheme.headline4, - ), - Material( - color: Colors.transparent, - child: PasswordInputField( - onSubmitted: (value) { - if (_passwordController.text.isNotEmpty) { - _loadingButton.onPressed!(); - } else { - setState(() { - _errorText = 'Please insert a password'; - }); - } - }, - errorText: _errorText, - controller: _passwordController, - onChanged: (value) { - setState(() {}); - }, - hintText: 'Wallet password', - ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - getPassiveButton(), - const SizedBox( - width: 70.0, - ), - _getReadWalletViewModel(), - ], - ), - ], - ), - ), - ); - } - - Widget getPassiveButton() { - return OnboardingButton( - onPressed: () { - Navigator.pop(context); - }, - text: 'Go back', - ); - } - - LoadingButton _getLoadingButton(ReadWalletBloc readWalletViewModel) { - return LoadingButton.onboarding( - key: _loadingButtonKey, - onPressed: _passwordController.text.isNotEmpty - ? () { - _loadingButtonKey.currentState!.animateForward(); - readWalletViewModel.readWallet( - widget.path, _passwordController.text); - } - : null, - text: 'Decrypt', - ); - } - - Widget _getReadWalletViewModel() { - return ViewModelBuilder.reactive( - onModelReady: (model) { - model.stream.listen( - (swapFileEntries) async { - if (swapFileEntries != null) { - var assetsModel = GetAssetsBloc(); - assetsModel.stream.listen( - (swapAssetsAndEntries) async { - if (swapAssetsAndEntries != null) { - _loadingButtonKey.currentState!.animateReverse(); - setState(() { - _errorText = null; - }); - NavigationUtils.push( - context, - SwapTransferBalanceScreen( - swapAssetsAndEntries, - _passwordController.text, - ), - ); - } - }, - onError: (error) { - _loadingButtonKey.currentState!.animateReverse(); - setState(() { - _errorText = error.toString(); - }); - }, - ); - await assetsModel.getAssetAndSwapFileEntries(swapFileEntries); - } - }, - onError: (error) { - _loadingButtonKey.currentState!.animateReverse(); - setState(() { - _errorText = error.toString(); - }); - }, - ); - }, - builder: (_, model, __) { - _loadingButton = _getLoadingButton(model); - return _loadingButton; - }, - viewModelBuilder: () => ReadWalletBloc(), - ); - } - - @override - void dispose() { - _passwordController.dispose(); - super.dispose(); - } -} diff --git a/lib/screens/swap/swap_transfer_balance_screen.dart b/lib/screens/swap/swap_transfer_balance_screen.dart deleted file mode 100644 index 382577b7..00000000 --- a/lib/screens/swap/swap_transfer_balance_screen.dart +++ /dev/null @@ -1,640 +0,0 @@ -import 'dart:io'; - -import 'package:flutter/material.dart'; -import 'package:flutter_vector_icons/flutter_vector_icons.dart'; -import 'package:path/path.dart' as path; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/swap/transfer_balance_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_theme.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/file_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/pair.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/main_app_container.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/onboarding_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dropdown/addresses_dropdown.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/progress_bars.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; -import 'package:znn_swap_utility/znn_swap_utility.dart'; - -class SwapTransferBalanceScreen extends StatefulWidget { - final Pair, List> _swapAssetsAndEntries; - final String _passphrase; - - const SwapTransferBalanceScreen( - this._swapAssetsAndEntries, - this._passphrase, { - Key? key, - }) : super(key: key); - - @override - _SwapTransferBalanceScreenState createState() => - _SwapTransferBalanceScreenState(); -} - -class _SwapTransferBalanceScreenState extends State { - final List _currentAddressControllers = []; - final List _newAddressControllers = []; - final List _currentAddressNode = []; - final List _newAddressNode = []; - final List _swappedFileEntries = []; - - List? _newKeyPairs; - List? _assetsAfterSwap; - TransferBalanceBloc? _currentlyActiveModel; - - late List _assetsBeforeSwap; - late List _transferBalanceBlocs = []; - late List _selectedNewAddresses; - late List _newAddressErrorTexts; - - bool? _shouldPerformCleanup; - - @override - void initState() { - super.initState(); - _assetsBeforeSwap = widget._swapAssetsAndEntries.first; - if (_transferBalanceBlocs.isEmpty) { - _transferBalanceBlocs = List.generate( - widget._swapAssetsAndEntries.first.length, - (index) => TransferBalanceBloc(), - ); - } - _initNewAddresses(); - _initNewAddressErrorTexts(); - _initSelectedNewAddresses(); - _shouldPerformCleanup = - Directory(zenonDefaultLegacyDirectoryPath).existsSync(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Container( - margin: const EdgeInsets.symmetric( - vertical: 30.0, - ), - child: Column( - children: [ - const ProgressBar( - currentLevel: 4, - numLevels: 4, - ), - const SizedBox( - height: 30.0, - ), - Text( - 'Swap Wallet', - style: Theme.of(context).textTheme.headline1, - ), - const SizedBox( - height: 30.0, - ), - Expanded( - child: _swapListWidget( - widget._swapAssetsAndEntries.second - .map( - (e) => e.address, - ) - .toList(), - ), - ), - kVerticalSpacing, - Visibility( - visible: Directory(zenonDefaultLegacyDirectoryPath).existsSync(), - child: _getPerformCleanupCheckBox(), - ), - kVerticalSpacing, - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - _getGoBackButton(), - const SizedBox( - width: 70.0, - ), - _getGoBackToSettingsButton(), - ], - ), - ], - ), - ), - ); - } - - Widget _getGoBackButton() { - return OnboardingButton( - text: 'Go back', - onPressed: _currentlyActiveModel == null - ? () { - Navigator.pop(context); - } - : null, - ); - } - - Widget _swapListWidget(List oldAddresses) { - return Container( - margin: const EdgeInsets.symmetric( - horizontal: 200.0, - ), - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.secondaryContainer, - borderRadius: const BorderRadius.all( - Radius.circular( - 20.0, - ), - ), - ), - child: Column( - children: [ - const SizedBox( - height: 30.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Text( - 'Legacy addresses', - style: Theme.of(context).textTheme.bodyText1, - ), - Text( - 'Alphanet addresses', - style: Theme.of(context).textTheme.bodyText1, - ), - ], - ), - Expanded( - child: Container( - margin: const EdgeInsets.only(top: 20.0), - child: Form( - child: ListView.builder( - shrinkWrap: true, - itemCount: oldAddresses.length, - itemBuilder: (context, index) { - _addInitialization(); - return _swapCellWidget( - index, - ); - }, - ), - ), - ), - ) - ], - ), - ); - } - - void _addInitialization() { - _currentAddressControllers.add(TextEditingController()); - _newAddressControllers.add(TextEditingController()); - _currentAddressNode.add(FocusNode()); - _newAddressNode.add(FocusNode()); - } - - Widget _swapCellWidget(int entryIndex) { - String oldAddress = widget._swapAssetsAndEntries.second[entryIndex].address; - - bool isCellEnabled = !_swappedFileEntries - .contains(widget._swapAssetsAndEntries.second[entryIndex]) && - (_assetsBeforeSwap[entryIndex].qsr > 0 || - _assetsBeforeSwap[entryIndex].znn > 0); - - return Container( - margin: const EdgeInsets.only(bottom: 10.0), - child: Column( - children: [ - Row( - children: [ - Expanded( - flex: 1, - child: _getNumber(entryIndex + 1), - ), - Expanded( - flex: 4, - child: Row( - children: [ - _oldAddressInputField( - entryIndex, - oldAddress, - isCellEnabled, - ), - ], - ), - ), - Expanded( - flex: 4, - child: Row( - children: [ - _getNewAddressDropdown(entryIndex, isCellEnabled), - _getNewAddressBalanceInfo(entryIndex), - ], - ), - ), - Expanded( - flex: 1, - child: _getTransferBalanceWidget( - _transferBalanceBlocs[entryIndex], - entryIndex, - ), - ), - ], - ), - const SizedBox( - height: 10.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: Container(), - ), - Expanded( - flex: 4, - child: isCellEnabled - ? _getOldAddressBalance(entryIndex) - : const Text('Swapped'), - ), - Expanded( - flex: 4, - child: _newAddressErrorTexts[entryIndex] != null - ? Text( - _newAddressErrorTexts[entryIndex] ?? '', - style: kTextFormFieldErrorStyle, - ) - : _getNewAddressBalanceInfo(entryIndex), - ), - Expanded( - flex: 1, - child: Container(), - ), - ], - ), - ], - ), - ); - } - - Expanded _getNewAddressDropdown(index, bool isEnabled) { - return Expanded( - child: Row( - children: [ - Expanded( - child: AddressesDropdown( - _selectedNewAddresses[index], - isEnabled - ? (newAddress) { - setState(() { - _selectedNewAddresses[index] = newAddress!; - }); - } - : null, - ), - ), - CopyToClipboardIcon( - _selectedNewAddresses[index], - ), - ], - ), - ); - } - - Widget _getNumber(number) { - return Container( - height: 35.0, - width: 35.0, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Theme.of(context).colorScheme.secondary, - ), - alignment: Alignment.center, - child: Text( - number.toString(), - style: Theme.of(context).textTheme.headline6, - ), - ); - } - - Widget _oldAddressInputField(index, String oldAddress, bool isCellEnabled) { - TextEditingController controller = TextEditingController(text: oldAddress); - - return Expanded( - child: Row( - children: [ - Expanded( - child: InputField( - enabled: false, - hintText: 'Pillar reward address', - controller: controller, - thisNode: _currentAddressNode[index], - nextNode: _newAddressNode[index], - validator: (value) => InputValidators.notEmpty( - 'Pillar reward address', - value, - ), - inputtedTextStyle: - Theme.of(context).textTheme.bodyText1!.copyWith( - color: isCellEnabled - ? AppColors.znnColor - : AppColors.lightSecondary, - ), - ), - ), - CopyToClipboardIcon(oldAddress), - ], - ), - ); - } - - Widget _getOldAddressBalance(index) { - return _assetsAfterSwap == null - ? Text( - '${_assetsBeforeSwap[index].znn.addDecimals( - znnDecimals, - )} ${kZnnCoin.symbol}, ' - '${_assetsBeforeSwap[index].qsr.addDecimals( - qsrDecimals, - )} ${kQsrCoin.symbol}', - style: const TextStyle( - color: AppColors.znnColor, - ), - ) - : Container(); - } - - Widget _getNewAddressBalanceInfo(index) { - return _assetsAfterSwap != null - ? Text( - '${_assetsBeforeSwap[index].znn - _assetsAfterSwap![index].znn} ${kZnnCoin.symbol}, ' - '${_assetsBeforeSwap[index].qsr - _assetsAfterSwap![index].qsr} ${kQsrCoin.symbol}', - style: const TextStyle( - color: AppColors.znnColor, - ), - ) - : Container(); - } - - Widget _getTransferBalanceWidget(TransferBalanceBloc model, int index) { - model.stream.listen( - (swapAssetEntryAfterSwap) { - if (swapAssetEntryAfterSwap != null) { - setState(() { - _newAddressErrorTexts[index] = null; - if (_currentlyActiveModel == model) { - _currentlyActiveModel = null; - } - }); - } - }, - onError: (error) { - setState(() { - _newAddressErrorTexts[index] = error.toString(); - _currentlyActiveModel = null; - }); - }, - ); - - return Row( - children: [ - StreamBuilder( - stream: model.stream, - builder: (_, snapshot) { - if (snapshot.hasError) { - return _getTransferBalanceIcon(model, index); - } - if (snapshot.connectionState == ConnectionState.active) { - if (snapshot.hasData) { - _swappedFileEntries.add(snapshot.data!); - return const Padding( - padding: EdgeInsets.all(8.0), - child: Icon( - Icons.check, - color: AppColors.znnColor, - ), - ); - } else { - return const Padding( - padding: EdgeInsets.all(8.0), - child: SyriusLoadingWidget( - size: 15.0, - ), - ); - } - } - return _getTransferBalanceIcon(model, index); - }, - ), - ], - ); - } - - Widget _getTransferBalanceIcon(TransferBalanceBloc model, int index) { - return RawMaterialButton( - child: Icon( - MaterialCommunityIcons.swap_horizontal, - color: _ifBalanceIsAvailable(index) && _currentlyActiveModel == null - ? AppColors.znnColor - : Theme.of(context).disabledColor, - ), - constraints: const BoxConstraints.tightForFinite(), - padding: const EdgeInsets.all(8), - shape: const CircleBorder(), - onPressed: _ifBalanceIsAvailable(index) && _currentlyActiveModel == null - ? () async { - setState(() { - _currentlyActiveModel = model; - }); - model.transferBalanceToNewAddresses( - widget._swapAssetsAndEntries.second[index], - _getKeyPairForNewAddress(index), - widget._passphrase, - ); - } - : null, - ); - } - - void _initNewAddressErrorTexts() { - _newAddressErrorTexts = List.generate( - _newKeyPairs!.length, - (index) => null, - ); - } - - Widget _getGoBackToSettingsButton() { - return OnboardingButton( - onPressed: _currentlyActiveModel == null ? _onFinishButtonPressed : null, - text: 'Finish', - ); - } - - void _onFinishButtonPressed() { - Navigator.popUntil( - context, - ModalRoute.withName(MainAppContainer.route), - ); - if (_shouldPerformCleanup ?? false) { - _removeLegacyData().then( - (value) => sl.get().addNotification( - WalletNotification( - title: 'Successful cleanup', - timestamp: DateTime.now().millisecondsSinceEpoch, - details: 'Successfully removed legacy data', - type: NotificationType.delete, - ), - ), onError: (error) { - NotificationUtils.sendNotificationError( - error, 'Couldn\'t remove legacy data'); - }); - } - } - - bool _ifBalanceIsAvailable(int oldAddressIndex) => - _assetsBeforeSwap[oldAddressIndex].znn > 0 || - _assetsBeforeSwap[oldAddressIndex].qsr > 0; - - Future _getKeyPairForNewAddress(int index) async => - (await kKeyStore!.findAddress( - Address.parse( - _selectedNewAddresses[index], - ), - kDefaultAddressList.length, - ))! - .keyPair; - - void _initSelectedNewAddresses() => _selectedNewAddresses = List.generate( - widget._swapAssetsAndEntries.first.length, - (index) => kDefaultAddressList[index]!, - ); - - void _initNewAddresses() { - _newKeyPairs = List.generate( - widget._swapAssetsAndEntries.second.length, - (index) => kKeyStore!.getKeyPair(index), - ); - } - - Widget _getPerformCleanupCheckBox() { - return Visibility( - visible: _ifThereIsNothingToSwap(), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Checkbox( - checkColor: Theme.of(context).scaffoldBackgroundColor, - activeColor: AppColors.znnColor, - value: _shouldPerformCleanup, - onChanged: (value) { - setState(() { - _shouldPerformCleanup = value; - }); - }, - ), - Text( - 'In order to avoid incompatibilities, remove legacy data', - style: Theme.of(context).textTheme.bodyText2, - ) - ], - ), - ); - } - - bool _ifThereIsNothingToSwap() { - for (int i = 0; i < _assetsBeforeSwap.length; i++) { - if (_assetsBeforeSwap[i].znn > 0 || _assetsBeforeSwap[i].qsr > 0) { - if (!_swappedFileEntries - .contains(widget._swapAssetsAndEntries.second[i])) { - return false; - } - } - } - return true; - } - - @override - void dispose() { - for (var controller in _currentAddressControllers) { - controller.dispose(); - } - for (var controller in _newAddressControllers) { - controller.dispose(); - } - for (var focusNode in _currentAddressNode) { - focusNode.dispose(); - } - for (var focusNode in _newAddressNode) { - focusNode.dispose(); - } - for (var bloc in _transferBalanceBlocs) { - bloc.dispose(); - } - _currentlyActiveModel?.dispose(); - _cleanupAfterSwapFinished(); - super.dispose(); - } - - void _cleanupAfterSwapFinished() async { - try { - String swapWalletTempDirectoryPath = path.join( - znnDefaultDirectory.path, - kSwapWalletTempDirectory, - ); - await FileUtils.deleteDirectory( - swapWalletTempDirectoryPath, - ); - } catch (e) { - NotificationUtils.sendNotificationError( - e, - 'Error while cleaning up files after swap', - ); - } - } - - Future _removeLegacyData() async { - List files = Directory(zenonDefaultLegacyDirectoryPath) - .listSync(recursive: true, followLinks: true); - for (FileSystemEntity file in files) { - String fileName = File(file.absolute.path).uri.pathSegments.last; - if (file.existsSync() && - !fileName.contains('wallet') && - !fileName.contains('backups')) { - file.deleteSync(recursive: true); - } - } - } - - String _getDefaultZenonLegacyDirectoryLocation() { - if (Platform.isWindows) { - return Platform.environment['AppData']!; - } else if (Platform.isMacOS) { - return path.join( - Platform.environment['HOME']!, 'Library', 'Application Support'); - } else { - return Platform.environment['HOME']!; - } - } - - String get zenonDefaultLegacyDirectoryPath => path.join( - _getDefaultZenonLegacyDirectoryLocation(), - _getZenonLegacyDirectoryName(), - ); - - String _getZenonLegacyDirectoryName() { - if (Platform.isLinux) { - return '.Zenon'; - } else { - return 'Zenon'; - } - } -} diff --git a/lib/utils/account_block_utils.dart b/lib/utils/account_block_utils.dart index 8f9f4858..cd9f27e8 100644 --- a/lib/utils/account_block_utils.dart +++ b/lib/utils/account_block_utils.dart @@ -1,11 +1,8 @@ import 'dart:async'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pow_generating_status_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/transfer/transfer_widgets_balance_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; @@ -68,10 +65,10 @@ class AccountBlockUtils { WalletNotification( title: 'Account-block published', timestamp: DateTime.now().millisecondsSinceEpoch, - details: 'Account-block type: ' + - FormatUtils.extractNameFromEnum( - BlockTypeEnum.values[response.blockType], - ), + details: + 'Account-block type: ${FormatUtils.extractNameFromEnum( + BlockTypeEnum.values[response.blockType], + )}', type: NotificationType.paymentSent, ), ); diff --git a/lib/utils/address_utils.dart b/lib/utils/address_utils.dart index 9046bc91..7bdd96f9 100644 --- a/lib/utils/address_utils.dart +++ b/lib/utils/address_utils.dart @@ -3,7 +3,7 @@ import 'dart:isolate'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/balance_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; @@ -24,21 +24,28 @@ class AddressUtils { static String getLabel(String address) => kAddressLabelMap[address] ?? address; - static Future generateNewAddress({VoidCallback? callback}) async { + static Future generateNewAddress( + {int numAddr = 1, VoidCallback? callback}) async { await Future.delayed(const Duration(milliseconds: 500)); - Address? newAddress = - await kKeyStore!.getKeyPair(kDefaultAddressList.length).address; - Box addressesBox = Hive.box(kAddressesBox); - await addressesBox.add(newAddress.toString()); - _initAddresses(addressesBox); - Box addressLabelsBox = Hive.box(kAddressLabelsBox); - await addressLabelsBox.put( - newAddress.toString(), - 'Address ${kDefaultAddressList.length}', - ); - _initAddressLabels(addressLabelsBox); - NodeUtils.getUnreceivedTransactionsByAddress(newAddress!); - callback?.call(); + List listAddr = []; + int addrListLength = kDefaultAddressList.length; + for (int i = 0; i < numAddr; i++) { + int addrListCounter = addrListLength + i; + Address? address = await kKeyStore!.getKeyPair(addrListCounter).address; + listAddr.add(address); + Box addressesBox = Hive.box(kAddressesBox); + await addressesBox.add(listAddr.elementAt(i).toString()); + _initAddresses(addressesBox); + Box addressLabelsBox = Hive.box(kAddressLabelsBox); + await addressLabelsBox.put( + listAddr.elementAt(i).toString(), + 'Address ${kDefaultAddressList.length}', + ); + _initAddressLabels(addressLabelsBox); + NodeUtils.getUnreceivedTransactionsByAddress(listAddr[i]!); + callback?.call(); + } + listAddr.clear(); } static Future setAddressLabels() async { diff --git a/lib/utils/app_theme.dart b/lib/utils/app_theme.dart index 2b9e5978..784e4fa2 100644 --- a/lib/utils/app_theme.dart +++ b/lib/utils/app_theme.dart @@ -16,7 +16,7 @@ final ButtonStyle kElevatedButtonStyle = ElevatedButton.styleFrom( ), ), minimumSize: const Size(55, 42), - primary: AppColors.znnColor, + backgroundColor: AppColors.znnColor, ); final ButtonStyle kOutlinedButtonStyle = OutlinedButton.styleFrom( @@ -32,39 +32,39 @@ final ButtonStyle kOutlinedButtonStyle = OutlinedButton.styleFrom( textStyle: kOutlinedButtonTextStyle, ); -const TextStyle kText1TextStyle = TextStyle( +const TextStyle kDisplaySmallTextStyle = TextStyle( fontSize: 14.0, fontWeight: FontWeight.w400, ); -const TextStyle kText2TextStyle = TextStyle( - fontSize: 12.0, +const TextStyle kBodyLargeTextStyle = TextStyle( + fontSize: 14.0, fontWeight: FontWeight.w400, ); -const TextStyle kHeadline6TextStyle = TextStyle( - fontSize: 16.0, +const TextStyle kBodyMediumTextStyle = TextStyle( + fontSize: 12.0, fontWeight: FontWeight.w400, ); -const TextStyle kHeadline5TextStyle = TextStyle( - fontSize: 18.0, - fontWeight: FontWeight.w400, +const TextStyle kBodySmallTextStyle = TextStyle( + fontSize: 10.0, + fontWeight: FontWeight.w300, ); -const TextStyle kHeadline4TextStyle = TextStyle( - fontSize: 20.0, - fontWeight: FontWeight.w400, +const TextStyle kHeadlineLargeTextStyle = TextStyle( + fontSize: 26.0, + fontWeight: FontWeight.w500, ); -const TextStyle kHeadline2TextStyle = TextStyle( +const TextStyle kHeadlineMediumTextStyle = TextStyle( fontSize: 24.0, fontWeight: FontWeight.w500, ); -const TextStyle kHeadline1TextStyle = TextStyle( - fontSize: 26.0, - fontWeight: FontWeight.w500, +const TextStyle kHeadlineSmallTextStyle = TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.w400, ); const TextStyle kOutlinedButtonTextStyle = TextStyle( @@ -77,13 +77,13 @@ const TextStyle kTextButtonTextStyle = TextStyle( fontWeight: FontWeight.w400, ); -const TextStyle kSubtitle1TextStyle = TextStyle( +const TextStyle kTitleMediumTextStyle = TextStyle( fontSize: 12.0, fontWeight: FontWeight.w400, color: AppColors.subtitleColor, ); -const TextStyle kSubtitle2TextStyle = TextStyle( +const TextStyle kTitleSmallTextStyle = TextStyle( fontSize: 10.0, fontWeight: FontWeight.w400, color: AppColors.subtitleColor, @@ -118,7 +118,7 @@ const OutlineInputBorder kOutlineInputBorder = OutlineInputBorder( class AppTheme { static final ThemeData lightTheme = ThemeData( - toggleableActiveColor: AppColors.znnColor, + useMaterial3: true, hoverColor: AppColors.lightTextFormFieldFill, textButtonTheme: kTextButtonThemeData, outlinedButtonTheme: OutlinedButtonThemeData( @@ -136,10 +136,10 @@ class AppTheme { elevatedButtonTheme: ElevatedButtonThemeData( style: kElevatedButtonStyle, ), - backgroundColor: AppColors.backgroundLight, scaffoldBackgroundColor: AppColors.backgroundLight, textSelectionTheme: const TextSelectionThemeData( cursorColor: AppColors.znnColor, + selectionHandleColor: AppColors.znnColor, ), fontFamily: 'Roboto', inputDecorationTheme: InputDecorationTheme( @@ -173,46 +173,89 @@ class AppTheme { dividerTheme: kDefaultDividerThemeData.copyWith( color: AppColors.lightDividerColor, ), - colorScheme: const ColorScheme.light( - primary: Colors.white, - primaryContainer: AppColors.lightPrimaryContainer, - secondary: AppColors.lightSecondary, - secondaryContainer: AppColors.lightSecondaryContainer, - error: AppColors.errorColor, - ), iconTheme: const IconThemeData( color: AppColors.lightSecondary, ), textTheme: TextTheme( - bodyText1: kText1TextStyle.copyWith( - color: Colors.black, - ), - bodyText2: kText2TextStyle.copyWith( + bodyLarge: kBodyMediumTextStyle.copyWith( color: Colors.black, ), - subtitle1: kSubtitle1TextStyle, - subtitle2: kSubtitle2TextStyle, - headline6: kHeadline6TextStyle.copyWith( + bodyMedium: kBodyMediumTextStyle.copyWith( color: Colors.black, ), - headline5: kHeadline5TextStyle.copyWith( + bodySmall: kBodySmallTextStyle.copyWith( color: Colors.black, ), - headline4: kHeadline4TextStyle.copyWith( + titleMedium: kTitleMediumTextStyle, + titleSmall: kTitleSmallTextStyle, + headlineLarge: kHeadlineLargeTextStyle.copyWith( color: Colors.black, ), - headline2: kHeadline2TextStyle.copyWith( + headlineMedium: kHeadlineMediumTextStyle.copyWith( color: Colors.black, ), - headline1: kHeadline1TextStyle.copyWith( + headlineSmall: kHeadlineSmallTextStyle.copyWith( color: Colors.black, ), ), unselectedWidgetColor: AppColors.lightSecondaryContainer, + switchTheme: SwitchThemeData( + thumbColor: MaterialStateProperty.resolveWith( + (Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return AppColors.znnColor; + } + return null; + }), + trackColor: MaterialStateProperty.resolveWith( + (Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return AppColors.znnColor; + } + return null; + }), + ), + radioTheme: RadioThemeData( + fillColor: MaterialStateProperty.resolveWith( + (Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return AppColors.znnColor; + } + return null; + }), + ), + checkboxTheme: CheckboxThemeData( + fillColor: MaterialStateProperty.resolveWith( + (Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return AppColors.znnColor; + } + return null; + }), + ), + colorScheme: const ColorScheme.light( + primary: Colors.white, + primaryContainer: AppColors.lightPrimaryContainer, + secondary: AppColors.lightSecondary, + secondaryContainer: AppColors.lightSecondaryContainer, + error: AppColors.errorColor, + ).copyWith(background: AppColors.backgroundLight), ); static final ThemeData darkTheme = ThemeData( - toggleableActiveColor: AppColors.znnColor, + useMaterial3: true, hoverColor: AppColors.darkTextFormFieldFill, textButtonTheme: kTextButtonThemeData, outlinedButtonTheme: OutlinedButtonThemeData( @@ -230,11 +273,11 @@ class AppTheme { elevatedButtonTheme: ElevatedButtonThemeData( style: kElevatedButtonStyle, ), - backgroundColor: AppColors.backgroundDark, scaffoldBackgroundColor: AppColors.backgroundDark, textSelectionTheme: TextSelectionThemeData( selectionColor: Colors.white.withOpacity(0.1), cursorColor: AppColors.znnColor, + selectionHandleColor: AppColors.znnColor, ), fontFamily: 'Roboto', inputDecorationTheme: InputDecorationTheme( @@ -270,42 +313,85 @@ class AppTheme { dividerTheme: kDefaultDividerThemeData.copyWith( color: AppColors.darkDividerColor, ), - colorScheme: const ColorScheme.dark( - primary: AppColors.darkPrimary, - primaryContainer: AppColors.darkPrimaryContainer, - secondary: AppColors.darkSecondary, - secondaryContainer: AppColors.darkSecondaryContainer, - error: AppColors.errorColor, - ), iconTheme: const IconThemeData( color: AppColors.lightSecondary, ), textTheme: TextTheme( - bodyText1: kText1TextStyle.copyWith( + bodyLarge: kBodyLargeTextStyle.copyWith( color: Colors.white, ), - bodyText2: kText2TextStyle.copyWith( + bodyMedium: kBodyMediumTextStyle.copyWith( color: Colors.white, ), - subtitle1: kSubtitle1TextStyle, - subtitle2: kSubtitle2TextStyle, - headline6: kHeadline6TextStyle.copyWith( + bodySmall: kBodySmallTextStyle.copyWith( color: Colors.white, ), - headline5: kHeadline5TextStyle.copyWith( + titleMedium: kTitleMediumTextStyle, + titleSmall: kTitleSmallTextStyle, + headlineLarge: kHeadlineLargeTextStyle.copyWith( color: Colors.white, ), - headline4: kHeadline4TextStyle.copyWith( - color: AppColors.subtitleColor, - ), - headline2: kHeadline2TextStyle.copyWith( + headlineMedium: kHeadlineMediumTextStyle.copyWith( color: Colors.white, ), - headline1: kHeadline2TextStyle.copyWith( + headlineSmall: kHeadlineSmallTextStyle.copyWith( color: Colors.white, ), ), unselectedWidgetColor: AppColors.darkSecondaryContainer, + switchTheme: SwitchThemeData( + thumbColor: MaterialStateProperty.resolveWith( + (Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return AppColors.znnColor; + } + return null; + }), + trackColor: MaterialStateProperty.resolveWith( + (Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return AppColors.znnColor; + } + return null; + }), + ), + radioTheme: RadioThemeData( + fillColor: MaterialStateProperty.resolveWith( + (Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return AppColors.znnColor; + } + return null; + }), + ), + checkboxTheme: CheckboxThemeData( + fillColor: MaterialStateProperty.resolveWith( + (Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return AppColors.znnColor; + } + return null; + }), + ), + colorScheme: const ColorScheme.dark( + primary: AppColors.darkPrimary, + primaryContainer: AppColors.darkPrimaryContainer, + secondary: AppColors.darkSecondary, + secondaryContainer: AppColors.darkSecondaryContainer, + error: AppColors.errorColor, + ).copyWith(background: AppColors.backgroundDark), ); AppTheme._(); diff --git a/lib/utils/clipboard_utils.dart b/lib/utils/clipboard_utils.dart index 5a630a06..63b7c357 100644 --- a/lib/utils/clipboard_utils.dart +++ b/lib/utils/clipboard_utils.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; class ClipboardUtils { diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart index 15b03a9f..145249eb 100644 --- a/lib/utils/constants.dart +++ b/lib/utils/constants.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/main_app_container.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/settings_widgets/display.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; // Dimensions @@ -24,11 +23,11 @@ const SizedBox kSpacingBetweenActionButtons = SizedBox( const Size kAcceleratorProgressBarSize = Size(300.0, 10.0); const List kBridgeNetworks = [ - 'BNB Smart Chain Mainnet', + 'The ZNN to wZNN bridge is unavailable. A new bridge will be available soon.', ]; // Wallet version -const String kWalletVersion = '0.0.5'; +const String kWalletVersion = '0.0.6'; // Boxes constants const String kFavoriteTokensBox = 'favourite_tokens_box'; @@ -50,9 +49,6 @@ const List kCacheBoxesToBeDeleted = [ kNodesBox, ]; -// Swap temporary directory -const String kSwapWalletTempDirectory = 'swap-wallet'; - // Wallet file name const String kNameWalletFile = 'wallet'; @@ -139,31 +135,28 @@ const int kWalletNotificationHiveTypeId = 100; const int kNotificationTypeEnumHiveTypeId = 101; // Community links -const String kWebsite = 'zenon.network'; -const String kCommunityWebsite = 'zenon.community'; -const String kOrgCommunityWebsite = 'zenon.org'; -const String kTwitter = 'twitter.com/Zenon_Network'; -const String kTelegram = 't.me/joinchat/MLyPehLIbJj1nw1XOOOltg'; -const String kGithub = 'github.com/zenon-network'; -const String kExplorer = 'explorer.zenon.network'; -const String kScraper = 'zenonscraper.com'; -const String kWiki = 'github.com/zenon-network/znn-wiki'; -const String kCommunityWiki = 'zenon.wiki'; -const String kTools = 'zenon.tools'; -const String kZnnController = 'github.com/zenon-network/znn_controller_dart'; +const String kWebsite = 'https://zenon.network'; +const String kOrgCommunityWebsite = 'https://zenon.org'; +const String kOrgCommunityForum = 'https://forum.zenon.org'; +const String kHubCommunityWebsite = 'https://zenonhub.io'; +const String kHubCommunityExplorer = 'https://zenonhub.io/explorer'; +const String kTwitter = 'https://twitter.com/Zenon_Network'; +const String kTelegram = 'https://t.me/zenonnetwork'; +const String kGithub = 'https://github.com/zenon-network'; +const String kExplorer = 'https://explorer.zenon.network'; +const String kWiki = 'https://wiki.zenon.network'; +const String kOrgCommunityWiki = 'https://docs.zenon.org'; +const String kTools = 'https://zenon.tools'; +const String kWhitepaper = + 'https://github.com/zenon-network/zenon.network/releases/download/whitepaper/whitepaper.pdf'; +const String kZnnController = + 'https://github.com/zenon-network/znn_controller_dart/releases/latest'; const String kBitcoinTalk = - 'bitcointalk.org/index.php?topic=5279643.msg55303681#msg55303681'; -const String kDiscord = 'discord.gg/VE2ENBGPNa'; -const String kMedium = 'medium.com/@zenon.network'; -const String kReddit = 'reddit.com/r/Zenon_Network'; -const String kYoutube = 'youtube.com/channel/UCDb8ZtqBt6l5l4HugCnJwhQ'; - -// Bridge links -const String kJoinLiquidityProgramUrl = - 'https://bridge.zenon.network/#liquidity'; -const String kAddLiquidityUrl = - 'https://pancakeswap.finance/add/0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c/0x84b174628911896a3b87fa6980d05dbc2ee74836'; -const int kLiquidityRewardsMultiplier = 10; + 'https://bitcointalk.org/index.php?topic=5279643.msg55303681#msg55303681'; +const String kDiscord = 'https://discord.gg/zenonnetwork'; +const String kMedium = 'https://medium.com/@zenon.network'; +const String kReddit = 'https://reddit.com/r/Zenon_Network'; +const String kYoutube = 'https://youtube.com/channel/UCDb8ZtqBt6l5l4HugCnJwhQ'; // Wallet security const double kAutoEraseNumAttemptsDefault = 3; @@ -171,6 +164,16 @@ const int kAutoLockWalletDefaultIntervalMinutes = 15; const String kAutoLockWalletMinutesKey = 'auto_lock_interval_minutes'; const String kAutoEraseNumAttemptsKey = 'auto_erase_num_attempts'; +// Wallet preferences +const String kLaunchAtStartupKey = 'launch_at_startup'; +const bool kLaunchAtStartupDefaultValue = false; +const String kEnableDesktopNotificationsKey = 'enable_desktop_notifications'; +const bool kEnableDesktopNotificationsDefaultValue = false; + +/// Node management +const String kChainIdKey = 'chain_id'; +const int kChainIdDefaultValue = 1; // 1 corresponds to Alphanet + // Display constants const String kThemeModeKey = 'theme_mode_key'; const ThemeMode kDefaultThemeMode = ThemeMode.dark; diff --git a/lib/utils/device_utils.dart b/lib/utils/device_utils.dart index fe86c27e..d68bfac5 100644 --- a/lib/utils/device_utils.dart +++ b/lib/utils/device_utils.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:device_info_plus/device_info_plus.dart'; +import 'package:flutter/services.dart'; import 'package:package_info_plus/package_info_plus.dart'; class DeviceUtils { @@ -65,4 +66,11 @@ class DeviceUtils { 'buildNumber': packageInfo.buildNumber, }; } + + static Future> getGitInfo() async { + final head = await rootBundle.loadString('.git/HEAD'); + final branchName = head.split('/').last; + final commitHash = await rootBundle.loadString('.git/ORIG_HEAD'); + return {'branchName': branchName, 'commitHash': commitHash}; + } } diff --git a/lib/utils/file_utils.dart b/lib/utils/file_utils.dart index dfe66d67..b9a93c84 100644 --- a/lib/utils/file_utils.dart +++ b/lib/utils/file_utils.dart @@ -4,7 +4,7 @@ class FileUtils { static Future deleteFile(String path) async { try { final file = File(path); - if (await file.exists()) { + if (file.existsSync()) { await file.delete(); } else { throw 'There is no file at the following path: $path'; @@ -17,7 +17,7 @@ class FileUtils { static Future deleteDirectory(String path) async { try { final directory = Directory(path); - if (await directory.exists()) { + if (directory.existsSync()) { await directory.delete(recursive: true); } else { throw 'There is no directory at the following path: $path'; diff --git a/lib/utils/global.dart b/lib/utils/global.dart index f2dad7af..53b11c17 100644 --- a/lib/utils/global.dart +++ b/lib/utils/global.dart @@ -1,8 +1,8 @@ import 'dart:io'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/main_app_container.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; String? kCurrentNode; diff --git a/lib/utils/init_utils.dart b/lib/utils/init_utils.dart new file mode 100644 index 00000000..65d62b9c --- /dev/null +++ b/lib/utils/init_utils.dart @@ -0,0 +1,98 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:hive/hive.dart'; +import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/services/shared_prefs_service.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/keystore_utils.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/node_utils.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/widget_utils.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; + +class InitUtils { + static Future initApp(BuildContext context) async { + try { + WidgetUtils.setThemeMode(context); + WidgetUtils.setTextScale(context); + _setAutoEraseWalletNumAttempts(); + _setAutoLockWalletTimeInterval(); + await KeyStoreUtils.setKeyStorePath(); + await _setNumUnlockFailedAttempts(); + await NodeUtils.setNode(); + _setChainId(); + await NodeUtils.loadDbNodes(); + } catch (e) { + rethrow; + } + } + + static void _setChainId() { + setChainIdentifier( + chainIdentifier: sharedPrefsService!.get( + kChainIdKey, + defaultValue: kChainIdDefaultValue, + ), + ); + } + + static Future _setNumUnlockFailedAttempts() async { + if (sharedPrefsService == null) { + sharedPrefsService = await sl.getAsync(); + } else { + await sharedPrefsService!.checkIfBoxIsOpen(); + } + + if (sharedPrefsService!.get(kNumUnlockFailedAttemptsKey) == null) { + await sharedPrefsService!.put( + kNumUnlockFailedAttemptsKey, + 0, + ); + } + kNumFailedUnlockAttempts = + sharedPrefsService!.get(kNumUnlockFailedAttemptsKey); + } + + static void _setAutoEraseWalletNumAttempts() => + kAutoEraseWalletLimit = sharedPrefsService!.get( + kAutoEraseNumAttemptsKey, + defaultValue: kAutoEraseNumAttemptsDefault, + ); + + static void _setAutoLockWalletTimeInterval() => + kAutoLockWalletMinutes = sharedPrefsService!.get( + kAutoLockWalletMinutesKey, + defaultValue: kAutoLockWalletDefaultIntervalMinutes, + ); + + static Future initWalletAfterDecryption() async { + await AddressUtils.setAddresses(kKeyStore); + await AddressUtils.setAddressLabels(); + await AddressUtils.setDefaultAddress(); + zenon!.defaultKeyPair = kKeyStore!.getKeyPair( + kDefaultAddressList.indexOf(kSelectedAddress), + ); + await _openFavoriteTokensBox(); + await _openNotificationsBox(); + await _openRecipientBox(); + await NodeUtils.initWebSocketClient(); + await _setWalletVersion(); + kWalletInitCompleted = true; + } + + static Future _openFavoriteTokensBox() async => + await Hive.openBox(kFavoriteTokensBox); + + static Future _openNotificationsBox() async => + await Hive.openBox(kNotificationsBox); + + static Future _openRecipientBox() async => + await Hive.openBox(kRecipientAddressBox); + + static Future _setWalletVersion() async => sharedPrefsService!.put( + kWalletVersionKey, + kWalletVersion, + ); +} diff --git a/lib/utils/input_validators.dart b/lib/utils/input_validators.dart index 146f9c06..e830c43e 100644 --- a/lib/utils/input_validators.dart +++ b/lib/utils/input_validators.dart @@ -1,7 +1,7 @@ +import 'package:logging/logging.dart'; import 'package:validators/validators.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/logger.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class InputValidators { @@ -34,7 +34,19 @@ class InputValidators { return (value ?? '').isEmpty ? '$fieldName must not be empty' : null; } - static String? validateNumber(String? value) { + static String? validateNumber(String? number) { + try { + if (number == null) { + return 'Add a number'; + } + int.parse(number); + return null; + } catch (e) { + return 'Input is not a valid number'; + } + } + + static String? validateAmount(String? value) { if (value != null) { try { if (value.isEmpty) { @@ -45,8 +57,9 @@ class InputValidators { } double.parse(value); return null; - } catch (e) { - Logger.logError(e); + } catch (e, stackTrace) { + Logger('InputValidators') + .log(Level.SEVERE, 'validateAmount', e, stackTrace); return 'Error'; } } else { @@ -99,8 +112,9 @@ class InputValidators { : maxValue == min ? 'Value must be $min' : 'Value must be between $min and $maxValue'; - } catch (e) { - Logger.logError(e); + } catch (e, stackTrace) { + Logger('InputValidators') + .log(Level.SEVERE, 'correctValue', e, stackTrace); return 'Error'; } } @@ -164,8 +178,9 @@ class InputValidators { return 'Max supply must be 0 for non-mintable tokens'; } return null; - } catch (e) { - Logger.logError(e); + } catch (e, stackTrace) { + Logger('InputValidators') + .log(Level.SEVERE, 'isMaxSupplyZero', e, stackTrace); return 'Error'; } } else { diff --git a/lib/utils/keyboard_fixer.dart b/lib/utils/keyboard_fixer.dart deleted file mode 100644 index 89f36a64..00000000 --- a/lib/utils/keyboard_fixer.dart +++ /dev/null @@ -1,39 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; - -/* -Class that is used to fix the SHIFT right bug: after pressing and releasing -the key, it stays locked, as if it was still being pressed - */ -class KeyboardFixer extends StatefulWidget { - const KeyboardFixer({required this.child, Key? key}) : super(key: key); - final Widget child; - - @override - State createState() => _KeyboardFixerState(); -} - -class _KeyboardFixerState extends State { - final List _keysToBeIgnored = [ - PhysicalKeyboardKey.shiftRight, - PhysicalKeyboardKey.controlLeft, - ]; - - final FocusNode focus = FocusNode( - skipTraversal: true, - canRequestFocus: false, - ); - - @override - Widget build(BuildContext context) { - return Focus( - focusNode: focus, - onKey: (_, RawKeyEvent event) { - return _keysToBeIgnored.contains(event.physicalKey) - ? KeyEventResult.handled - : KeyEventResult.ignored; - }, - child: widget.child, - ); - } -} diff --git a/lib/utils/logger.dart b/lib/utils/logger.dart deleted file mode 100644 index f32883f5..00000000 --- a/lib/utils/logger.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:flutter/foundation.dart'; - -class Logger { - static void logError(Object error) { - if (!kReleaseMode) { - if (error is String) { - // ignore: avoid_print - print('Info: $error'); - } else { - // ignore: avoid_print - print('Error: ' + error.toString()); - if (error is Error) { - // ignore: avoid_print - print('Stack trace: ' + error.stackTrace.toString()); - } - } - } - } -} diff --git a/lib/utils/metadata.dart b/lib/utils/metadata.dart new file mode 100644 index 00000000..9d7a3f67 --- /dev/null +++ b/lib/utils/metadata.dart @@ -0,0 +1,5 @@ +const String gitBranchName = ''; +const String gitCommitHash = ''; +const String gitCommitMessage = ''; +const String gitCommitDate = ''; +const String gitOriginUrl = ''; diff --git a/lib/utils/navigation_utils.dart b/lib/utils/navigation_utils.dart index 49b478fe..f6c3348a 100644 --- a/lib/utils/navigation_utils.dart +++ b/lib/utils/navigation_utils.dart @@ -1,18 +1,18 @@ import 'package:flutter/material.dart'; import 'package:page_transition/page_transition.dart'; import 'package:url_launcher/url_launcher.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; class NavigationUtils { - static Future launchUrl(String url, BuildContext context) async { + static Future openUrl(String url, BuildContext context) async { if (!RegExp(r'^http').hasMatch(url)) { - url = 'http://' + url; + url = 'http://$url'; } - if (await canLaunch(url)) { - await launch(url); + var uri = Uri.parse(url); + if (await canLaunchUrl(uri)) { + await launchUrl(uri); } else { sl.get().addNotification( WalletNotification( diff --git a/lib/utils/network_utils.dart b/lib/utils/network_utils.dart index cfd8d4db..d1413e3c 100644 --- a/lib/utils/network_utils.dart +++ b/lib/utils/network_utils.dart @@ -10,17 +10,17 @@ class NetworkUtils { try { NetworkInterface vpnInterface = - interfaces.firstWhere((element) => element.name == "tun0"); + interfaces.firstWhere((element) => element.name == 'tun0'); return vpnInterface.addresses.first.address; } on StateError { try { NetworkInterface interface = - interfaces.firstWhere((element) => element.name == "wlan0"); + interfaces.firstWhere((element) => element.name == 'wlan0'); return interface.addresses.first.address; } catch (e) { try { NetworkInterface interface = interfaces.firstWhere((element) => - !(element.name == "tun0" || element.name == "wlan0")); + !(element.name == 'tun0' || element.name == 'wlan0')); return interface.addresses.first.address; } catch (e) { return e.toString(); diff --git a/lib/utils/node_utils.dart b/lib/utils/node_utils.dart index 58e12ba3..4a28e2c7 100644 --- a/lib/utils/node_utils.dart +++ b/lib/utils/node_utils.dart @@ -2,15 +2,13 @@ import 'dart:async'; import 'dart:io'; import 'dart:isolate'; -import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; +import 'package:logging/logging.dart'; import 'package:wakelock/wakelock.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/auto_receive_tx_worker.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/embedded_node/embedded_node.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; @@ -20,15 +18,29 @@ int _kHeight = 0; class NodeUtils { static Future establishConnectionToNode(String url) async { - return await zenon!.wsClient.initialize( + bool connectionStatus = await zenon!.wsClient.initialize( url, retry: false, ); + return connectionStatus; + } + + static Future getNodeChainIdentifier() async { + int nodeChainId = 1; + try { + await zenon!.ledger.getFrontierMomentum().then((value) { + nodeChainId = value.chainIdentifier; + }); + } catch (e, stackTrace) { + Logger('NodeUtils') + .log(Level.WARNING, 'getNodeChainIdentifier', e, stackTrace); + } + return nodeChainId; } static closeEmbeddedNode() async { // Release WakeLock - if (await Wakelock.enabled) { + if (!Platform.isLinux && await Wakelock.enabled) { Wakelock.disable(); } @@ -64,7 +76,7 @@ class NodeUtils { } } - static initWebSocketClient(BuildContext context) async { + static initWebSocketClient() async { addOnWebSocketConnectedCallback(); var url = kCurrentNode!; bool connected = false; @@ -153,7 +165,7 @@ class NodeUtils { static Future _getSubscriptionForAllAccountEvents() async => await zenon!.subscribe.toAllAccountBlocks(); - static Future loadDbNodes(BuildContext context) async { + static Future loadDbNodes() async { if (!Hive.isBoxOpen(kNodesBox)) { await Hive.openBox(kNodesBox); } @@ -171,7 +183,7 @@ class NodeUtils { } } - static Future setNode(BuildContext context) async { + static Future setNode() async { String savedNode = sharedPrefsService!.get( kSelectedNodeKey, defaultValue: kDefaultNodes.first, @@ -180,11 +192,11 @@ class NodeUtils { if (savedNode == 'Embedded Node') { // First we need to check if the node is not already running - bool _isConnectionEstablished = + bool isConnectionEstablished = await NodeUtils.establishConnectionToNode(kLocalhostDefaultNodeUrl); - if (_isConnectionEstablished == false) { + if (isConnectionEstablished == false) { // Acquire WakeLock - if (!await Wakelock.enabled) { + if (!Platform.isLinux && !await Wakelock.enabled) { Wakelock.enable(); } // Initialize local full node diff --git a/lib/utils/notification_utils.dart b/lib/utils/notification_utils.dart index 6e47b66a..38cf51a0 100644 --- a/lib/utils/notification_utils.dart +++ b/lib/utils/notification_utils.dart @@ -1,9 +1,8 @@ -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; +import 'package:logging/logging.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/logger.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class NotificationUtils { @@ -11,7 +10,8 @@ class NotificationUtils { Object error, String title, ) { - Logger.logError(error); + Logger('NotificationUtils') + .log(Level.WARNING, 'sendNotificationError', error); sl.get().addErrorNotification( error, title, diff --git a/lib/utils/notifiers/notifiers.dart b/lib/utils/notifiers/notifiers.dart new file mode 100644 index 00000000..f0ac7d78 --- /dev/null +++ b/lib/utils/notifiers/notifiers.dart @@ -0,0 +1,7 @@ +library notifiers; + +export 'app_theme_notifier.dart'; +export 'default_address_notifier.dart'; +export 'plasma_beneficiary_address_notifier.dart'; +export 'plasma_generated_notifier.dart'; +export 'text_scaling_notifier.dart'; diff --git a/lib/utils/notifiers/plasma_beneficiary_address_notifier.dart b/lib/utils/notifiers/plasma_beneficiary_address_notifier.dart index e38cb018..5ea0ddfe 100644 --- a/lib/utils/notifiers/plasma_beneficiary_address_notifier.dart +++ b/lib/utils/notifiers/plasma_beneficiary_address_notifier.dart @@ -5,10 +5,8 @@ class PlasmaBeneficiaryAddressNotifier extends ChangeNotifier { String? _plasmaBeneficiaryAddress = kSelectedAddress; changePlasmaBeneficiaryAddress(String? newAddress) { - if (_plasmaBeneficiaryAddress != newAddress) { - _plasmaBeneficiaryAddress = newAddress; - notifyListeners(); - } + _plasmaBeneficiaryAddress = newAddress; + notifyListeners(); } String? getBeneficiaryAddress() => _plasmaBeneficiaryAddress; diff --git a/lib/utils/notifiers/text_scaling_notifier.dart b/lib/utils/notifiers/text_scaling_notifier.dart index 272aaa84..4ba13161 100644 --- a/lib/utils/notifiers/text_scaling_notifier.dart +++ b/lib/utils/notifiers/text_scaling_notifier.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/settings_widgets/display.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class TextScalingNotifier extends ChangeNotifier { TextScaling? _currentTextScaling = kDefaultTextScaling; diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 06aaa3ec..742acb01 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -1,87 +1,24 @@ -import 'dart:async'; - -import 'package:flutter/material.dart'; -import 'package:hive/hive.dart'; -import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/services/shared_prefs_service.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/keystore_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/node_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/widget_utils.dart'; - -class Utils { - static Future initApp(BuildContext context) async { - try { - await KeyStoreUtils.setKeyStorePath(); - await _setNumUnlockFailedAttempts(); - await NodeUtils.setNode(context); - await NodeUtils.loadDbNodes(context); - WidgetUtils.setThemeMode(context); - WidgetUtils.setTextScale(context); - _setAutoEraseWalletNumAttempts(); - _setAutoLockWalletTimeInterval(); - } catch (e) { - rethrow; - } - } - - static Future _setNumUnlockFailedAttempts() async { - if (sharedPrefsService == null) { - sharedPrefsService = await sl.getAsync(); - } else { - await sharedPrefsService!.checkIfBoxIsOpen(); - } - - if (sharedPrefsService!.get(kNumUnlockFailedAttemptsKey) == null) { - await sharedPrefsService!.put( - kNumUnlockFailedAttemptsKey, - 0, - ); - } - kNumFailedUnlockAttempts = - sharedPrefsService!.get(kNumUnlockFailedAttemptsKey); - } - - static void _setAutoEraseWalletNumAttempts() => - kAutoEraseWalletLimit = sharedPrefsService!.get( - kAutoEraseNumAttemptsKey, - defaultValue: kAutoEraseNumAttemptsDefault, - ); - - static void _setAutoLockWalletTimeInterval() => - kAutoLockWalletMinutes = sharedPrefsService!.get( - kAutoLockWalletMinutesKey, - defaultValue: kAutoLockWalletDefaultIntervalMinutes, - ); - - static Future initWalletAfterDecryption(BuildContext context) async { - await AddressUtils.setAddresses(kKeyStore); - await AddressUtils.setAddressLabels(); - await AddressUtils.setDefaultAddress(); - zenon!.defaultKeyPair = kKeyStore!.getKeyPair( - kDefaultAddressList.indexOf(kSelectedAddress), - ); - await _openFavoriteTokensBox(); - await _openNotificationsBox(); - await _openRecipientBox(); - await NodeUtils.initWebSocketClient(context); - await _setWalletVersion(); - kWalletInitCompleted = true; - } - - static Future _openFavoriteTokensBox() async => - await Hive.openBox(kFavoriteTokensBox); - - static Future _openNotificationsBox() async => - await Hive.openBox(kNotificationsBox); - - static Future _openRecipientBox() async => - await Hive.openBox(kRecipientAddressBox); - - static Future _setWalletVersion() async => sharedPrefsService!.put( - kWalletVersionKey, - kWalletVersion, - ); -} +export 'account_block_utils.dart'; +export 'address_utils.dart'; +export 'app_colors.dart'; +export 'app_theme.dart'; +export 'clipboard_utils.dart'; +export 'color_utils.dart'; +export 'constants.dart'; +export 'device_utils.dart'; +export 'extensions.dart'; +export 'file_utils.dart'; +export 'format_utils.dart'; +export 'global.dart'; +export 'init_utils.dart'; +export 'input_validators.dart'; +export 'keystore_utils.dart'; +export 'navigation_utils.dart'; +export 'network_utils.dart'; +export 'node_utils.dart'; +export 'notification_utils.dart'; +export 'pair.dart'; +export 'utils.dart'; +export 'widget_utils.dart'; +export 'zts_utils.dart'; +export 'notifiers/notifiers.dart'; diff --git a/lib/utils/widget_utils.dart b/lib/utils/widget_utils.dart index f24648ea..a8bf6259 100644 --- a/lib/utils/widget_utils.dart +++ b/lib/utils/widget_utils.dart @@ -8,8 +8,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notifiers/app_theme_notifier.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notifiers/text_scaling_notifier.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/settings_widgets/display.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/infinite_scroll_table.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class WidgetUtils { @@ -44,14 +43,14 @@ class WidgetUtils { } static String isWidgetHiddenKey(String widgetTitle) => - widgetTitle + 'is_hidden'; + '${widgetTitle}is_hidden'; static InfiniteScrollTableCell getMarqueeAddressTableCell( Address? address, BuildContext context, ) { TextStyle? textStyle = address != null && address.isEmbedded() - ? Theme.of(context).textTheme.subtitle1!.copyWith( + ? Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.znnColor, fontWeight: FontWeight.bold, ) @@ -93,7 +92,7 @@ class WidgetUtils { bool showCopyToClipboardIcon = false, }) { TextStyle? textStyle = address != null && address.isEmbedded() - ? Theme.of(context).textTheme.subtitle1!.copyWith( + ? Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.znnColor, fontWeight: FontWeight.bold, ) @@ -101,7 +100,7 @@ class WidgetUtils { if (checkIfStakeAddress) { textStyle = address != null && address.toString() == kSelectedAddress - ? Theme.of(context).textTheme.subtitle1!.copyWith( + ? Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.znnColor, fontWeight: FontWeight.bold, ) diff --git a/lib/widgets/charts/pillar_rewards_chart.dart b/lib/widgets/charts/pillar_rewards_chart.dart index 8a0727c4..80984a84 100644 --- a/lib/widgets/charts/pillar_rewards_chart.dart +++ b/lib/widgets/charts/pillar_rewards_chart.dart @@ -4,8 +4,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_chart.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_line_chart_bar_data.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PillarRewardsChart extends StatefulWidget { @@ -52,9 +51,7 @@ class PillarRewardsChartState extends State { List _linesBarData() => [ StandardLineChartBarData( - colors: [ - AppColors.znnColor, - ], + color: AppColors.znnColor, spots: _getRewardsSpots(), ), ]; diff --git a/lib/widgets/charts/realtime_txs_chart.dart b/lib/widgets/charts/realtime_txs_chart.dart index c6ec494b..2d994960 100644 --- a/lib/widgets/charts/realtime_txs_chart.dart +++ b/lib/widgets/charts/realtime_txs_chart.dart @@ -5,8 +5,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/color_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_chart.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_line_chart_bar_data.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class RealtimeTxsChart extends StatefulWidget { @@ -37,9 +36,9 @@ class RealtimeTxsChartState extends State { @override Widget build(BuildContext context) { return StandardChart( - yValuesInterval: (_maxTransactionsPerDay + 1) > kNumOfChartLeftSideTitles - ? (_maxTransactionsPerDay + 1) / kNumOfChartLeftSideTitles - : null, + yValuesInterval: _maxTransactionsPerDay > kNumOfChartLeftSideTitles + ? _maxTransactionsPerDay / kNumOfChartLeftSideTitles + : 1, maxY: _maxTransactionsPerDay, lineBarsData: _linesBarData(), lineBarDotSymbol: 'txs', @@ -82,15 +81,11 @@ class RealtimeTxsChartState extends State { List _linesBarData() { return [ StandardLineChartBarData( - colors: [ - ColorUtils.getTokenColor(kZnnCoin.tokenStandard), - ], + color: ColorUtils.getTokenColor(kZnnCoin.tokenStandard), spots: _znnSpots, ), StandardLineChartBarData( - colors: [ - ColorUtils.getTokenColor(kQsrCoin.tokenStandard), - ], + color: ColorUtils.getTokenColor(kQsrCoin.tokenStandard), spots: _qsrSpots, ), ]; diff --git a/lib/widgets/charts/sentinel_rewards_chart.dart b/lib/widgets/charts/sentinel_rewards_chart.dart index 78537d22..464d766c 100644 --- a/lib/widgets/charts/sentinel_rewards_chart.dart +++ b/lib/widgets/charts/sentinel_rewards_chart.dart @@ -6,8 +6,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_chart.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_line_chart_bar_data.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class SentinelRewardsChart extends StatefulWidget { @@ -63,15 +62,11 @@ class _SentinelRewardsChart extends State { List _linesBarData() => [ StandardLineChartBarData( - colors: [ - AppColors.znnColor, - ], + color: AppColors.znnColor, spots: _getZnnRewardsSpots(), ), StandardLineChartBarData( - colors: [ - AppColors.qsrColor, - ], + color: AppColors.qsrColor, spots: _getQsrRewardsSpots(), ), ]; diff --git a/lib/widgets/charts/staking_rewards_chart.dart b/lib/widgets/charts/staking_rewards_chart.dart index 1e9701f4..026de9f9 100644 --- a/lib/widgets/charts/staking_rewards_chart.dart +++ b/lib/widgets/charts/staking_rewards_chart.dart @@ -4,8 +4,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_chart.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_line_chart_bar_data.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class StakingRewardsChart extends StatefulWidget { @@ -52,9 +51,7 @@ class _StakingRewardsChart extends State { _linesBarData() => [ StandardLineChartBarData( - colors: [ - AppColors.qsrColor, - ], + color: AppColors.qsrColor, spots: _getRewardsSpots(), ), ]; diff --git a/lib/widgets/main_app_container.dart b/lib/widgets/main_app_container.dart index 78229ec4..ce179578 100644 --- a/lib/widgets/main_app_container.dart +++ b/lib/widgets/main_app_container.dart @@ -4,14 +4,9 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:provider/provider.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/auto_receive_tx_worker.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/lock_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/node_sync_status_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pow_generating_status_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; @@ -19,22 +14,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notifiers/text_scaling_notifier.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/overscroll_remover.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/notification_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/tab_children_widgets/accelerator_tab_child.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/tab_children_widgets/bridge_tab_child.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/tab_children_widgets/dashboard_tab_child.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/tab_children_widgets/help_tab_child.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/tab_children_widgets/lock_tab_child.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/tab_children_widgets/notifications_tab_child.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/tab_children_widgets/pillars_tab_child.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/tab_children_widgets/plasma_tab_child.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/tab_children_widgets/sentinels_tab_child.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/tab_children_widgets/settings_tab_child.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/tab_children_widgets/staking_tab_child.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/tab_children_widgets/tokens_tab_child.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/tab_children_widgets/transfer_tab_child.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; enum Tabs { @@ -65,7 +45,7 @@ class MainAppContainer extends StatefulWidget { }) : super(key: key); @override - _MainAppContainerState createState() => _MainAppContainerState(); + State createState() => _MainAppContainerState(); } class _MainAppContainerState extends State @@ -146,11 +126,8 @@ class _MainAppContainerState extends State borderRadius: BorderRadius.circular( 15.0, ), - child: ScrollConfiguration( - behavior: RemoveOverscrollEffect(), - child: Container( - child: _getCurrentPageContainer(), - ), + child: Container( + child: _getCurrentPageContainer(), ), ), ), @@ -224,12 +201,14 @@ class _MainAppContainerState extends State child: IgnorePointer( ignoring: _isWalletLocked(), child: TabBar( - labelStyle: - Theme.of(context).textTheme.headline6!.copyWith( - fontSize: 15.0, - ), + labelStyle: Theme.of(context) + .textTheme + .headlineSmall! + .copyWith( + fontSize: 15.0, + ), labelColor: - Theme.of(context).textTheme.headline6!.color, + Theme.of(context).textTheme.headlineSmall!.color, onTap: (int index) { if (_isTabSelected(Tabs.lock)) { _onNavigateToLock(); diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donation_stepper.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donation_stepper.dart index bc026f2c..e639822d 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donation_stepper.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donation_stepper.dart @@ -1,28 +1,12 @@ import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/accelerator/submit_donation_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/balance_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/stepper_button.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_material_stepper.dart' as custom_material_stepper; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dotted_border_info_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/standard_tooltip_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/amount_suffix_widgets.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/disabled_address_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/stepper_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; enum AcceleratorDonationStep { @@ -35,7 +19,7 @@ class AcceleratorDonationStepper extends StatefulWidget { const AcceleratorDonationStepper({Key? key}) : super(key: key); @override - _AcceleratorDonationStepperState createState() => + State createState() => _AcceleratorDonationStepperState(); } @@ -251,6 +235,7 @@ class _AcceleratorDonationStepperState Text('Total donation budget'), StandardTooltipIcon( 'Your donation matters', + Icons.help, ), ], ), @@ -445,7 +430,7 @@ class _AcceleratorDonationStepperState Widget _getSubmitDonationViewModel() { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (event) { if (event != null) { diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donations.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donations.dart index 725794a6..9791a7eb 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donations.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_donations.dart @@ -1,11 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/stepper_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/accelerator_widgets/accelerator_donation_stepper.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/elevated_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class AcceleratorDonations extends StatelessWidget { final VoidCallback onStepperNotificationSeeMorePressed; @@ -41,7 +38,7 @@ class AcceleratorDonations extends StatelessWidget { width: 200.0, child: Text( 'Fuel for the Mothership', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), ), kVerticalSpacing, diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list.dart index 0084131d..3d52dae1 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list.dart @@ -1,12 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/tag_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; -enum ProjectsFilterTag { +enum AcceleratorProjectsFilterTag { myProjects, onlyAccepted, votingOpened, @@ -27,14 +24,14 @@ class AcceleratorProjectList extends StatefulWidget { }) : super(key: key); @override - _AcceleratorProjectListState createState() => _AcceleratorProjectListState(); + State createState() => _AcceleratorProjectListState(); } class _AcceleratorProjectListState extends State { final TextEditingController _searchKeyWordController = TextEditingController(); - final List _selectedProjectsFilterTag = []; + final List _selectedProjectsFilterTag = []; final ScrollController _scrollController = ScrollController(); @@ -59,7 +56,7 @@ class _AcceleratorProjectListState extends State { Expanded( child: Scrollbar( controller: _scrollController, - isAlwaysShown: true, + thumbVisibility: true, child: ListView.separated( separatorBuilder: (_, __) => const SizedBox( height: 15.0, @@ -168,17 +165,18 @@ class _AcceleratorProjectListState extends State { Widget _getProjectsFilterTags() { return Row( children: [ - _getProjectsFilterTag(ProjectsFilterTag.myProjects), - _getProjectsFilterTag(ProjectsFilterTag.onlyAccepted), + _getProjectsFilterTag(AcceleratorProjectsFilterTag.myProjects), + _getProjectsFilterTag(AcceleratorProjectsFilterTag.onlyAccepted), if (widget.pillarInfo != null) - _getProjectsFilterTag(ProjectsFilterTag.votingOpened), + _getProjectsFilterTag(AcceleratorProjectsFilterTag.votingOpened), ], ); } - Widget _getProjectsFilterTag(ProjectsFilterTag filterTag) { + Widget _getProjectsFilterTag(AcceleratorProjectsFilterTag filterTag) { return TagWidget( - text: FormatUtils.extractNameFromEnum(filterTag), + text: FormatUtils.extractNameFromEnum( + filterTag), hexColorCode: Theme.of(context) .colorScheme .primaryContainer @@ -202,12 +200,14 @@ class _AcceleratorProjectListState extends State { Set _filterProjectsByFilterTags(List projects) { var filteredBaseProjects = const Iterable.empty(); - if (_selectedProjectsFilterTag.contains(ProjectsFilterTag.myProjects)) { + if (_selectedProjectsFilterTag + .contains(AcceleratorProjectsFilterTag.myProjects)) { filteredBaseProjects = projects.where( (project) => project.owner.toString() == kSelectedAddress, ); } - if (_selectedProjectsFilterTag.contains(ProjectsFilterTag.onlyAccepted)) { + if (_selectedProjectsFilterTag + .contains(AcceleratorProjectsFilterTag.onlyAccepted)) { if (filteredBaseProjects.isNotEmpty) { filteredBaseProjects = filteredBaseProjects.where( (project) => project.status == AcceleratorProjectStatus.active, @@ -218,7 +218,8 @@ class _AcceleratorProjectListState extends State { ); } } - if (_selectedProjectsFilterTag.contains(ProjectsFilterTag.votingOpened)) { + if (_selectedProjectsFilterTag + .contains(AcceleratorProjectsFilterTag.votingOpened)) { if (filteredBaseProjects.isNotEmpty) { filteredBaseProjects = filteredBaseProjects.where( (project) => project.status == AcceleratorProjectStatus.voting, diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart index a7e4f4f2..9baf5e63 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart @@ -1,24 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/accelerator/project_vote_breakdown_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/accelerator/vote_project_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/project_details_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/stepper_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/pair.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/accelerator_widgets/update_phase_stepper.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/accelerator_project_details.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/progress_bars.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/tag_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class AcceleratorProjectListItem extends StatefulWidget { @@ -36,7 +22,7 @@ class AcceleratorProjectListItem extends StatefulWidget { }) : super(key: key); @override - _AcceleratorProjectListItemState createState() => + State createState() => _AcceleratorProjectListItemState(); } @@ -132,7 +118,7 @@ class _AcceleratorProjectListItemState children: [ Text( widget.acceleratorProject.name, - style: Theme.of(context).textTheme.headline5, + style: Theme.of(context).textTheme.headlineSmall, ), ], ); @@ -144,7 +130,7 @@ class _AcceleratorProjectListItemState Expanded( child: Text( widget.acceleratorProject.description, - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), ), ], @@ -314,6 +300,7 @@ class _AcceleratorProjectListItemState Row( children: [ AcceleratorProgressBar( + context: context, child: Row( children: [ AcceleratorProgressBarSpan( @@ -335,8 +322,7 @@ class _AcceleratorProjectListItemState '$pillarsThatCanStillVote Pillars that can still cast a vote', ), ], - ), - context: context), + )), const SizedBox( width: 10.0, ), @@ -367,7 +353,7 @@ class _AcceleratorProjectListItemState materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, shape: const CircleBorder(), onPressed: () => - NavigationUtils.launchUrl(widget.acceleratorProject.url, context), + NavigationUtils.openUrl(widget.acceleratorProject.url, context), child: Tooltip( message: 'Visit ${widget.acceleratorProject.url}', child: Container( @@ -598,7 +584,7 @@ class _AcceleratorProjectListItemState ProjectVoteBreakdownBloc projectVoteBreakdownViewModel, ) { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen((event) { if (event != null) { projectVoteBreakdownViewModel.getVoteBreakdown( @@ -633,7 +619,7 @@ class _AcceleratorProjectListItemState Widget _getProjectVoteBreakdownViewModel(BuildContext context) { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.getVoteBreakdown( widget.pillarInfo?.name, widget.acceleratorProject.id); model.stream.listen((event) {}, onError: (error) { diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_stats.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_stats.dart index 69d72f8a..6bc68252 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_stats.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_stats.dart @@ -1,24 +1,16 @@ import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/accelerator/accelerator_balance_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/color_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/chart_legend.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_pie_chart.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/formatted_amount_with_tooltip.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class AcceleratorStats extends StatefulWidget { const AcceleratorStats({Key? key}) : super(key: key); @override - _AcceleratorStatsState createState() => _AcceleratorStatsState(); + State createState() => _AcceleratorStatsState(); } class _AcceleratorStatsState extends State { @@ -91,7 +83,7 @@ class _AcceleratorStatsState extends State { tokenSymbol: kZnnCoin.symbol, builder: (amount, tokenSymbol) => Text( '$amount $tokenSymbol', - style: Theme.of(context).textTheme.subtitle1!, + style: Theme.of(context).textTheme.titleMedium!, ), ), ), @@ -106,7 +98,7 @@ class _AcceleratorStatsState extends State { tokenSymbol: kQsrCoin.symbol, builder: (amount, tokenSymbol) => Text( '$amount $tokenSymbol', - style: Theme.of(context).textTheme.subtitle1!, + style: Theme.of(context).textTheme.titleMedium!, ), ), ), @@ -156,7 +148,7 @@ class _AcceleratorStatsState extends State { value: value / sumValues, title: accountInfo.findTokenByTokenStandard(token.tokenStandard)!.symbol, radius: 60.0, - titleStyle: Theme.of(context).textTheme.bodyText1, + titleStyle: Theme.of(context).textTheme.bodyLarge, ); } } diff --git a/lib/widgets/modular_widgets/accelerator_widgets/accelerator_widgets.dart b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_widgets.dart new file mode 100644 index 00000000..001249bc --- /dev/null +++ b/lib/widgets/modular_widgets/accelerator_widgets/accelerator_widgets.dart @@ -0,0 +1,13 @@ +export 'accelerator_donation_stepper.dart'; +export 'accelerator_donations.dart'; +export 'accelerator_project_list.dart'; +export 'accelerator_project_list_item.dart'; +export 'accelerator_stats.dart'; +export 'create_phase.dart'; +export 'create_project.dart'; +export 'phase_creation_stepper.dart'; +export 'phase_list.dart'; +export 'project_creation_stepper.dart'; +export 'project_list.dart'; +export 'projects_stats.dart'; +export 'update_phase_stepper.dart'; diff --git a/lib/widgets/modular_widgets/accelerator_widgets/create_phase.dart b/lib/widgets/modular_widgets/accelerator_widgets/create_phase.dart index f7e1d845..44754889 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/create_phase.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/create_phase.dart @@ -1,11 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/stepper_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/accelerator_widgets/phase_creation_stepper.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/elevated_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class CreatePhase extends StatelessWidget { @@ -46,7 +43,7 @@ class CreatePhase extends StatelessWidget { width: 200.0, child: Text( 'Start the project by creating a phase to unlock funds', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), ), kVerticalSpacing, diff --git a/lib/widgets/modular_widgets/accelerator_widgets/create_project.dart b/lib/widgets/modular_widgets/accelerator_widgets/create_project.dart index 67dbb32c..d4170ff2 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/create_project.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/create_project.dart @@ -1,11 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/stepper_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/accelerator_widgets/project_creation_stepper.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/elevated_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class CreateProject extends StatelessWidget { final VoidCallback onStepperNotificationSeeMorePressed; @@ -41,7 +38,7 @@ class CreateProject extends StatelessWidget { width: 200.0, child: Text( 'Join the Aliens building the future on Network of Momentum', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), ), kVerticalSpacing, diff --git a/lib/widgets/modular_widgets/accelerator_widgets/phase_creation_stepper.dart b/lib/widgets/modular_widgets/accelerator_widgets/phase_creation_stepper.dart index b5ae80bb..638db334 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/phase_creation_stepper.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/phase_creation_stepper.dart @@ -1,28 +1,13 @@ import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/accelerator/create_phase_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/balance_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/stepper_button.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_material_stepper.dart' as custom_material_stepper; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dotted_border_info_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/standard_tooltip_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/amount_suffix_widgets.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/stepper_utils.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; enum PhaseCreationStep { phaseDetails, @@ -35,7 +20,7 @@ class PhaseCreationStepper extends StatefulWidget { const PhaseCreationStepper(this.project, {Key? key}) : super(key: key); @override - _PhaseCreationStepperState createState() => _PhaseCreationStepperState(); + State createState() => _PhaseCreationStepperState(); } class _PhaseCreationStepperState extends State { @@ -256,7 +241,9 @@ class _PhaseCreationStepperState extends State { ), ), const StandardTooltipIcon( - 'Showcase the progress of your project (e.g. Git PR/commit)'), + 'Showcase the progress of your project (e.g. Git PR/commit)', + Icons.help, + ), ], ), kVerticalSpacing, @@ -264,10 +251,12 @@ class _PhaseCreationStepperState extends State { children: [ Text( 'Total phase budget', - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), const StandardTooltipIcon( - 'Necessary budget to successfully complete this phase'), + 'Necessary budget to successfully complete this phase', + Icons.help, + ), ], ), kVerticalSpacing, @@ -454,7 +443,7 @@ class _PhaseCreationStepperState extends State { Widget _getCreatePhaseViewModel() { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (event) { if (event != null) { diff --git a/lib/widgets/modular_widgets/accelerator_widgets/phase_list.dart b/lib/widgets/modular_widgets/accelerator_widgets/phase_list.dart index 4f40935f..27b6a8ca 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/phase_list.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/phase_list.dart @@ -1,7 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/accelerator_widgets/accelerator_project_list.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PhaseList extends StatelessWidget { diff --git a/lib/widgets/modular_widgets/accelerator_widgets/project_creation_stepper.dart b/lib/widgets/modular_widgets/accelerator_widgets/project_creation_stepper.dart index 6f7c553f..71828429 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/project_creation_stepper.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/project_creation_stepper.dart @@ -1,29 +1,13 @@ import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/accelerator/create_project_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/balance_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/stepper_button.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_material_stepper.dart' as custom_material_stepper; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dotted_border_info_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/standard_tooltip_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/amount_suffix_widgets.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/disabled_address_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/stepper_utils.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; enum ProjectCreationStep { projectCreation, @@ -35,7 +19,7 @@ class ProjectCreationStepper extends StatefulWidget { const ProjectCreationStepper({Key? key}) : super(key: key); @override - _ProjectCreationStepperState createState() => _ProjectCreationStepperState(); + State createState() => _ProjectCreationStepperState(); } class _ProjectCreationStepperState extends State { @@ -320,7 +304,10 @@ class _ProjectCreationStepperState extends State { ), ), ), - const StandardTooltipIcon('Link to project article'), + const StandardTooltipIcon( + 'Link to project article', + Icons.help, + ), ], ), kVerticalSpacing, @@ -328,9 +315,12 @@ class _ProjectCreationStepperState extends State { children: [ Text( 'Total project budget', - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, + ), + const StandardTooltipIcon( + 'Set a budget for the project', + Icons.help, ), - const StandardTooltipIcon('Set a budget for the project'), ], ), kVerticalSpacing, @@ -476,7 +466,7 @@ class _ProjectCreationStepperState extends State { Widget _getSubmitProjectViewModel() { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (event) { if (event != null) { diff --git a/lib/widgets/modular_widgets/accelerator_widgets/project_list.dart b/lib/widgets/modular_widgets/accelerator_widgets/project_list.dart index 93107348..3619d148 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/project_list.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/project_list.dart @@ -4,39 +4,33 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:rxdart/rxdart.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/accelerator/project_list_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/accelerator_widgets/accelerator_project_list_item.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/tag_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; -enum ProjectsFilterTag { +enum AccProjectsFilterTag { myProjects, onlyAccepted, votingOpened, alreadyVoted, } -class ProjectList extends StatefulWidget { +class AccProjectList extends StatefulWidget { final VoidCallback onStepperNotificationSeeMorePressed; final PillarInfo? pillarInfo; - const ProjectList({ + const AccProjectList({ required this.onStepperNotificationSeeMorePressed, required this.pillarInfo, Key? key, }) : super(key: key); @override - _ProjectListState createState() => _ProjectListState(); + State createState() => _AccProjectListState(); } -class _ProjectListState extends State { +class _AccProjectListState extends State { final ScrollController _scrollController = ScrollController(); final PagingController _pagingController = PagingController( firstPageKey: 0, @@ -119,7 +113,7 @@ class _ProjectListState extends State { Expanded( child: Scrollbar( controller: _scrollController, - isAlwaysShown: true, + thumbVisibility: true, child: PagedListView.separated( scrollController: _scrollController, pagingController: _pagingController, @@ -171,10 +165,12 @@ class _ProjectListState extends State { Row _getProjectsFilterTags() { List children = []; - for (var tag in ProjectsFilterTag.values) { + for (var tag in AccProjectsFilterTag.values) { if (widget.pillarInfo == null) { - if ([ProjectsFilterTag.votingOpened, ProjectsFilterTag.alreadyVoted] - .contains(tag)) { + if ([ + AccProjectsFilterTag.votingOpened, + AccProjectsFilterTag.alreadyVoted + ].contains(tag)) { continue; } } @@ -186,9 +182,9 @@ class _ProjectListState extends State { ); } - _getProjectsFilterTag(ProjectsFilterTag filterTag) { + _getProjectsFilterTag(AccProjectsFilterTag filterTag) { return TagWidget( - text: FormatUtils.extractNameFromEnum(filterTag), + text: FormatUtils.extractNameFromEnum(filterTag), hexColorCode: Theme.of(context) .colorScheme .primaryContainer @@ -215,6 +211,10 @@ class _ProjectListState extends State { void dispose() { _textChangesSubscription.cancel(); _blocListingStateSubscription.cancel(); + _textChangeStreamController.sink.close(); + _textChangeStreamController.close(); + _bloc.onPageRequestSink.close(); + _bloc.onSearchInputChangedSink.close(); _bloc.dispose(); _pagingController.dispose(); _scrollController.dispose(); diff --git a/lib/widgets/modular_widgets/accelerator_widgets/projects_stats.dart b/lib/widgets/modular_widgets/accelerator_widgets/projects_stats.dart index 72fc446f..d4b695ad 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/projects_stats.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/projects_stats.dart @@ -1,13 +1,7 @@ import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/accelerator_project_details.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/chart_legend.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_pie_chart.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/formatted_amount_with_tooltip.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ProjectsStats extends StatelessWidget { @@ -185,7 +179,7 @@ class ProjectsStats extends StatelessWidget { tokenSymbol: kZnnCoin.symbol, builder: (amount, tokenSymbol) => Text( '$amount $tokenSymbol', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ), ), @@ -198,7 +192,7 @@ class ProjectsStats extends StatelessWidget { tokenSymbol: kZnnCoin.symbol, builder: (amount, tokenSymbol) => Text( '$amount $tokenSymbol', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ), ), @@ -211,7 +205,7 @@ class ProjectsStats extends StatelessWidget { tokenSymbol: kZnnCoin.symbol, builder: (amount, tokenSymbol) => Text( '$amount $tokenSymbol', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ), ), @@ -236,7 +230,7 @@ class ProjectsStats extends StatelessWidget { tokenSymbol: kQsrCoin.symbol, builder: (amount, tokenSymbol) => Text( '$amount $tokenSymbol', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ), ), @@ -249,7 +243,7 @@ class ProjectsStats extends StatelessWidget { tokenSymbol: kQsrCoin.symbol, builder: (amount, tokenSymbol) => Text( '$amount $tokenSymbol', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ), ), @@ -262,7 +256,7 @@ class ProjectsStats extends StatelessWidget { tokenSymbol: kQsrCoin.symbol, builder: (amount, tokenSymbol) => Text( '$amount $tokenSymbol', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ), ), diff --git a/lib/widgets/modular_widgets/accelerator_widgets/update_phase_stepper.dart b/lib/widgets/modular_widgets/accelerator_widgets/update_phase_stepper.dart index d4d43bdb..8a234981 100644 --- a/lib/widgets/modular_widgets/accelerator_widgets/update_phase_stepper.dart +++ b/lib/widgets/modular_widgets/accelerator_widgets/update_phase_stepper.dart @@ -1,24 +1,12 @@ import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/accelerator/update_phase_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/balance_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/stepper_button.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_material_stepper.dart' as custom_material_stepper; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dotted_border_info_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/amount_suffix_widgets.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/stepper_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; enum UpdatePhaseStep { @@ -37,7 +25,7 @@ class UpdatePhaseStepper extends StatefulWidget { }) : super(key: key); @override - _UpdatePhaseStepperState createState() => _UpdatePhaseStepperState(); + State createState() => _UpdatePhaseStepperState(); } class _UpdatePhaseStepperState extends State { @@ -197,7 +185,7 @@ class _UpdatePhaseStepperState extends State { child: Text( 'This phase belongs to Project ID ' '${widget.phase.id.toShortString()}', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), ), ], @@ -244,7 +232,7 @@ class _UpdatePhaseStepperState extends State { kVerticalSpacing, Text( 'Total phase budget', - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), kVerticalSpacing, Form( @@ -408,7 +396,7 @@ class _UpdatePhaseStepperState extends State { Widget _getUpdatePhaseViewModel() { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (event) { if (event != null) { diff --git a/lib/widgets/modular_widgets/bridge_widgets/bridge_widgets.dart b/lib/widgets/modular_widgets/bridge_widgets/bridge_widgets.dart new file mode 100644 index 00000000..f3fab9de --- /dev/null +++ b/lib/widgets/modular_widgets/bridge_widgets/bridge_widgets.dart @@ -0,0 +1 @@ +export 'swap_card.dart'; diff --git a/lib/widgets/modular_widgets/bridge_widgets/dynamic_multiplier_rewards_card.dart b/lib/widgets/modular_widgets/bridge_widgets/dynamic_multiplier_rewards_card.dart deleted file mode 100644 index ff3a740c..00000000 --- a/lib/widgets/modular_widgets/bridge_widgets/dynamic_multiplier_rewards_card.dart +++ /dev/null @@ -1,111 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dotted_border_info_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; - -class DynamicMultiplierRewardsCard extends StatelessWidget { - const DynamicMultiplierRewardsCard({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return CardScaffold( - title: 'Dynamic Multiplier Rewards', - description: - 'The dynamic multiplier is active until the 1.8M QSR liquidity fund is fully distributed', - childBuilder: () => _getCardBody(context), - ); - } - - Widget _getCardBody(BuildContext context) { - return Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 15.0, - ), - child: Row( - children: List.generate( - kLiquidityRewardsMultiplier, - (index) => _getMultiplier( - index + 1, - context, - ), - ), - ), - ), - const Padding( - padding: EdgeInsets.symmetric( - horizontal: 15.0, - ), - child: DottedBorderInfoWidget( - text: - 'Up to 10x daily QSR rewards until the 1.8M QSR liquidity fund is fully distributed', - borderColor: AppColors.qsrColor, - ), - ), - ], - ); - } - - Widget _getMultiplier(int multiplier, BuildContext context) { - Color fillColor = AppColors.qsrColor - .withOpacity(multiplier / kLiquidityRewardsMultiplier); - - return Expanded( - flex: (multiplier + kLiquidityRewardsMultiplier) ~/ 2, - child: Row( - children: [ - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - '${multiplier * 1000}', - style: Theme.of(context).textTheme.bodyText1!.copyWith( - fontSize: 7.0, - ), - ), - SizedBox( - height: kVerticalSpacing.height! / 2, - ), - Container( - width: 3.0, - height: 3.0, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: fillColor, - ), - ), - SizedBox( - height: kVerticalSpacing.height! / 2, - ), - Container( - height: 10.0, - decoration: BoxDecoration( - color: fillColor, - borderRadius: BorderRadius.circular(5.0), - ), - ), - kVerticalSpacing, - Text( - '${multiplier}x', - style: Theme.of(context).textTheme.bodyText1!.copyWith( - fontSize: 7.0, - ), - ), - ], - ), - ), - Visibility( - visible: multiplier < kLiquidityRewardsMultiplier, - child: const SizedBox( - width: 5.0, - ), - ), - ], - ), - ); - } -} diff --git a/lib/widgets/modular_widgets/bridge_widgets/join_liquidity_program_card.dart b/lib/widgets/modular_widgets/bridge_widgets/join_liquidity_program_card.dart deleted file mode 100644 index 65e9437f..00000000 --- a/lib/widgets/modular_widgets/bridge_widgets/join_liquidity_program_card.dart +++ /dev/null @@ -1,117 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/outlined_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_material_stepper.dart' - as custom_material_stepper; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/stepper_utils.dart'; - -enum JoinLiquidityProgramStep { - joinProgram, - addLiquidity, -} - -class JoinLiquidityProgramCard extends StatefulWidget { - const JoinLiquidityProgramCard({Key? key}) : super(key: key); - - @override - State createState() => - _JoinLiquidityProgramCardState(); -} - -class _JoinLiquidityProgramCardState extends State { - JoinLiquidityProgramStep _currentStep = JoinLiquidityProgramStep.values.first; - JoinLiquidityProgramStep? _lastCompletedStep; - - @override - Widget build(BuildContext context) { - return CardScaffold( - title: 'Add Liquidity', - description: 'Become a Liquidity Provider', - childBuilder: () => _getCardBody(context), - ); - } - - Widget _getCardBody(BuildContext context) { - return Theme( - data: Theme.of(context).copyWith( - highlightColor: Colors.transparent, - splashColor: Colors.transparent, - hoverColor: Colors.transparent, - ), - child: custom_material_stepper.Stepper( - activeColor: AppColors.qsrColor, - currentStep: _currentStep.index, - onStepTapped: (int index) {}, - steps: [ - StepperUtils.getMaterialStep( - stepTitle: 'Join the Liquidity Program', - stepContent: Row( - children: [ - MyOutlinedButton( - outlineColor: AppColors.qsrColor, - onPressed: () => NavigationUtils.launchUrl( - kJoinLiquidityProgramUrl, - context, - ).then((value) => _saveProgressAndNavigateToNextStep( - JoinLiquidityProgramStep.joinProgram)), - text: 'Join', - ), - ], - ), - stepSubtitle: '', - stepState: StepperUtils.getStepState( - JoinLiquidityProgramStep.joinProgram.index, - _lastCompletedStep?.index, - ), - context: context, - stepSubtitleColor: AppColors.ztsColor, - expanded: true, - ), - StepperUtils.getMaterialStep( - stepTitle: 'Add Liquidity', - stepContent: Column( - children: [ - Row( - children: [ - MyOutlinedButton( - outlineColor: AppColors.qsrColor, - onPressed: () => NavigationUtils.launchUrl( - kAddLiquidityUrl, - context, - ).then((value) => _saveProgressAndNavigateToNextStep( - JoinLiquidityProgramStep.addLiquidity)), - text: 'Earn LP rewards', - ), - ], - ), - ], - ), - stepSubtitle: '', - stepState: StepperUtils.getStepState( - JoinLiquidityProgramStep.addLiquidity.index, - _lastCompletedStep?.index, - ), - context: context, - stepSubtitleColor: AppColors.ztsColor, - expanded: true, - ), - ], - ), - ); - } - - void _saveProgressAndNavigateToNextStep( - JoinLiquidityProgramStep _completedStep) { - setState(() { - _lastCompletedStep = _completedStep; - if (_lastCompletedStep!.index + 1 < - JoinLiquidityProgramStep.values.length) { - _currentStep = - JoinLiquidityProgramStep.values[_completedStep.index + 1]; - } - }); - } -} diff --git a/lib/widgets/modular_widgets/bridge_widgets/swap_card.dart b/lib/widgets/modular_widgets/bridge_widgets/swap_card.dart index f9549daf..39ef0122 100644 --- a/lib/widgets/modular_widgets/bridge_widgets/swap_card.dart +++ b/lib/widgets/modular_widgets/bridge_widgets/swap_card.dart @@ -1,29 +1,14 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/transfer/send_payment_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/transfer/transfer_widgets_balance_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/available_balance.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/outlined_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dialogs.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dropdown/addresses_dropdown.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dropdown/bridge_network_dropdown.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/amount_suffix_widgets.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class SwapCard extends StatefulWidget { @@ -46,6 +31,9 @@ class _SwapCardState extends State { final SendPaymentBloc _sendPaymentBloc = SendPaymentBloc(); bool? _userHasEnoughBnbBalance = false; + String? _selectedBridge = kBridgeNetworks.first; + final bool _bridgeStatus = false; + final ScrollController _scrollController = ScrollController(); @override @@ -67,11 +55,8 @@ class _SwapCardState extends State { }, onError: (error) { _swapButtonKey.currentState?.animateReverse(); - NotificationUtils.sendNotificationError( - error, - 'Couldn\'t send ${_amountController.text} ${kZnnCoin.symbol} ' - 'to $bridgeAddress', - ); + NotificationUtils.sendNotificationError(error, + 'Couldn\'t send ${_amountController.text} ${kZnnCoin.symbol}'); }, ); } @@ -115,15 +100,6 @@ class _SwapCardState extends State { controller: _scrollController, children: [ _getInputFields(accountInfo), - _getCheckBox(), - _getSwapButton(accountInfo), - kVerticalSpacing, - const Text( - 'Redeem the wZNN if you have already performed the swap', - textAlign: TextAlign.center, - ), - kVerticalSpacing, - _getRedeemButton(), ], ), ), @@ -134,7 +110,12 @@ class _SwapCardState extends State { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - BridgeNetworkDropdown(kBridgeNetworks.first, (value) {}), + BridgeNetworkDropdown( + _selectedBridge, + (value) => setState(() { + _selectedBridge = value; + }), + ), Padding( padding: const EdgeInsets.only( left: 10.0, @@ -216,9 +197,8 @@ class _SwapCardState extends State { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Checkbox( - checkColor: Theme.of(context).scaffoldBackgroundColor, - activeColor: AppColors.znnColor, + SyriusCheckbox( + context: context, value: _userHasEnoughBnbBalance, onChanged: (value) { setState(() { @@ -228,37 +208,14 @@ class _SwapCardState extends State { ), Text( 'I have enough funds to cover the gas fees in order to complete the swap', - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, ) ], ); } - Widget _getSwapButton(AccountInfo accountInfo) { - return Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - LoadingButton( - onPressed: - _isInputValid(accountInfo) && (_userHasEnoughBnbBalance ?? false) - ? _onSwapButtonPressed - : null, - key: _swapButtonKey, - text: 'Swap', - ), - ], - ); - } - void _sendSwapBlock() { _swapButtonKey.currentState?.animateForward(); - _sendPaymentBloc.sendTransfer( - fromAddress: _selectedSelfAddress, - toAddress: bridgeAddress.toString(), - amount: _amountController.text, - data: _decodeEvmAddress(), - token: kZnnCoin, - ); } void _onMaxPressed(AccountInfo accountInfo) => setState(() { @@ -285,11 +242,9 @@ class _SwapCardState extends State { void _sendConfirmationNotification() { sl.get().addNotification( WalletNotification( - title: 'Sent ${_amountController.text} ${kZnnCoin.symbol} ' - 'to $bridgeAddress', + title: 'Sent ${_amountController.text} ${kZnnCoin.symbol}', timestamp: DateTime.now().millisecondsSinceEpoch, - details: 'Sent ${_amountController.text} ${kZnnCoin.symbol} ' - 'from $_selectedSelfAddress to $bridgeAddress', + details: 'Sent ${_amountController.text} ${kZnnCoin.symbol}', type: NotificationType.paymentSent, id: null, ), @@ -314,30 +269,6 @@ class _SwapCardState extends State { return FormatUtils.decodeHexString(hexCharacters); } - Widget _getRedeemButton() { - return Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - MyOutlinedButton( - text: 'Redeem', - onPressed: () => showOkDialog( - context: context, - title: 'Redeem', - description: 'Press OK to open https://bridge.zenon.network/', - onActionButtonPressed: () { - NavigationUtils.launchUrl( - 'https://bridge.zenon.network/', context) - .then( - (value) => Navigator.pop(context), - ); - }, - ), - minimumSize: kLoadingButtonMinSize, - ), - ], - ); - } - @override void dispose() { _amountController.dispose(); diff --git a/lib/widgets/modular_widgets/dashboard_widgets/balance.dart b/lib/widgets/modular_widgets/dashboard_widgets/balance.dart index 53293808..7e58bf66 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/balance.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/balance.dart @@ -2,16 +2,13 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/balance_dashboard_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/color_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/amount_info_column.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_pie_chart.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/formatted_amount_with_tooltip.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; const String _kWidgetTitle = 'Balance'; @@ -24,7 +21,7 @@ class BalanceWidget extends StatefulWidget { }) : super(key: key); @override - _BalanceWidgetState createState() => _BalanceWidgetState(); + State createState() => _BalanceWidgetState(); } class _BalanceWidgetState extends State { @@ -36,14 +33,14 @@ class _BalanceWidgetState extends State { void didChangeDependencies() { super.didChangeDependencies(); _colorAddressPrefixSuffix ??= Theme.of(context).hintColor; - _backgroundAddressColor ??= Theme.of(context).backgroundColor; + _backgroundAddressColor ??= Theme.of(context).colorScheme.background; } @override Widget build(BuildContext context) { return ViewModelBuilder.reactive( viewModelBuilder: () => BalanceDashboardBloc(), - onModelReady: (model) { + onViewModelReady: (model) { model.getDataPeriodically(); }, builder: (_, model, __) => CardScaffold( @@ -204,7 +201,7 @@ class _BalanceWidgetState extends State { tokenStandard, )} ${_touchedTokenStandard == kZnnCoin.tokenStandard.toString() ? kZnnCoin.symbol : kQsrCoin.symbol}', textAlign: TextAlign.center, - style: Theme.of(context).textTheme.headline4!.copyWith( + style: Theme.of(context).textTheme.headlineMedium!.copyWith( color: ColorUtils.getTokenColor(tokenStandard), fontWeight: FontWeight.bold, ), diff --git a/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart b/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart new file mode 100644 index 00000000..d6c30b75 --- /dev/null +++ b/lib/widgets/modular_widgets/dashboard_widgets/dashboard_widgets.dart @@ -0,0 +1,10 @@ +export 'balance.dart'; +export 'delegation_stats.dart'; +export 'dual_coin_stats.dart'; +export 'pillars.dart'; +export 'plasma_stats.dart'; +export 'realtime_statistics.dart'; +export 'sentinels.dart'; +export 'staking.dart'; +export 'total_hourly_transactions.dart'; +export 'transfer.dart'; diff --git a/lib/widgets/modular_widgets/dashboard_widgets/delegation_stats.dart b/lib/widgets/modular_widgets/dashboard_widgets/delegation_stats.dart index afc08998..49a8d569 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/delegation_stats.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/delegation_stats.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/delegation_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; const String _kWidgetTitle = 'Delegation Stats'; @@ -15,7 +15,7 @@ class DelegationStats extends StatefulWidget { const DelegationStats({Key? key}) : super(key: key); @override - _DelegationStatsState createState() => _DelegationStatsState(); + State createState() => _DelegationStatsState(); } class _DelegationStatsState extends State { @@ -23,7 +23,7 @@ class _DelegationStatsState extends State { Widget build(BuildContext context) { return ViewModelBuilder.reactive( viewModelBuilder: () => DelegationBloc(), - onModelReady: (model) { + onViewModelReady: (model) { model.getDataPeriodically(); }, builder: (_, model, __) => CardScaffold( @@ -54,7 +54,7 @@ class _DelegationStatsState extends State { child: Icon( SimpleLineIcons.trophy, size: 12.0, - color: Theme.of(context).textTheme.bodyText1!.color, + color: Theme.of(context).textTheme.bodyLarge!.color, ), ), Container(width: 16.0), @@ -64,11 +64,11 @@ class _DelegationStatsState extends State { children: [ Text( delegationInfo.name.toString(), - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, ), Text( '${delegationInfo.weightWithDecimals.toString()} ${kZnnCoin.symbol}', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ], ), diff --git a/lib/widgets/modular_widgets/dashboard_widgets/dual_coin_stats.dart b/lib/widgets/modular_widgets/dashboard_widgets/dual_coin_stats.dart index 020d6425..f8642177 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/dual_coin_stats.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/dual_coin_stats.dart @@ -1,14 +1,11 @@ import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/dual_coin_stats_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/color_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/amount_info_column.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_pie_chart.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/formatted_amount_with_tooltip.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; const String _kWidgetTitle = 'Dual Coin Stats'; @@ -21,7 +18,7 @@ class DualCoinStats extends StatefulWidget { }) : super(key: key); @override - _DualCoinStatsState createState() => _DualCoinStatsState(); + State createState() => _DualCoinStatsState(); } class _DualCoinStatsState extends State @@ -32,7 +29,7 @@ class _DualCoinStatsState extends State Widget build(BuildContext context) { return ViewModelBuilder.reactive( viewModelBuilder: () => DualCoinStatsBloc(), - onModelReady: (model) { + onViewModelReady: (model) { model.getDataPeriodically(); }, builder: (_, model, __) => CardScaffold>( @@ -112,7 +109,7 @@ class _DualCoinStatsState extends State value: currentTokenInfo.totalSupply / totalSupply, title: currentTokenInfo.symbol, radius: 60.0, - titleStyle: Theme.of(context).textTheme.subtitle2!.copyWith( + titleStyle: Theme.of(context).textTheme.titleSmall!.copyWith( color: Colors.white, ), ); diff --git a/lib/widgets/modular_widgets/dashboard_widgets/pillars.dart b/lib/widgets/modular_widgets/dashboard_widgets/pillars.dart index bb4dd66e..feda883b 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/pillars.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/pillars.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/pillars_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/number_animation.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; const String _kWidgetTitle = 'Pillars'; const String _kWidgetDescription = 'This card displays the number of active ' @@ -15,7 +14,7 @@ class Pillars extends StatefulWidget { }) : super(key: key); @override - _PillarsState createState() => _PillarsState(); + State createState() => _PillarsState(); } class _PillarsState extends State { @@ -23,7 +22,7 @@ class _PillarsState extends State { Widget build(BuildContext context) { return ViewModelBuilder.reactive( viewModelBuilder: () => PillarsBloc(), - onModelReady: (model) { + onViewModelReady: (model) { model.getDataPeriodically(); }, builder: (_, model, __) => CardScaffold( @@ -50,11 +49,11 @@ class _PillarsState extends State { NumberAnimation( end: numOfPillars, isInt: true, - style: Theme.of(context).textTheme.headline2, + style: Theme.of(context).textTheme.headlineMedium, ), Text( 'Active Pillars', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ], ), diff --git a/lib/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart b/lib/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart index 246c0fde..98e6281e 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart @@ -1,14 +1,12 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/plasma/plasma_stats_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/plasma_info_wrapper.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notifiers/plasma_beneficiary_address_notifier.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_table.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/plasma_icon.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; const String kPlasmaStatsWidgetTitle = 'Plasma Stats'; @@ -35,7 +33,7 @@ class PlasmaStats extends StatefulWidget { }) : super(key: key); @override - _PlasmaStatsState createState() => _PlasmaStatsState(); + State createState() => _PlasmaStatsState(); } class _PlasmaStatsState extends State { diff --git a/lib/widgets/modular_widgets/dashboard_widgets/realtime_statistics.dart b/lib/widgets/modular_widgets/dashboard_widgets/realtime_statistics.dart index ce347665..d5d4b2a8 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/realtime_statistics.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/realtime_statistics.dart @@ -1,12 +1,10 @@ import 'package:flutter/material.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/realtime_statistics_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/color_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/charts/realtime_txs_chart.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/chart_legend.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; const String _kWidgetTitle = 'Realtime Stats'; @@ -20,7 +18,7 @@ class RealtimeStatistics extends StatefulWidget { const RealtimeStatistics({Key? key}) : super(key: key); @override - _RealtimeStatisticsState createState() => _RealtimeStatisticsState(); + State createState() => _RealtimeStatisticsState(); } class _RealtimeStatisticsState extends State { @@ -28,7 +26,7 @@ class _RealtimeStatisticsState extends State { Widget build(BuildContext context) { return ViewModelBuilder.reactive( viewModelBuilder: () => RealtimeStatisticsBloc(), - onModelReady: (model) { + onViewModelReady: (model) { model.getDataPeriodically(); }, builder: (_, model, __) => CardScaffold>( diff --git a/lib/widgets/modular_widgets/dashboard_widgets/sentinels.dart b/lib/widgets/modular_widgets/dashboard_widgets/sentinels.dart index 319ed47e..6e85ee4c 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/sentinels.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/sentinels.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/sentinels_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/number_animation.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; const String _kWidgetTitle = 'Sentinels'; @@ -14,7 +13,7 @@ class Sentinels extends StatefulWidget { const Sentinels({Key? key}) : super(key: key); @override - _SentinelsState createState() => _SentinelsState(); + State createState() => _SentinelsState(); } class _SentinelsState extends State { @@ -22,7 +21,7 @@ class _SentinelsState extends State { Widget build(BuildContext context) { return ViewModelBuilder.reactive( viewModelBuilder: () => SentinelsBloc(), - onModelReady: (model) { + onViewModelReady: (model) { model.getDataPeriodically(); }, builder: (_, model, __) => CardScaffold>( @@ -52,11 +51,11 @@ class _SentinelsState extends State { NumberAnimation( end: sentinelsByCycle.length, isInt: true, - style: Theme.of(context).textTheme.headline2, + style: Theme.of(context).textTheme.headlineMedium, ), Text( 'Active Sentinels', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ], ), diff --git a/lib/widgets/modular_widgets/dashboard_widgets/staking.dart b/lib/widgets/modular_widgets/dashboard_widgets/staking.dart index 08130f63..b850fe5c 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/staking.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/staking.dart @@ -1,11 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/staking_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/number_animation.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; const String _kWidgetTitle = 'Staking Stats'; final String _kWidgetDescription = 'This card displays the number of staking ' @@ -15,7 +14,7 @@ class Staking extends StatefulWidget { const Staking({Key? key}) : super(key: key); @override - _StakingState createState() => _StakingState(); + State createState() => _StakingState(); } class _StakingState extends State { @@ -23,7 +22,7 @@ class _StakingState extends State { Widget build(BuildContext context) { return ViewModelBuilder.reactive( viewModelBuilder: () => StakingBloc(), - onModelReady: (model) { + onViewModelReady: (model) { model.getDataPeriodically(); }, builder: (_, model, __) => CardScaffold( @@ -52,7 +51,7 @@ class _StakingState extends State { child: Icon( SimpleLineIcons.energy, size: 12.0, - color: Theme.of(context).textTheme.bodyText1!.color, + color: Theme.of(context).textTheme.bodyLarge!.color, ), ), Container(width: 16.0), @@ -63,11 +62,11 @@ class _StakingState extends State { NumberAnimation( end: stake.numActiveStakingEntries, isInt: true, - style: Theme.of(context).textTheme.headline2, + style: Theme.of(context).textTheme.headlineMedium, ), Text( '${stake.totalZnnStakingAmount.toString()} ${kZnnCoin.symbol}', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ], ), diff --git a/lib/widgets/modular_widgets/dashboard_widgets/swap_decay.dart b/lib/widgets/modular_widgets/dashboard_widgets/swap_decay.dart deleted file mode 100644 index 1c3905ad..00000000 --- a/lib/widgets/modular_widgets/dashboard_widgets/swap_decay.dart +++ /dev/null @@ -1,103 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/number_animation.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; - -const String _kWidgetTitle = 'Swap Decay'; -const String _kWidgetDescription = - 'There will be a total of 10 Swap Cycles spanning over a period of 12 months. ' - 'The Swap Decay mechanism will decrease the amount of the funds that can be ' - 'swapped with each passing cycle until the swap window is closed. Starting ' - 'with Swap Cycle 3, the Swap Ratio will progressively decrease each cycle ' - 'by 10% until it reaches 0: after the last swap cycle is over, it won\'t ' - 'be possible to swap coins from the legacy network anymore'; - -class SwapDecay extends StatelessWidget { - const SwapDecay({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return CardScaffold( - title: _kWidgetTitle, - description: _kWidgetDescription, - childBuilder: () => _getWidgetBody(context), - ); - } - - Widget _getWidgetBody(BuildContext context) { - return _getDurationUntilSwapDecayStarts().inDays > 1 - ? _showHowManyDaysLeftUntilSwapDecayStarts(context) - : _getDurationUntilSwapDecayStarts().inSeconds > 0 - ? _showWhenSwapDecayStarts(context) - : _getSwapDecay(context); - } - - Widget _showHowManyDaysLeftUntilSwapDecayStarts(BuildContext context) { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - NumberAnimation( - end: _getDurationUntilSwapDecayStarts().inDays, - isInt: true, - style: Theme.of(context).textTheme.headline1!.copyWith( - fontSize: 30.0, - ), - ), - kVerticalSpacing, - const Text('days until Swap Decay starts'), - ], - ); - } - - Duration _getDurationUntilSwapDecayStarts() { - return DateTime.fromMillisecondsSinceEpoch( - swapAssetDecayTimestampStart * 1000, - ).difference(DateTime.now()); - } - - Widget _showWhenSwapDecayStarts(BuildContext context) { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - 'At ${FormatUtils.formatDate( - swapAssetDecayTimestampStart * 1000, - dateFormat: '$kDefaultDateFormat HH:mm', - )}', - style: Theme.of(context).textTheme.headline5, - textAlign: TextAlign.center, - ), - kVerticalSpacing, - const Text('Swap Decay will start'), - ], - ); - } - - _getSwapDecay(BuildContext context) { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - '${zenon!.embedded.swap.getSwapDecayPercentage(DateTime.now().millisecondsSinceEpoch ~/ 1000)}%', - style: Theme.of(context).textTheme.headline1!.copyWith( - fontSize: 30.0, - ), - textAlign: TextAlign.center, - ), - ], - ), - kVerticalSpacing, - const Text( - 'current swap cycle decay', - textAlign: TextAlign.center, - ), - ], - ); - } -} diff --git a/lib/widgets/modular_widgets/dashboard_widgets/total_hourly_transactions.dart b/lib/widgets/modular_widgets/dashboard_widgets/total_hourly_transactions.dart index b606428f..b04a20c5 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/total_hourly_transactions.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/total_hourly_transactions.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/total_hourly_transactions_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/number_animation.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; const String _kWidgetTitle = 'Transactions'; const String _kWidgetDescription = 'This card displays the total number of ' @@ -13,7 +12,7 @@ class TotalHourlyTransactions extends StatefulWidget { const TotalHourlyTransactions({Key? key}) : super(key: key); @override - _TotalHourlyTransactionsState createState() => + State createState() => _TotalHourlyTransactionsState(); } @@ -22,7 +21,7 @@ class _TotalHourlyTransactionsState extends State { Widget build(BuildContext context) { return ViewModelBuilder.reactive( viewModelBuilder: () => TotalHourlyTransactionsBloc(), - onModelReady: (model) { + onViewModelReady: (model) { model.getDataPeriodically(); }, builder: (_, model, __) => CardScaffold>( @@ -41,7 +40,7 @@ class _TotalHourlyTransactionsState extends State { NumberAnimation( end: widgetData['numAccountBlocks'], isInt: true, - style: Theme.of(context).textTheme.headline1!.copyWith( + style: Theme.of(context).textTheme.headlineLarge!.copyWith( fontSize: 30.0, ), ), diff --git a/lib/widgets/modular_widgets/dashboard_widgets/transfer.dart b/lib/widgets/modular_widgets/dashboard_widgets/transfer.dart index 71c440ce..b64310c4 100644 --- a/lib/widgets/modular_widgets/dashboard_widgets/transfer.dart +++ b/lib/widgets/modular_widgets/dashboard_widgets/transfer.dart @@ -1,9 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/main_app_container.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/transfer_icon_legend.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; const String _kWidgetTitle = 'Transfer'; const String _kWidgetDescription = @@ -23,7 +21,7 @@ class Transfer extends StatefulWidget { }) : super(key: key); @override - _TransferState createState() => _TransferState(); + State createState() => _TransferState(); } class _TransferState extends State { diff --git a/lib/widgets/modular_widgets/help_widgets/about_card.dart b/lib/widgets/modular_widgets/help_widgets/about_card.dart index 4348fce2..a9ef9f4f 100644 --- a/lib/widgets/modular_widgets/help_widgets/about_card.dart +++ b/lib/widgets/modular_widgets/help_widgets/about_card.dart @@ -1,15 +1,12 @@ import 'dart:io'; import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/settings/general_stats_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/model/general_stats.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_expandable_panel.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_table.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:open_filex/open_filex.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/metadata.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class AboutCard extends StatefulWidget { @@ -26,8 +23,8 @@ class AboutCardState extends State { @override void initState() { - super.initState(); _generalStatsBloc = GeneralStatsBloc(); + super.initState(); } @override @@ -48,16 +45,16 @@ class AboutCardState extends State { _getGenericTextExpandedChild(kWalletVersion), ), CustomExpandablePanel( - 'Zenon Node network identifier', + 'Zenon Node chain identifier', _getGenericTextExpandedChild( generalStats.frontierMomentum.chainIdentifier.toString()), ), CustomExpandablePanel( - 'Client network identifier', - _getGenericTextExpandedChild(netId.toString()), + 'Client chain identifier', + _getGenericTextExpandedChild(getChainIdentifier().toString()), ), CustomExpandablePanel( - 'ZNN SDK version', + 'Zenon SDK version', _getGenericTextExpandedChild(znnSdkVersion), ), CustomExpandablePanel( @@ -68,6 +65,26 @@ class AboutCardState extends State { 'Zenon Node git commit hash', _getGenericTextExpandedChild(generalStats.processInfo.commit), ), + CustomExpandablePanel( + 'Syrius git origin url', + _getGenericLinkButtonExpandedChild(gitOriginUrl), + ), + CustomExpandablePanel( + 'Syrius git branch name', + _getGenericTextExpandedChild(gitBranchName), + ), + CustomExpandablePanel( + 'Syrius git commit hash', + _getGenericTextExpandedChild(gitCommitHash), + ), + CustomExpandablePanel( + 'Syrius git commit message', + _getGenericTextExpandedChild(gitCommitMessage), + ), + CustomExpandablePanel( + 'Syrius git commit date', + _getGenericTextExpandedChild(gitCommitDate), + ), CustomExpandablePanel( 'Zenon Node kernel version', _getGenericTextExpandedChild(generalStats.osInfo.kernelVersion), @@ -90,18 +107,18 @@ class AboutCardState extends State { ), CustomExpandablePanel( 'Zenon main data path', - _getGenericTextExpandedChild( - znnDefaultPaths.main.absolute.toString()), + _getGenericOpenButtonExpandedChild( + znnDefaultPaths.main.absolute.path), ), CustomExpandablePanel( - 'syrius cache path', - _getGenericTextExpandedChild( - znnDefaultPaths.cache.absolute.toString()), + 'Syrius cache path', + _getGenericOpenButtonExpandedChild( + znnDefaultPaths.cache.absolute.path), ), CustomExpandablePanel( - 'syrius wallet path', - _getGenericTextExpandedChild( - znnDefaultPaths.wallet.absolute.toString()), + 'Syrius wallet path', + _getGenericOpenButtonExpandedChild( + znnDefaultPaths.wallet.absolute.path), ), CustomExpandablePanel( 'Client hostname', @@ -123,10 +140,6 @@ class AboutCardState extends State { 'Client number of processors', _getGenericTextExpandedChild(Platform.numberOfProcessors.toString()), ), - CustomExpandablePanel( - 'ZNN bridge address', - _getGenericTextExpandedChild(bridgeAddress.toString()), - ), ], ); } @@ -139,6 +152,44 @@ class AboutCardState extends State { ]); } + Widget _getGenericLinkButtonExpandedChild(String url) { + return Row(children: [ + CustomTableCell.withMarquee( + url.toString(), + ), + IconButton( + splashRadius: 16, + onPressed: () async { + NavigationUtils.openUrl(url, context); + }, + icon: const Icon( + Icons.link, + size: 16, + color: AppColors.znnColor, + ), + ), + ]); + } + + Widget _getGenericOpenButtonExpandedChild(String expandedText) { + return Row(children: [ + CustomTableCell.withMarquee( + expandedText.toString(), + ), + IconButton( + splashRadius: 16, + onPressed: () async { + await OpenFilex.open(expandedText); + }, + icon: const Icon( + Icons.open_in_new, + size: 16, + color: AppColors.znnColor, + ), + ), + ]); + } + Widget _getStreamBuilder() { return StreamBuilder( stream: _generalStatsBloc!.stream, diff --git a/lib/widgets/modular_widgets/help_widgets/community_card.dart b/lib/widgets/modular_widgets/help_widgets/community_card.dart index 8a9ad576..96fb3bc6 100644 --- a/lib/widgets/modular_widgets/help_widgets/community_card.dart +++ b/lib/widgets/modular_widgets/help_widgets/community_card.dart @@ -3,8 +3,7 @@ import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_expandable_panel.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class CommunityCard extends StatelessWidget { const CommunityCard({Key? key}) : super(key: key); @@ -21,100 +20,120 @@ class CommunityCard extends StatelessWidget { Widget _getWidgetBody(BuildContext context) { return ListView( + physics: const ClampingScrollPhysics(), shrinkWrap: true, children: [ CustomExpandablePanel( 'Websites', _getWebsitesExpandableChild(context), ), + CustomExpandablePanel( + 'Explorers', + _getExplorersExpandableChild(context), + ), CustomExpandablePanel( 'Social Media', _getSocialMediaExpandableChild(context), ), + CustomExpandablePanel( + 'Documentation', + _getDocumentationExpandableChild(context), + ), ], ); } Widget _getWebsitesExpandableChild(BuildContext context) { return ListView( + physics: const ClampingScrollPhysics(), shrinkWrap: true, children: [ _getListViewChild( - iconData: MaterialCommunityIcons.web, + iconData: MaterialCommunityIcons.home, title: 'Zenon Network', url: kWebsite, context: context, ), _getListViewChild( - iconData: Icons.explore, - title: 'Zenon Explorer', - url: kExplorer, - context: context, - ), - _getListViewChild( - iconData: MaterialCommunityIcons.cube, - title: 'Zenonscraper', - url: kScraper, + iconData: MaterialCommunityIcons.forum, + title: 'Zenon ORG Community Forum', + url: kOrgCommunityForum, context: context, ), _getListViewChild( - iconData: MaterialCommunityIcons.book_multiple, - title: 'Zenon Wiki', - url: kWiki, + iconData: MaterialCommunityIcons.tools, + title: 'Zenon Tools', + url: kTools, context: context, ), _getListViewChild( - iconData: MaterialCommunityIcons.book, - title: 'Zenon Community Wiki', - url: kCommunityWiki, + iconData: MaterialCommunityIcons.web, + title: 'Zenon ORG Community', + url: kOrgCommunityWebsite, context: context, ), _getListViewChild( - iconData: MaterialCommunityIcons.tools, - title: 'Zenon Tools', - url: kTools, + iconData: MaterialCommunityIcons.lan, + title: 'Zenon Hub', + url: kHubCommunityWebsite, context: context, ), + ], + ); + } + + Widget _getExplorersExpandableChild(BuildContext context) { + return ListView( + physics: const ClampingScrollPhysics(), + shrinkWrap: true, + children: [ _getListViewChild( - iconData: MaterialCommunityIcons.human_greeting, - title: 'Zenon Community', - url: kCommunityWebsite, + iconData: Icons.explore, + title: 'Zenon Explorer', + url: kExplorer, context: context, ), _getListViewChild( - iconData: MaterialCommunityIcons.web_box, - title: 'ZenonORG Community', - url: kOrgCommunityWebsite, + iconData: Icons.explore_off_outlined, + title: 'Zenon Hub Explorer', + url: kHubCommunityExplorer, context: context, - ), + ) ], ); } Widget _getSocialMediaExpandableChild(BuildContext context) { return ListView( + physics: const ClampingScrollPhysics(), shrinkWrap: true, children: [ _getListViewChild( - iconData: SimpleLineIcons.social_twitter, + iconData: MaterialCommunityIcons.twitter, title: 'Zenon Twitter', url: kTwitter, context: context, ), _getListViewChild( - iconData: Icons.article, - title: 'Zenon Medium', - url: kMedium, + iconData: MaterialCommunityIcons.discord, + title: 'Zenon Discord', + url: kDiscord, context: context, ), _getListViewChild( - iconData: MaterialCommunityIcons.telegram, + iconData: Icons.telegram, title: 'Zenon Telegram', url: kTelegram, context: context, ), _getListViewChild( - iconData: SimpleLineIcons.social_github, + iconData: Icons.article, + title: 'Zenon Medium', + url: kMedium, + context: context, + ), + _getListViewChild( + iconData: MaterialCommunityIcons.github, title: 'Zenon Github', url: kGithub, context: context, @@ -125,12 +144,6 @@ class CommunityCard extends StatelessWidget { url: kBitcoinTalk, context: context, ), - _getListViewChild( - iconData: MaterialCommunityIcons.discord, - title: 'Zenon Discord', - url: kDiscord, - context: context, - ), _getListViewChild( iconData: MaterialCommunityIcons.reddit, title: 'Zenon Reddit', @@ -147,6 +160,33 @@ class CommunityCard extends StatelessWidget { ); } + Widget _getDocumentationExpandableChild(BuildContext context) { + return ListView( + physics: const ClampingScrollPhysics(), + shrinkWrap: true, + children: [ + _getListViewChild( + iconData: MaterialCommunityIcons.book_open_page_variant, + title: 'Zenon Wiki', + url: kWiki, + context: context, + ), + _getListViewChild( + iconData: MaterialCommunityIcons.book_multiple, + title: 'ZenonORG Community Wiki', + url: kOrgCommunityWiki, + context: context, + ), + _getListViewChild( + iconData: MaterialCommunityIcons.file_document, + title: 'Zenon Whitepaper', + url: kWhitepaper, + context: context, + ), + ], + ); + } + Widget _getListViewChild({ required IconData iconData, required String title, @@ -164,11 +204,9 @@ class CommunityCard extends StatelessWidget { const SizedBox( width: 10.0, ), - Expanded( - child: Text( - title, - style: Theme.of(context).textTheme.subtitle1, - ), + Text( + title, + style: Theme.of(context).textTheme.titleMedium, ), const SizedBox( width: 10.0, @@ -180,7 +218,7 @@ class CommunityCard extends StatelessWidget { ), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, shape: const CircleBorder(), - onPressed: () => NavigationUtils.launchUrl(url, context), + onPressed: () => NavigationUtils.openUrl(url, context), child: Container( height: 25.0, width: 25.0, diff --git a/lib/widgets/modular_widgets/help_widgets/help_widgets.dart b/lib/widgets/modular_widgets/help_widgets/help_widgets.dart new file mode 100644 index 00000000..77f3f1fa --- /dev/null +++ b/lib/widgets/modular_widgets/help_widgets/help_widgets.dart @@ -0,0 +1,3 @@ +export 'about_card.dart'; +export 'community_card.dart'; +export 'update_card.dart'; diff --git a/lib/widgets/modular_widgets/help_widgets/update_card.dart b/lib/widgets/modular_widgets/help_widgets/update_card.dart index a55aad68..cd987b98 100644 --- a/lib/widgets/modular_widgets/help_widgets/update_card.dart +++ b/lib/widgets/modular_widgets/help_widgets/update_card.dart @@ -1,9 +1,7 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/settings_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_expandable_panel.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class UpdateCard extends StatelessWidget { const UpdateCard({Key? key}) : super(key: key); @@ -32,8 +30,7 @@ class UpdateCard extends StatelessWidget { Widget _getCheckUpdateExpandableChild(BuildContext context) { return Center( child: SettingsButton( - onPressed: () => - NavigationUtils.launchUrl(kGithubReleasesLink, context), + onPressed: () => NavigationUtils.openUrl(kGithubReleasesLink, context), text: 'Update', ), ); diff --git a/lib/widgets/modular_widgets/modular_widgets.dart b/lib/widgets/modular_widgets/modular_widgets.dart new file mode 100644 index 00000000..9d078502 --- /dev/null +++ b/lib/widgets/modular_widgets/modular_widgets.dart @@ -0,0 +1,11 @@ +export 'accelerator_widgets/accelerator_widgets.dart'; +export 'bridge_widgets/bridge_widgets.dart'; +export 'dashboard_widgets/dashboard_widgets.dart'; +export 'help_widgets/help_widgets.dart'; +export 'pillars_widgets/pillars_widgets.dart'; +export 'plasma_widgets/plasma_widgets.dart'; +export 'sentinel_widgets/sentinel_widgets.dart'; +export 'settings_widgets/settings_widgets.dart'; +export 'staking_widgets/staking_widgets.dart'; +export 'token_widgets/token_widgets.dart'; +export 'transfer_widgets/transfer_widgets.dart'; diff --git a/lib/widgets/modular_widgets/pillars_widgets/create_pillar.dart b/lib/widgets/modular_widgets/pillars_widgets/create_pillar.dart index 7d6f3dc2..5c3aa018 100644 --- a/lib/widgets/modular_widgets/pillars_widgets/create_pillar.dart +++ b/lib/widgets/modular_widgets/pillars_widgets/create_pillar.dart @@ -1,16 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:lottie/lottie.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pillars/get_pillar_by_owner_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/stepper_screen.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/pillars_widgets/pillar_update_stepper.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/pillars_widgets/pillars_stepper_container.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/elevated_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class CreatePillar extends StatefulWidget { @@ -110,7 +105,7 @@ class _CreatePillarState extends State { children: [ Text( 'Update Pillar settings', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), kVerticalSpacing, Row( diff --git a/lib/widgets/modular_widgets/pillars_widgets/pillar_collect.dart b/lib/widgets/modular_widgets/pillars_widgets/pillar_collect.dart index 10747007..db76b88e 100644 --- a/lib/widgets/modular_widgets/pillars_widgets/pillar_collect.dart +++ b/lib/widgets/modular_widgets/pillars_widgets/pillar_collect.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pillars/pillar_rewards_history_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pillars/pillar_uncollected_rewards_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; @@ -8,11 +7,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/number_animation.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PillarCollect extends StatefulWidget { @@ -24,7 +19,7 @@ class PillarCollect extends StatefulWidget { }) : super(key: key); @override - _PillarCollectState createState() => _PillarCollectState(); + State createState() => _PillarCollectState(); } class _PillarCollectState extends State { @@ -78,7 +73,7 @@ class _PillarCollectState extends State { ), isInt: false, after: ' ${kZnnCoin.symbol}', - style: Theme.of(context).textTheme.headline1!.copyWith( + style: Theme.of(context).textTheme.headlineLarge!.copyWith( color: AppColors.znnColor, fontSize: 30.0, ), diff --git a/lib/widgets/modular_widgets/pillars_widgets/pillar_rewards.dart b/lib/widgets/modular_widgets/pillars_widgets/pillar_rewards.dart index dd190045..89bdb140 100644 --- a/lib/widgets/modular_widgets/pillars_widgets/pillar_rewards.dart +++ b/lib/widgets/modular_widgets/pillars_widgets/pillar_rewards.dart @@ -1,9 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pillars/pillar_rewards_history_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/charts/pillar_rewards_chart.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PillarRewards extends StatefulWidget { diff --git a/lib/widgets/modular_widgets/pillars_widgets/pillar_update_stepper.dart b/lib/widgets/modular_widgets/pillars_widgets/pillar_update_stepper.dart index 8d49ee7f..b801345a 100644 --- a/lib/widgets/modular_widgets/pillars_widgets/pillar_update_stepper.dart +++ b/lib/widgets/modular_widgets/pillars_widgets/pillar_update_stepper.dart @@ -1,18 +1,14 @@ import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pillars/update_pillar_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/stepper_button.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_material_stepper.dart' as custom_material_stepper; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_slider.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/stepper_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; enum PillarUpdateStep { @@ -27,7 +23,7 @@ class PillarUpdateStepper extends StatefulWidget { const PillarUpdateStepper(this.pillarInfo, {Key? key}) : super(key: key); @override - _PillarUpdateStepperState createState() => _PillarUpdateStepperState(); + State createState() => _PillarUpdateStepperState(); } class _PillarUpdateStepperState extends State { @@ -164,7 +160,7 @@ class _PillarUpdateStepperState extends State { children: [ Text( 'Pillar name', - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), kVerticalSpacing, InputField( @@ -174,7 +170,7 @@ class _PillarUpdateStepperState extends State { kVerticalSpacing, Text( 'Pillar reward address', - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), kVerticalSpacing, Form( @@ -194,7 +190,7 @@ class _PillarUpdateStepperState extends State { kVerticalSpacing, Text( 'Pillar producer address', - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), kVerticalSpacing, Form( @@ -249,7 +245,7 @@ class _PillarUpdateStepperState extends State { children: [ Text( 'Percentage of momentum rewards given to the delegators', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), ], ), @@ -270,11 +266,11 @@ class _PillarUpdateStepperState extends State { children: [ Text( 'Pillar: ${100 - _momentumRewardPercentageGiven.toInt()}', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), Text( 'Delegators: ${_momentumRewardPercentageGiven.toInt()}', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ], ), @@ -284,7 +280,7 @@ class _PillarUpdateStepperState extends State { children: [ Text( 'Percentage of delegation rewards given to the delegators', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), ], ), @@ -305,11 +301,11 @@ class _PillarUpdateStepperState extends State { children: [ Text( 'Pillar: ${100 - _delegateRewardPercentageGiven.toInt()}', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), Text( 'Delegators: ${_delegateRewardPercentageGiven.toInt()}', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ], ), @@ -388,7 +384,7 @@ class _PillarUpdateStepperState extends State { Widget _getUpdatePillarViewModel() { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (event) { if (event != null) { diff --git a/lib/widgets/modular_widgets/pillars_widgets/pillars_list_widget.dart b/lib/widgets/modular_widgets/pillars_widgets/pillars_list_widget.dart index b4533dba..9e529ac7 100644 --- a/lib/widgets/modular_widgets/pillars_widgets/pillars_list_widget.dart +++ b/lib/widgets/modular_widgets/pillars_widgets/pillars_list_widget.dart @@ -4,12 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/balance_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pillars/delegate_button_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pillars/delegation_info_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pillars/disassemble_pillar_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pillars/pillars_list_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pillars/undelegate_button_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; @@ -17,15 +12,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/outlined_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/cancel_timer.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/formatted_amount_with_tooltip.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/standard_tooltip_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/infinite_scroll_table.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PillarsListWidget extends StatefulWidget { @@ -34,7 +21,7 @@ class PillarsListWidget extends StatefulWidget { const PillarsListWidget({Key? key, this.title}) : super(key: key); @override - _PillarsListWidgetState createState() => _PillarsListWidgetState(); + State createState() => _PillarsListWidgetState(); } class _PillarsListWidgetState extends State { @@ -127,7 +114,7 @@ class _PillarsListWidgetState extends State { Widget _getTable(PillarsListBloc bloc) { return Column( children: [ - _getTableHeader(), + _getTableHeader(bloc), Expanded( child: Scrollbar( controller: _scrollController, @@ -155,7 +142,7 @@ class _PillarsListWidgetState extends State { ); } - Container _getTableHeader() { + Container _getTableHeader(PillarsListBloc bloc) { return Container( decoration: BoxDecoration( border: Border( @@ -169,44 +156,59 @@ class _PillarsListWidgetState extends State { vertical: 15.0, ), child: Row( - children: List.from( + children: List.from( + [ + const SizedBox( + width: 20.0, + ) + ], + ) + [ + InfiniteScrollTableHeaderColumn( + columnName: 'Name', + onSortArrowsPressed: _onSortArrowsPressed, + ), + InfiniteScrollTableHeaderColumn( + columnName: 'Producer Address', + onSortArrowsPressed: _onSortArrowsPressed, + flex: 3, + ), + InfiniteScrollTableHeaderColumn( + columnName: 'Weight', + onSortArrowsPressed: _onSortArrowsPressed, + ), + const InfiniteScrollTableHeaderColumn(columnName: 'Delegation'), + const InfiniteScrollTableHeaderColumn( + columnName: 'Momentum reward'), + const InfiniteScrollTableHeaderColumn( + columnName: 'Delegation reward'), + const InfiniteScrollTableHeaderColumn( + columnName: 'Expected/produced momentums', + ), + const InfiniteScrollTableHeaderColumn( + columnName: 'Uptime', + ), + const InfiniteScrollTableHeaderColumn( + columnName: '', + flex: 1, + ), const SizedBox( - width: 20.0, + width: 5.0, ) - ], - ) + - [ - InfiniteScrollTableHeaderColumn( - columnName: 'Name', - onSortArrowsPressed: _onSortArrowsPressed, - ), - InfiniteScrollTableHeaderColumn( - columnName: 'Producer Address', - onSortArrowsPressed: _onSortArrowsPressed, - flex: 3, - ), - InfiniteScrollTableHeaderColumn( - columnName: 'Weight', - onSortArrowsPressed: _onSortArrowsPressed, - ), - const InfiniteScrollTableHeaderColumn(columnName: 'Delegation'), - const InfiniteScrollTableHeaderColumn( - columnName: 'Momentum reward'), - const InfiniteScrollTableHeaderColumn( - columnName: 'Delegation reward'), - const InfiniteScrollTableHeaderColumn( - columnName: 'Expected/produced momentums', - ), - const InfiniteScrollTableHeaderColumn( - columnName: 'Uptime', - ), - const InfiniteScrollTableHeaderColumn( - columnName: '', - flex: 2, - ), - ], - ), + ] + + [ + SizedBox( + width: 110, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Visibility( + visible: _delegationInfo?.name != null, + child: _getUndelegateButtonViewModel(bloc), + ), + ])), + ]), ); } @@ -247,15 +249,19 @@ class _PillarsListWidgetState extends State { ), ), child: Row( - children: List.from( + children: List.from( + [ + const SizedBox( + width: 20.0, + ) + ], + ) + + generateRowCells(item, isSelected) + [ const SizedBox( - width: 20.0, + width: 110, ) - ], - ) + - generateRowCells(item, isSelected), - ), + ]), ), ); } @@ -293,7 +299,7 @@ class _PillarsListWidgetState extends State { tokenSymbol: kZnnCoin.symbol, builder: (formattedAmount, tokenSymbol) => Text( '$formattedAmount $tokenSymbol', - style: Theme.of(context).textTheme.subtitle1!.copyWith( + style: Theme.of(context).textTheme.titleMedium!.copyWith( color: _isStakeAddressDefault(pillarInfo) ? AppColors.znnColor : AppColors.subtitleColor, @@ -309,11 +315,11 @@ class _PillarsListWidgetState extends State { ), InfiniteScrollTableCell.withText( context, - pillarInfo.giveMomentumRewardPercentage.toString() + ' %', + '${pillarInfo.giveMomentumRewardPercentage} %', ), InfiniteScrollTableCell.withText( context, - pillarInfo.giveDelegateRewardPercentage.toString() + ' %', + '${pillarInfo.giveDelegateRewardPercentage} %', ), InfiniteScrollTableCell.withText(context, '${pillarInfo.expectedMomentums}/${pillarInfo.producedMomentums} '), @@ -327,7 +333,6 @@ class _PillarsListWidgetState extends State { pillarInfo, _pillarsListBloc, ), - flex: 2, ), ]; } @@ -367,8 +372,8 @@ class _PillarsListWidgetState extends State { model.votePillar(pillarInfo.name, context); }, text: 'DELEGATE', - textStyle: Theme.of(context).textTheme.subtitle2!.copyWith( - color: Theme.of(context).textTheme.bodyText1!.color, + textStyle: Theme.of(context).textTheme.titleSmall!.copyWith( + color: Theme.of(context).textTheme.bodyLarge!.color, ), key: key, ); @@ -397,32 +402,37 @@ class _PillarsListWidgetState extends State { width: 5.0, ), ), - pillarItem.isRevocable - ? CancelTimer( - Duration( - seconds: pillarItem.revokeCooldown, - ), - AppColors.znnColor, - onTimeFinishedCallback: () { - model.refreshResults(); - }, - ) - : CancelTimer( - Duration( - seconds: pillarItem.revokeCooldown, + Expanded( + child: pillarItem.isRevocable + ? CancelTimer( + Duration( + seconds: pillarItem.revokeCooldown, + ), + AppColors.znnColor, + onTimeFinishedCallback: () { + model.refreshResults(); + }, + ) + : CancelTimer( + Duration( + seconds: pillarItem.revokeCooldown, + ), + AppColors.errorColor, + onTimeFinishedCallback: () { + model.refreshResults(); + }, ), - AppColors.errorColor, - onTimeFinishedCallback: () { - model.refreshResults(); - }, - ), - StandardTooltipIcon( - pillarItem.isRevocable - ? 'Revocation window is open' - : 'Until revocation window opens', - iconColor: pillarItem.isRevocable - ? AppColors.znnColor - : AppColors.errorColor, + ), + Expanded( + child: StandardTooltipIcon( + pillarItem.isRevocable + ? 'Revocation window is open' + : 'Until revocation window opens', + Icons.help, + iconColor: pillarItem.isRevocable + ? AppColors.znnColor + : AppColors.errorColor, + ), ), ], ), @@ -435,7 +445,7 @@ class _PillarsListWidgetState extends State { PillarInfo pillarInfo, ) { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (event) { if (event != null) { @@ -478,7 +488,7 @@ class _PillarsListWidgetState extends State { minimumSize: const Size(55.0, 25.0), outlineColor: isSelected ? AppColors.errorColor - : Theme.of(context).textTheme.subtitle2!.color, + : Theme.of(context).textTheme.titleSmall!.color, onPressed: isSelected ? () { model.disassemblePillar( @@ -493,10 +503,10 @@ class _PillarsListWidgetState extends State { Text( 'DISASSEMBLE', style: isSelected - ? Theme.of(context).textTheme.subtitle2!.copyWith( - color: Theme.of(context).textTheme.bodyText1!.color, + ? Theme.of(context).textTheme.titleSmall!.copyWith( + color: Theme.of(context).textTheme.bodyLarge!.color, ) - : Theme.of(context).textTheme.subtitle2, + : Theme.of(context).textTheme.titleSmall, ), const SizedBox( width: 20.0, @@ -506,7 +516,7 @@ class _PillarsListWidgetState extends State { size: 11.0, color: isSelected ? AppColors.errorColor - : Theme.of(context).textTheme.subtitle2!.color, + : Theme.of(context).textTheme.titleSmall!.color, ), ], ), @@ -523,8 +533,8 @@ class _PillarsListWidgetState extends State { model.cancelPillarVoting(context); }, text: 'UNDELEGATE', - textStyle: Theme.of(context).textTheme.subtitle2!.copyWith( - color: Theme.of(context).textTheme.bodyText1!.color, + textStyle: Theme.of(context).textTheme.titleSmall!.copyWith( + color: Theme.of(context).textTheme.bodyLarge!.color, ), outlineColor: AppColors.errorColor, key: key, @@ -563,19 +573,19 @@ class _PillarsListWidgetState extends State { } Widget _getUndelegateButtonViewModel(PillarsListBloc pillarsModel) { - final GlobalKey _undelegateButtonKey = GlobalKey(); + final GlobalKey undelegateButtonKey = GlobalKey(); return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (event) { if (event != null) { - _undelegateButtonKey.currentState?.animateReverse(); + undelegateButtonKey.currentState?.animateReverse(); _delegationInfoBloc.updateStream(); } }, onError: (error) { - _undelegateButtonKey.currentState?.animateReverse(); + undelegateButtonKey.currentState?.animateReverse(); NotificationUtils.sendNotificationError( error, 'Error while undelegating', @@ -585,7 +595,7 @@ class _PillarsListWidgetState extends State { }, builder: (_, model, __) => _getUndelegateButton( model, - _undelegateButtonKey, + undelegateButtonKey, ), viewModelBuilder: () => UndelegateButtonBloc(), ); @@ -621,13 +631,13 @@ class _PillarsListWidgetState extends State { PillarsListBloc pillarsModel, AccountInfo accountInfo, ) { - GlobalKey _delegateButtonKey; + GlobalKey delegateButtonKey; if (_delegateButtonKeys[pillarInfo.name] == null) { _delegateButtonKeys[pillarInfo.name] = GlobalKey(); } - _delegateButtonKey = _delegateButtonKeys[pillarInfo.name]!; + delegateButtonKey = _delegateButtonKeys[pillarInfo.name]!; return Visibility( visible: accountInfo.znn()!.addDecimals( @@ -638,19 +648,19 @@ class _PillarsListWidgetState extends State { ? true : _currentlyDelegatingToPillar == pillarInfo.name), child: ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (event) { if (event != null) { _delegationInfoBloc.updateStream(); - _delegateButtonKey.currentState?.animateReverse(); + delegateButtonKey.currentState?.animateReverse(); setState(() { _currentlyDelegatingToPillar = null; }); } }, onError: (error) { - _delegateButtonKey.currentState?.animateReverse(); + delegateButtonKey.currentState?.animateReverse(); NotificationUtils.sendNotificationError( error, 'Pillar delegation error', @@ -664,7 +674,7 @@ class _PillarsListWidgetState extends State { builder: (_, model, __) => _getDelegateButton( pillarInfo, model, - _delegateButtonKey, + delegateButtonKey, ), viewModelBuilder: () => DelegateButtonBloc(), ), diff --git a/lib/widgets/modular_widgets/pillars_widgets/pillars_stepper_container.dart b/lib/widgets/modular_widgets/pillars_widgets/pillars_stepper_container.dart index 1c68c5b8..481fe565 100644 --- a/lib/widgets/modular_widgets/pillars_widgets/pillars_stepper_container.dart +++ b/lib/widgets/modular_widgets/pillars_widgets/pillars_stepper_container.dart @@ -6,15 +6,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:lottie/lottie.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/balance_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pillars/get_legacy_pillars_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pillars/pillars_deploy_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pillars/pillars_deposit_qsr_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pillars/pillars_qsr_info_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pillars/pillars_withdraw_qsr_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/swap/read_wallet_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/pillars_qsr_info.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; @@ -24,35 +18,18 @@ import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/available_balance.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/stepper_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_pie_chart.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_material_stepper.dart' as custom_material_stepper; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_slider.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dotted_border_info_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/standard_tooltip_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/disabled_address_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/password_input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/plasma_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/select_file_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/stepper_utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; -import 'package:znn_swap_utility/znn_swap_utility.dart'; enum PillarType { regularPillar, - legacyPillar, } enum PillarsStepperStep { checkPlasma, selectPillarType, - checkForLegacyPillar, qsrManagement, znnManagement, deployPillar, @@ -104,16 +81,6 @@ class _MainPillarsState extends State { late PillarsQsrInfoBloc _pillarsQsrInfoViewModel; - String _password = ''; - String _checkForLegacyPillarStepSubtitle = 'Step skipped'; - String? _walletPath; - - final List _foundLegacyPillarSwapFileEntries = []; - List _decryptWalletResults = []; - SwapFileEntry? _selectedLegacyPillarSwapFileEntry; - - List? _legacyPillars; - double _momentumRewardPercentageGiven = 0.0; double _delegateRewardPercentageGiven = 0.0; @@ -155,7 +122,7 @@ class _MainPillarsState extends State { Widget _getQsrManagementStep(BuildContext context, AccountInfo accountInfo) { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { _pillarsQsrInfoViewModel = model; model.getQsrManagementInfo( _selectedPillarType, @@ -312,7 +279,7 @@ class _MainPillarsState extends State { visible: qsrInfo.deposit > 0, child: Container( decoration: BoxDecoration( - color: Theme.of(context).backgroundColor, + color: Theme.of(context).colorScheme.background, borderRadius: BorderRadius.circular(6), ), margin: const EdgeInsets.only( @@ -356,7 +323,7 @@ class _MainPillarsState extends State { Text( 'Current Pillar Slot fee\n${qsrInfo.cost} ' '${kQsrCoin.symbol}', - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, textAlign: TextAlign.center, ), ], @@ -372,7 +339,7 @@ class _MainPillarsState extends State { 'You have deposited ${qsrInfo.deposit} ' '${kQsrCoin.symbol}', textAlign: TextAlign.center, - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), ), kVerticalSpacing, @@ -393,7 +360,7 @@ class _MainPillarsState extends State { Widget _getDepositQsrViewModel(PillarsQsrInfo qsrInfo) { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (response) { if (response != null) { @@ -439,7 +406,7 @@ class _MainPillarsState extends State { num qsrDeposit, ) { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (event) { if (event != null) { @@ -512,17 +479,6 @@ class _MainPillarsState extends State { ), context: context, ), - StepperUtils.getMaterialStep( - stepTitle: 'Check for Legacy Pillar', - stepContent: _getCheckForLegacyPillarStepBody(), - stepSubtitle: _checkForLegacyPillarStepSubtitle, - stepState: StepperUtils.getStepState( - PillarsStepperStep.checkForLegacyPillar.index, - _lastCompletedStep?.index, - ), - context: context, - expanded: true, - ), StepperUtils.getMaterialStep( stepTitle: '${kQsrCoin.symbol} management', stepContent: _getQsrManagementStep(context, accountInfo), @@ -561,8 +517,6 @@ class _MainPillarsState extends State { String _getPillarTypeStepSubtitle() { switch (_selectedPillarType) { - case PillarType.legacyPillar: - return 'Legacy Pillar'; case PillarType.regularPillar: return 'Pillar'; default: @@ -589,7 +543,7 @@ class _MainPillarsState extends State { children: [ Text( kQsrCoin.symbol, - style: Theme.of(context).textTheme.subtitle2!.copyWith( + style: Theme.of(context).textTheme.titleSmall!.copyWith( color: Colors.white, ), ), @@ -653,6 +607,7 @@ class _MainPillarsState extends State { ), const StandardTooltipIcon( 'The address that will be able to collect the Pillar rewards', + Icons.help, ), ], ), @@ -677,6 +632,7 @@ class _MainPillarsState extends State { ), const StandardTooltipIcon( 'The address that will produce momentums, get it from znn-controller', + Icons.help, ), ], ), @@ -693,7 +649,7 @@ class _MainPillarsState extends State { Widget _getDeployButton() { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (response) { if (response != null) { @@ -749,7 +705,7 @@ class _MainPillarsState extends State { child: InputField( enabled: false, controller: _znnAmountController, - validator: InputValidators.validateNumber, + validator: InputValidators.validateAmount, ), ), ], @@ -774,19 +730,17 @@ class _MainPillarsState extends State { PillarsDepositQsrBloc model, PillarsQsrInfo qsrInfo, ) { - if (_lastCompletedStep == PillarsStepperStep.checkForLegacyPillar) { - if (qsrInfo.deposit >= qsrInfo.cost) { - _depositQsrButtonKey.currentState?.animateForward(); - model.depositQsr( - _qsrAmountController.text, - justMarkStepCompleted: true, - ); - } else if (qsrInfo.deposit + _maxQsrAmount! <= qsrInfo.cost && - _qsrFormKey.currentState!.validate() && - _qsrAmountController.text.toNum() > 0) { - _depositQsrButtonKey.currentState?.animateForward(); - model.depositQsr(_qsrAmountController.text); - } + if (qsrInfo.deposit >= qsrInfo.cost) { + _depositQsrButtonKey.currentState?.animateForward(); + model.depositQsr( + _qsrAmountController.text, + justMarkStepCompleted: true, + ); + } else if (qsrInfo.deposit + _maxQsrAmount! <= qsrInfo.cost && + _qsrFormKey.currentState!.validate() && + _qsrAmountController.text.toNum() > 0) { + _depositQsrButtonKey.currentState?.animateForward(); + model.depositQsr(_qsrAmountController.text); } } @@ -816,11 +770,6 @@ class _MainPillarsState extends State { blockProducingAddress: _pillarMomentumController.text, giveBlockRewardPercentage: _momentumRewardPercentageGiven.toInt(), giveDelegateRewardPercentage: _delegateRewardPercentageGiven.toInt(), - signature: _selectedLegacyPillarSwapFileEntry?.signLegacyPillar( - _password, - _addressController.text, - ), - publicKey: _selectedLegacyPillarSwapFileEntry?.pubKeyB64, ); } else { for (var element in _pillarFormKeys) { @@ -872,33 +821,37 @@ class _MainPillarsState extends State { child: RichText( textAlign: TextAlign.center, text: TextSpan( - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, children: [ TextSpan( text: 'Pillar ', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), TextSpan( text: 'successfully', - style: - Theme.of(context).textTheme.headline6!.copyWith( - color: AppColors.znnColor, - ), + style: Theme.of(context) + .textTheme + .headlineSmall! + .copyWith( + color: AppColors.znnColor, + ), ), TextSpan( text: ' registered. Use ', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), TextSpan( text: 'znn-controller ', - style: - Theme.of(context).textTheme.headline6!.copyWith( - color: AppColors.znnColor, - decoration: TextDecoration.underline, - ), + style: Theme.of(context) + .textTheme + .headlineSmall! + .copyWith( + color: AppColors.znnColor, + decoration: TextDecoration.underline, + ), recognizer: TapGestureRecognizer() ..onTap = () { - NavigationUtils.launchUrl( + NavigationUtils.openUrl( kZnnController, context); }, ), @@ -908,7 +861,7 @@ class _MainPillarsState extends State { ), TextSpan( text: ' to check the Pillar status', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), ], ), @@ -988,12 +941,11 @@ class _MainPillarsState extends State { children: [ Text( 'Please choose the type of Pillar you want to register', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), ], ), _getPillarTypeListTile('Pillar', PillarType.regularPillar), - _getPillarTypeListTile('Legacy Pillar', PillarType.legacyPillar), _getContinueButton(), ], ); @@ -1012,7 +964,7 @@ class _MainPillarsState extends State { return ListTile( title: Text( text, - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), leading: Radio( activeColor: AppColors.znnColor, @@ -1030,11 +982,7 @@ class _MainPillarsState extends State { } void _onPillarTypeContinuePressed() { - _saveProgressAndNavigateToNextStep( - _selectedPillarType == PillarType.legacyPillar - ? PillarsStepperStep.selectPillarType - : PillarsStepperStep.checkForLegacyPillar, - ); + _saveProgressAndNavigateToNextStep(PillarsStepperStep.selectPillarType); } void _saveProgressAndNavigateToNextStep(PillarsStepperStep completedStep) { @@ -1086,17 +1034,9 @@ class _MainPillarsState extends State { ); void _onQsrNextPressed() { - if (_lastCompletedStep == PillarsStepperStep.checkForLegacyPillar) { - _saveProgressAndNavigateToNextStep(PillarsStepperStep.qsrManagement); - } else if (StepperUtils.getStepState( - PillarsStepperStep.qsrManagement.index, - _lastCompletedStep?.index, - ) == - custom_material_stepper.StepState.complete) { - setState(() { - _currentStep = PillarsStepperStep.values[_currentStep.index + 1]; - }); - } + setState(() { + _currentStep = PillarsStepperStep.values[_currentStep.index + 1]; + }); } Widget _getPlasmaCheckFutureBuilder() { @@ -1159,220 +1099,6 @@ class _MainPillarsState extends State { } } - Widget _getCheckForLegacyPillarStepBody() { - return ViewModelBuilder.reactive( - onModelReady: (model) { - model.checkForLegacyPillar(); - }, - builder: (_, model, __) => StreamBuilder?>( - stream: model.stream, - builder: (_, snapshot) { - if (snapshot.hasError) { - return SyriusErrorWidget(snapshot.error!); - } - if (snapshot.connectionState == ConnectionState.active) { - if (snapshot.hasData) { - _legacyPillars = snapshot.data; - return _getDecryptWalletFileBody(); - } - return const SyriusLoadingWidget(); - } - return const SyriusLoadingWidget(); - }, - ), - viewModelBuilder: () => GetLegacyPillarsBloc(), - ); - } - - Widget _getImportWalletWidget() { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Please choose the ".dat" wallet file to discover legacy Pillar entries', - style: Theme.of(context).textTheme.headline6, - ), - const SizedBox( - height: 25.0, - ), - SelectFileWidget( - fileExtension: 'dat', - onPathFoundCallback: (String path) { - setState(() { - _walletPath = path; - }); - }, - ), - ], - ); - } - - Widget _getDecryptWalletFileBody() { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _getImportWalletWidget(), - Visibility( - visible: _walletPath != null, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - kVerticalSpacing, - _getWalletPasswordInputField(), - kVerticalSpacing, - Visibility( - visible: _decryptWalletResults.isEmpty, - child: _getDecryptWalletFileViewModel(), - ), - Visibility( - visible: _foundLegacyPillarSwapFileEntries.isNotEmpty, - child: Column( - children: [ - Row( - children: [ - Text( - 'Please choose the Legacy Pillar', - style: Theme.of(context).textTheme.headline6, - ), - ], - ) - ] + - _foundLegacyPillarSwapFileEntries - .map((e) => _getLegacyPillarListTile(e.address, e)) - .toList() - .cast(), - ), - ), - Visibility( - visible: _foundLegacyPillarSwapFileEntries.isNotEmpty && - _selectedLegacyPillarSwapFileEntry != null, - child: StepperButton( - text: 'Next', - onPressed: () { - _saveProgressAndNavigateToNextStep( - PillarsStepperStep.checkForLegacyPillar, - ); - }, - ), - ), - Visibility( - visible: _foundLegacyPillarSwapFileEntries.isEmpty && - _decryptWalletResults.isNotEmpty, - child: Text( - 'No Legacy Pillar found', - style: Theme.of(context).textTheme.headline6, - ), - ), - ], - ), - ), - ], - ); - } - - Widget _getWalletPasswordInputField() { - return Material( - color: Colors.transparent, - child: PasswordInputField( - hintText: 'Wallet password', - controller: _passwordController, - onChanged: (value) { - setState(() { - _password = value; - }); - }, - ), - ); - } - - Widget _getDecryptWalletFileViewModel() { - return ViewModelBuilder.reactive( - onModelReady: (model) { - model.stream.listen( - (results) { - if (results != null) { - _decryptWalletResults = results; - _findLegacyPillar( - _decryptWalletResults, - _legacyPillars!, - ); - if (_foundLegacyPillarSwapFileEntries.isEmpty) { - _checkForLegacyPillarStepSubtitle = - 'No Legacy Pillar available'; - } else { - _checkForLegacyPillarStepSubtitle = 'Legacy Pillar available'; - } - setState(() {}); - } - }, - onError: (error) { - NotificationUtils.sendNotificationError(error, error.toString()); - }, - ); - }, - builder: (_, model, __) => StreamBuilder?>( - stream: model.stream, - builder: (_, snapshot) { - if (snapshot.hasError) { - return _getDecryptButton(model); - } - if (snapshot.connectionState == ConnectionState.active) { - if (snapshot.hasData) { - return _getDecryptButton(model); - } - return const SyriusLoadingWidget(); - } - return _getDecryptButton(model); - }, - ), - viewModelBuilder: () => ReadWalletBloc(), - ); - } - - Widget _getDecryptButton(ReadWalletBloc model) { - return StepperButton( - onPressed: _password.isNotEmpty - ? () { - model.readWallet(_walletPath!, _password); - } - : null, - text: 'Decrypt', - ); - } - - void _findLegacyPillar( - List decryptWalletResults, - List legacyPillars, - ) { - for (SwapFileEntry decryptWalletResult in decryptWalletResults) { - for (SwapLegacyPillarEntry legacyPillar in legacyPillars) { - if (legacyPillar.keyIdHash.toString() == - decryptWalletResult.keyIdHashHex) { - _foundLegacyPillarSwapFileEntries.add(decryptWalletResult); - } - } - } - } - - Widget _getLegacyPillarListTile(String text, SwapFileEntry value) { - return ListTile( - title: Text( - text, - style: Theme.of(context).textTheme.bodyText1, - ), - leading: Radio( - activeColor: AppColors.znnColor, - value: value, - groupValue: _selectedLegacyPillarSwapFileEntry, - onChanged: (SwapFileEntry? value) { - setState(() { - _selectedLegacyPillarSwapFileEntry = value; - }); - }, - ), - ); - } - Widget _getPillarMomentumRewardsStepContent() { return Column( children: [ @@ -1381,7 +1107,7 @@ class _MainPillarsState extends State { children: [ Text( 'Percentage of momentum rewards given to the delegators', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), ], ), @@ -1402,11 +1128,11 @@ class _MainPillarsState extends State { children: [ Text( 'Pillar: ${100 - _momentumRewardPercentageGiven.toInt()}', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), Text( 'Delegators: ${_momentumRewardPercentageGiven.toInt()}', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ], ), @@ -1416,7 +1142,7 @@ class _MainPillarsState extends State { children: [ Text( 'Percentage of delegation rewards given to the delegators', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), ], ), @@ -1437,11 +1163,11 @@ class _MainPillarsState extends State { children: [ Text( 'Pillar: ${100 - _delegateRewardPercentageGiven.toInt()}', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), Text( 'Delegators: ${_delegateRewardPercentageGiven.toInt()}', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ], ), diff --git a/lib/widgets/modular_widgets/pillars_widgets/pillars_widgets.dart b/lib/widgets/modular_widgets/pillars_widgets/pillars_widgets.dart new file mode 100644 index 00000000..b97ad09c --- /dev/null +++ b/lib/widgets/modular_widgets/pillars_widgets/pillars_widgets.dart @@ -0,0 +1,6 @@ +export 'create_pillar.dart'; +export 'pillar_collect.dart'; +export 'pillar_rewards.dart'; +export 'pillar_update_stepper.dart'; +export 'pillars_list_widget.dart'; +export 'pillars_stepper_container.dart'; diff --git a/lib/widgets/modular_widgets/plasma_widgets/plasma_list/plasma_list.dart b/lib/widgets/modular_widgets/plasma_widgets/plasma_list/plasma_list.dart index e94f94de..d1b8af94 100644 --- a/lib/widgets/modular_widgets/plasma_widgets/plasma_list/plasma_list.dart +++ b/lib/widgets/modular_widgets/plasma_widgets/plasma_list/plasma_list.dart @@ -1,18 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/plasma/cancel_plasma_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/plasma/plasma_list_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/cancel_timer.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/formatted_amount_with_tooltip.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/infinite_scroll_table.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PlasmaList extends StatefulWidget { @@ -29,7 +23,7 @@ class PlasmaList extends StatefulWidget { } class _PlasmaListState extends State { - final List? _stakingList = []; + final List _stakingList = []; bool _sortAscending = true; @@ -74,7 +68,7 @@ class _PlasmaListState extends State { tokenSymbol: kQsrCoin.symbol, builder: (formattedAmount, tokenSymbol) => Text( '$formattedAmount $tokenSymbol', - style: Theme.of(context).textTheme.subtitle1!.copyWith( + style: Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.subtitleColor, ), ), @@ -115,19 +109,19 @@ class _PlasmaListState extends State { bool isSelected, FusionEntry plasmaItem, ) { - final GlobalKey _cancelButtonKey = GlobalKey(); + final GlobalKey cancelButtonKey = GlobalKey(); return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (event) { if (event != null) { - _cancelButtonKey.currentState?.animateReverse(); + cancelButtonKey.currentState?.animateReverse(); plasmaModel.refreshResults(); } }, onError: (error) { - _cancelButtonKey.currentState?.animateReverse(); + cancelButtonKey.currentState?.animateReverse(); NotificationUtils.sendNotificationError( error, 'Error while cancelling plasma'); }, @@ -136,7 +130,7 @@ class _PlasmaListState extends State { builder: (_, model, __) => _getCancelButton( model, plasmaItem.id.toString(), - _cancelButtonKey, + cancelButtonKey, ), viewModelBuilder: () => CancelPlasmaBloc(), ); @@ -160,8 +154,8 @@ class _PlasmaListState extends State { color: AppColors.errorColor, ), outlineColor: AppColors.errorColor, - textStyle: Theme.of(context).textTheme.subtitle2!.copyWith( - color: Theme.of(context).textTheme.bodyText1!.color, + textStyle: Theme.of(context).textTheme.titleSmall!.copyWith( + color: Theme.of(context).textTheme.bodyLarge!.color, ), ); } @@ -170,21 +164,21 @@ class _PlasmaListState extends State { switch (columnName) { case 'Amount': _sortAscending - ? _stakingList!.sort((a, b) => a.qsrAmount.compareTo(b.qsrAmount)) - : _stakingList!.sort((a, b) => b.qsrAmount.compareTo(a.qsrAmount)); + ? _stakingList.sort((a, b) => a.qsrAmount.compareTo(b.qsrAmount)) + : _stakingList.sort((a, b) => b.qsrAmount.compareTo(a.qsrAmount)); break; case 'Beneficiary': _sortAscending - ? _stakingList! + ? _stakingList .sort((a, b) => a.beneficiary.compareTo(b.beneficiary)) - : _stakingList! + : _stakingList .sort((a, b) => b.beneficiary.compareTo(a.beneficiary)); break; default: _sortAscending - ? _stakingList! + ? _stakingList .sort((a, b) => a.beneficiary.compareTo(b.beneficiary)) - : _stakingList! + : _stakingList .sort((a, b) => b.beneficiary.compareTo(a.beneficiary)); break; } diff --git a/lib/widgets/modular_widgets/plasma_widgets/plasma_options/plasma_options.dart b/lib/widgets/modular_widgets/plasma_widgets/plasma_options/plasma_options.dart index 292f9299..7a0cd71b 100644 --- a/lib/widgets/modular_widgets/plasma_widgets/plasma_options/plasma_options.dart +++ b/lib/widgets/modular_widgets/plasma_widgets/plasma_options/plasma_options.dart @@ -3,12 +3,9 @@ import 'package:flutter/services.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:provider/provider.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/balance_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/plasma/plasma_list_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/plasma/plasma_options_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/plasma/plasma_stats_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/plasma_info_wrapper.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; @@ -18,15 +15,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notifiers/default_address_notifier.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notifiers/plasma_beneficiary_address_notifier.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/amount_suffix_widgets.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/disabled_address_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/plasma_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/stepper_utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PlasmaOptions extends StatefulWidget { @@ -56,6 +45,8 @@ class _PlasmaOptionsState extends State { final GlobalKey _beneficiaryAddressKey = GlobalKey(); final GlobalKey _fuseButtonKey = GlobalKey(); + PlasmaBeneficiaryAddressNotifier? _plasmaBeneficiaryAddress; + int? _maxQsrAmount; double? _maxWidth; @@ -68,7 +59,13 @@ class _PlasmaOptionsState extends State { @override void initState() { + // The setState() causes a redraw which resets the beneficiaryAddress. + _plasmaBeneficiaryAddress = + Provider.of(context, listen: false); + _plasmaBeneficiaryAddress!.addListener(_beneficiaryAddressListener); + super.initState(); + sl.get().getBalanceForAllAddresses(); } @@ -132,112 +129,110 @@ class _PlasmaOptionsState extends State { ); } + void _beneficiaryAddressListener() { + _beneficiaryAddressController.text = + _plasmaBeneficiaryAddress!.getBeneficiaryAddress()!; + } + Widget _getWidgetBody(AccountInfo? accountInfo) { - return Consumer( - builder: (_, notifier, child) { - _beneficiaryAddressController.text = notifier.getBeneficiaryAddress()!; - return Container( - margin: EdgeInsets.all(_marginWidth), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: _beneficiaryAddressExpandedFlex, - child: ListView( - shrinkWrap: true, - children: [ - DisabledAddressField( - _addressController, - contentLeftPadding: 20.0, - ), - StepperUtils.getBalanceWidget(kQsrCoin, accountInfo!), - Form( - key: _beneficiaryAddressKey, - autovalidateMode: AutovalidateMode.onUserInteraction, - child: InputField( - onChanged: (String value) { - _beneficiaryAddressString.value = value; - }, - inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp(r'[0-9a-z]')), - ], - controller: _beneficiaryAddressController, - hintText: 'Beneficiary address', - contentLeftPadding: 20.0, - validator: (value) => - InputValidators.checkAddress(value), - ), - ), - ], + return Container( + margin: EdgeInsets.all(_marginWidth), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: _beneficiaryAddressExpandedFlex, + child: ListView( + shrinkWrap: true, + children: [ + DisabledAddressField( + _addressController, + contentLeftPadding: 20.0, ), - ), - SizedBox( - width: _spaceBetweenExpandedWidgets, - ), - Expanded( - flex: _fuseButtonExpandedFlex, - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - SizedBox( - height: 87.0, - child: Form( - key: _qsrAmountKey, - autovalidateMode: AutovalidateMode.onUserInteraction, - child: InputField( - enabled: _maxQsrAmount! > 0, - onChanged: (String value) { - setState(() {}); - }, - inputFormatters: - FormatUtils.getPlasmaAmountTextInputFormatters( - _qsrAmountController.text, - ), - controller: _qsrAmountController, - validator: (value) => InputValidators.correctValue( - value, - _maxQsrAmount, - kQsrCoin.decimals, - min: fuseMinQsrAmount.addDecimals( - qsrDecimals, - ), - canBeEqualToMin: true, - ), - suffixIcon: _getAmountSuffix(), - hintText: 'Amount', - contentLeftPadding: 20.0, + StepperUtils.getBalanceWidget(kQsrCoin, accountInfo!), + Form( + key: _beneficiaryAddressKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + child: InputField( + onChanged: (String value) { + _beneficiaryAddressString.value = value; + }, + inputFormatters: [ + FilteringTextInputFormatter.allow(RegExp(r'[0-9a-z]')), + ], + controller: _beneficiaryAddressController, + hintText: 'Beneficiary address', + contentLeftPadding: 20.0, + validator: (value) => InputValidators.checkAddress(value), + ), + ), + ], + ), + ), + SizedBox( + width: _spaceBetweenExpandedWidgets, + ), + Expanded( + flex: _fuseButtonExpandedFlex, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + SizedBox( + height: 87.0, + child: Form( + key: _qsrAmountKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + child: InputField( + enabled: _maxQsrAmount! > 0, + onChanged: (String value) { + setState(() {}); + }, + inputFormatters: + FormatUtils.getPlasmaAmountTextInputFormatters( + _qsrAmountController.text, + ), + controller: _qsrAmountController, + validator: (value) => InputValidators.correctValue( + value, + _maxQsrAmount, + kQsrCoin.decimals, + min: fuseMinQsrAmount.addDecimals( + qsrDecimals, ), + canBeEqualToMin: true, ), + suffixIcon: _getAmountSuffix(), + hintText: 'Amount', + contentLeftPadding: 20.0, ), - ValueListenableBuilder( - valueListenable: _beneficiaryAddressString, - builder: (_, __, ___) { - return Row( - children: [ - _getGeneratePlasmaButtonStreamBuilder(), - Visibility( - visible: _isInputValid(), - child: Row( - children: [ - const SizedBox( - width: 10.0, - ), - _getPlasmaIcon(), - ], + ), + ), + ValueListenableBuilder( + valueListenable: _beneficiaryAddressString, + builder: (_, __, ___) { + return Row( + children: [ + _getGeneratePlasmaButtonStreamBuilder(), + Visibility( + visible: _isInputValid(), + child: Row( + children: [ + const SizedBox( + width: 10.0, ), - ) - ], - ); - }, - ), - ], + _getPlasmaIcon(), + ], + ), + ) + ], + ); + }, ), - ), - ], + ], + ), ), - ); - }, + ], + ), ); } @@ -333,7 +328,7 @@ class _PlasmaOptionsState extends State { Widget _getGeneratePlasmaButtonStreamBuilder() { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (event) { if (event != null) { @@ -378,6 +373,7 @@ class _PlasmaOptionsState extends State { @override void dispose() { + _plasmaBeneficiaryAddress!.removeListener(_beneficiaryAddressListener); _qsrAmountController.dispose(); _addressController.dispose(); _beneficiaryAddressController.dispose(); diff --git a/lib/widgets/modular_widgets/plasma_widgets/plasma_widgets.dart b/lib/widgets/modular_widgets/plasma_widgets/plasma_widgets.dart new file mode 100644 index 00000000..ea7a6839 --- /dev/null +++ b/lib/widgets/modular_widgets/plasma_widgets/plasma_widgets.dart @@ -0,0 +1,2 @@ +export 'plasma_list/plasma_list.dart'; +export 'plasma_options/plasma_options.dart'; diff --git a/lib/widgets/modular_widgets/sentinel_widgets/create_sentinel.dart b/lib/widgets/modular_widgets/sentinel_widgets/create_sentinel.dart index 1202b02c..362aa30a 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/create_sentinel.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/create_sentinel.dart @@ -1,15 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:lottie/lottie.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/sentinels/get_sentinel_by_owner_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/stepper_screen.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/sentinel_widgets/sentinels_stepper_container.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/elevated_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/standard_tooltip_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class CreateSentinel extends StatefulWidget { @@ -64,11 +59,12 @@ class _CreateSentinelState extends State { children: [ Text( 'You already spawned a Sentinel on this address', - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), const StandardTooltipIcon( 'Cannot reuse address. ' 'Please use another address to spawn a new Sentinel Node', + Icons.help, ), ], ), diff --git a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_collect.dart b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_collect.dart index ef634d37..5bf82495 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_collect.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_collect.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/sentinels/sentinel_rewards_history_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/sentinels/sentinel_uncollected_rewards_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; @@ -8,11 +7,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/number_animation.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class SentinelCollect extends StatefulWidget { @@ -24,7 +19,7 @@ class SentinelCollect extends StatefulWidget { }) : super(key: key); @override - _SentinelCollectState createState() => _SentinelCollectState(); + State createState() => _SentinelCollectState(); } class _SentinelCollectState extends State { @@ -75,7 +70,7 @@ class _SentinelCollectState extends State { end: uncollectedReward.znnAmount.addDecimals(znnDecimals), isInt: false, after: ' ${kZnnCoin.symbol}', - style: Theme.of(context).textTheme.headline1!.copyWith( + style: Theme.of(context).textTheme.headlineLarge!.copyWith( color: AppColors.znnColor, fontSize: 30.0, ), @@ -85,7 +80,7 @@ class _SentinelCollectState extends State { end: uncollectedReward.qsrAmount.addDecimals(qsrDecimals), isInt: false, after: ' ${kQsrCoin.symbol}', - style: Theme.of(context).textTheme.headline1!.copyWith( + style: Theme.of(context).textTheme.headlineLarge!.copyWith( color: AppColors.qsrColor, fontSize: 30.0, ), diff --git a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_rewards.dart b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_rewards.dart index 2b40f004..8fe010c6 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_rewards.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_rewards.dart @@ -1,9 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/sentinels/sentinel_rewards_history_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/charts/sentinel_rewards_chart.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class SentinelRewards extends StatefulWidget { diff --git a/lib/widgets/modular_widgets/sentinel_widgets/sentinel_widgets.dart b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_widgets.dart new file mode 100644 index 00000000..d07dd8b4 --- /dev/null +++ b/lib/widgets/modular_widgets/sentinel_widgets/sentinel_widgets.dart @@ -0,0 +1,5 @@ +export 'create_sentinel.dart'; +export 'sentinel_collect.dart'; +export 'sentinel_rewards.dart'; +export 'sentinels_list_widget.dart'; +export 'sentinels_stepper_container.dart'; diff --git a/lib/widgets/modular_widgets/sentinel_widgets/sentinels_list_widget.dart b/lib/widgets/modular_widgets/sentinel_widgets/sentinels_list_widget.dart index d6a116c0..85d19eac 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/sentinels_list_widget.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/sentinels_list_widget.dart @@ -1,31 +1,25 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/sentinels/disassemble_button_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/sentinels/sentinel_list_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/widget_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/outlined_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/cancel_timer.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/standard_tooltip_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/infinite_scroll_table.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class SentinelsListWidget extends StatefulWidget { const SentinelsListWidget({Key? key}) : super(key: key); @override - _SentinelsListWidgetState createState() => _SentinelsListWidgetState(); + State createState() => _SentinelsListWidgetState(); } class _SentinelsListWidgetState extends State { late SentinelsListBloc _bloc; - final List? _sentinels = []; + final List _sentinels = []; bool _sortAscending = true; @override @@ -118,6 +112,7 @@ class _SentinelsListWidgetState extends State { sentinelInfo.isRevocable ? 'Revocation window is open' : 'Until revocation window opens', + Icons.help, iconColor: sentinelInfo.isRevocable ? AppColors.znnColor : AppColors.errorColor, @@ -159,7 +154,7 @@ class _SentinelsListWidgetState extends State { minimumSize: const Size(55.0, 25.0), outlineColor: isSelected ? AppColors.errorColor - : Theme.of(context).textTheme.subtitle2!.color, + : Theme.of(context).textTheme.titleSmall!.color, onPressed: isSelected ? () { model.disassembleSentinel(context); @@ -171,10 +166,10 @@ class _SentinelsListWidgetState extends State { Text( 'DISASSEMBLE', style: isSelected - ? Theme.of(context).textTheme.subtitle2!.copyWith( - color: Theme.of(context).textTheme.bodyText1!.color, + ? Theme.of(context).textTheme.titleSmall!.copyWith( + color: Theme.of(context).textTheme.bodyLarge!.color, ) - : Theme.of(context).textTheme.subtitle2, + : Theme.of(context).textTheme.titleSmall, ), const SizedBox( width: 20.0, @@ -184,7 +179,7 @@ class _SentinelsListWidgetState extends State { size: 11.0, color: isSelected ? AppColors.errorColor - : Theme.of(context).textTheme.subtitle2!.color, + : Theme.of(context).textTheme.titleSmall!.color, ), ], ), @@ -195,14 +190,14 @@ class _SentinelsListWidgetState extends State { switch (columnName) { case 'Sentinel Owner': _sortAscending - ? _sentinels!.sort((a, b) => a.owner.compareTo(b.owner)) - : _sentinels!.sort((a, b) => b.owner.compareTo(a.owner)); + ? _sentinels.sort((a, b) => a.owner.compareTo(b.owner)) + : _sentinels.sort((a, b) => b.owner.compareTo(a.owner)); break; case 'Registration time': _sortAscending - ? _sentinels!.sort((a, b) => + ? _sentinels.sort((a, b) => a.registrationTimestamp.compareTo(b.registrationTimestamp)) - : _sentinels!.sort((a, b) => + : _sentinels.sort((a, b) => b.registrationTimestamp.compareTo(a.registrationTimestamp)); break; case 'Reward Address': @@ -221,7 +216,7 @@ class _SentinelsListWidgetState extends State { SentinelInfo sentinelInfo, ) { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (event) { if (event != null) { diff --git a/lib/widgets/modular_widgets/sentinel_widgets/sentinels_stepper_container.dart b/lib/widgets/modular_widgets/sentinel_widgets/sentinels_stepper_container.dart index c2dff885..54898c3a 100644 --- a/lib/widgets/modular_widgets/sentinel_widgets/sentinels_stepper_container.dart +++ b/lib/widgets/modular_widgets/sentinel_widgets/sentinels_stepper_container.dart @@ -6,11 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:lottie/lottie.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/balance_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/sentinels/sentinel_deposit_qsr_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/sentinels/sentinel_qsr_info_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/sentinels/sentinel_register_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/sentinels/sentinel_withdraw_qsr_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; @@ -21,19 +17,9 @@ import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/stepper_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_pie_chart.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_material_stepper.dart' as custom_material_stepper; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dotted_border_info_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/amount_suffix_widgets.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/disabled_address_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/plasma_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/stepper_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; enum SentinelsStepperStep { @@ -112,7 +98,7 @@ class _MainSentinelsState extends State { Widget _getDepositQsrStep(BuildContext context, AccountInfo? accountInfo) { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { _sentinelsQsrInfoViewModel = model; model.getQsrDepositedAmount(_addressController.text); }, @@ -157,7 +143,7 @@ class _MainSentinelsState extends State { bottom: 30.0, ), decoration: BoxDecoration( - color: Theme.of(context).backgroundColor, + color: Theme.of(context).colorScheme.background, borderRadius: BorderRadius.circular(6.0), ), child: Padding( @@ -193,7 +179,7 @@ class _MainSentinelsState extends State { ), Text( 'Sentinel Slot value\n$_qsrCost ${kQsrCoin.symbol}', - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, textAlign: TextAlign.center, ), ], @@ -216,7 +202,7 @@ class _MainSentinelsState extends State { 'Deposited ${kQsrCoin.symbol}', style: Theme.of(context) .textTheme - .bodyText1! + .bodyLarge! .copyWith( fontSize: 10.0, ), @@ -237,7 +223,7 @@ class _MainSentinelsState extends State { 'Remaining ${kQsrCoin.symbol}', style: Theme.of(context) .textTheme - .bodyText1! + .bodyLarge! .copyWith( fontSize: 10.0, ), @@ -254,7 +240,7 @@ class _MainSentinelsState extends State { child: Text( 'You have deposited $depositedQsr ${kQsrCoin.symbol}', textAlign: TextAlign.center, - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), ), kVerticalSpacing, @@ -348,7 +334,7 @@ class _MainSentinelsState extends State { Widget _getDepositButtonViewModel(AccountInfo accountInfo, num depositedQsr) { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (response) { if (response != null) { @@ -392,7 +378,7 @@ class _MainSentinelsState extends State { Widget _getWithdrawQsrButtonViewModel(num qsrDeposit) { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (event) { if (event != null) { @@ -519,7 +505,7 @@ class _MainSentinelsState extends State { Widget _getDeployButtonViewModel() { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (response) { if (response != null) { @@ -574,7 +560,7 @@ class _MainSentinelsState extends State { child: InputField( enabled: false, controller: _znnAmountController, - validator: InputValidators.validateNumber, + validator: InputValidators.validateAmount, ), ), ], @@ -680,33 +666,37 @@ class _MainSentinelsState extends State { child: RichText( textAlign: TextAlign.center, text: TextSpan( - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, children: [ TextSpan( text: 'Sentinel ', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), TextSpan( text: 'successfully', - style: - Theme.of(context).textTheme.headline6!.copyWith( - color: AppColors.znnColor, - ), + style: Theme.of(context) + .textTheme + .headlineSmall! + .copyWith( + color: AppColors.znnColor, + ), ), TextSpan( text: ' registered. Use ', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), TextSpan( text: 'znn-controller ', - style: - Theme.of(context).textTheme.headline6!.copyWith( - color: AppColors.znnColor, - decoration: TextDecoration.underline, - ), + style: Theme.of(context) + .textTheme + .headlineSmall! + .copyWith( + color: AppColors.znnColor, + decoration: TextDecoration.underline, + ), recognizer: TapGestureRecognizer() ..onTap = () { - NavigationUtils.launchUrl( + NavigationUtils.openUrl( kZnnController, context); }, ), @@ -719,7 +709,7 @@ class _MainSentinelsState extends State { ), TextSpan( text: ' to check the Sentinel status', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), ], ), diff --git a/lib/widgets/modular_widgets/settings_widgets/account_chain_stats.dart b/lib/widgets/modular_widgets/settings_widgets/account_chain_stats.dart index 2e9ce3ed..bcbb368a 100644 --- a/lib/widgets/modular_widgets/settings_widgets/account_chain_stats.dart +++ b/lib/widgets/modular_widgets/settings_widgets/account_chain_stats.dart @@ -3,17 +3,13 @@ import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:marquee_widget/marquee_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/settings/account_chain_stats_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/model/account_chain_stats.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_pie_chart.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/number_animation.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class AccountChainStatsWidget extends StatefulWidget { @@ -52,7 +48,7 @@ class _AccountChainStatsState extends State { children: [ Text( 'Account-chain height', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), Stack( alignment: Alignment.center, @@ -60,7 +56,7 @@ class _AccountChainStatsState extends State { NumberAnimation( end: stats.blockCount, isInt: true, - style: Theme.of(context).textTheme.headline2, + style: Theme.of(context).textTheme.headlineMedium, ), _getChart(stats), ], @@ -72,8 +68,8 @@ class _AccountChainStatsState extends State { minHeight: 40.0, ), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - onPressed: () => NavigationUtils.launchUrl( - kExplorer + '/transaction/' + stats.firstHash.toString(), + onPressed: () => NavigationUtils.openUrl( + '$kExplorer/transaction/${stats.firstHash}', context, ), child: Row( @@ -81,7 +77,7 @@ class _AccountChainStatsState extends State { children: [ Text( 'Block hash', - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, ), Container(width: 10.0), const Icon( @@ -104,7 +100,7 @@ class _AccountChainStatsState extends State { child: Marquee( child: Text( stats.firstHash.toString(), - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ), ), @@ -187,20 +183,20 @@ class _AccountChainStatsState extends State { children: [ Text( '● ', - style: Theme.of(context).textTheme.bodyText2!.copyWith( + style: Theme.of(context).textTheme.bodyMedium!.copyWith( color: kBlockTypeColorMap[blockType] ?? AppColors.errorColor, ), ), AutoSizeText( FormatUtils.extractNameFromEnum(blockType), - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, ), const SizedBox( width: 10.0, ), AutoSizeText( blockTypeCount.toString(), - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ], ), diff --git a/lib/widgets/modular_widgets/settings_widgets/addresses.dart b/lib/widgets/modular_widgets/settings_widgets/addresses.dart index 050204be..4852249d 100644 --- a/lib/widgets/modular_widgets/settings_widgets/addresses.dart +++ b/lib/widgets/modular_widgets/settings_widgets/addresses.dart @@ -2,8 +2,9 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; +import 'package:number_selector/number_selector.dart'; import 'package:provider/provider.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/settings/account_chain_stats_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; @@ -11,10 +12,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notifiers/default_address_notifier.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notifiers/plasma_beneficiary_address_notifier.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/settings_address.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class Addresses extends StatefulWidget { final AccountChainStatsBloc accountChainStatsBloc; @@ -40,6 +38,7 @@ class AddressesState extends State { late ScrollController _scrollController; bool _shouldScrollToTheEnd = false; + int numberOfAddressesToAdd = 1; @override void initState() { @@ -61,6 +60,7 @@ class AddressesState extends State { try { Box box = Hive.box(kSharedPrefsBox); await box.put(kDefaultAddressKey, newDefaultAddress); + if (!mounted) return; Provider.of( context, listen: false, @@ -80,42 +80,70 @@ class AddressesState extends State { } Widget _getAddAddressWidget() { - return InkWell( - onTap: () { - setState(() { - _futureGenerateNewAddress = - AddressUtils.generateNewAddress(callback: () { - setState(() { - _shouldScrollToTheEnd = true; - }); - }); - }); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Icon( - Icons.add_circle, - color: AppColors.znnColor, - size: 20.0, - ), - const SizedBox( - width: 5.0, - ), - Text( - 'Add new address', - style: Theme.of(context).textTheme.bodyText1, + return Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + flex: 1, + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 20.0), + child: NumberSelector.plain( + borderColor: AppColors.znnColor, + iconColor: AppColors.znnColor, + dividerColor: AppColors.znnColor, + step: 1, + current: 1, + min: 1, + max: 10, + onUpdate: (val) { + _onAddAddressPressedCallback(val); + }, + ), ), - ], - ), + ), + InkWell( + onTap: () { + setState(() { + _futureGenerateNewAddress = AddressUtils.generateNewAddress( + numAddr: numberOfAddressesToAdd, + callback: () { + setState(() { + _shouldScrollToTheEnd = true; + }); + }); + }); + }, + child: Container( + constraints: + const BoxConstraints(minWidth: 150.0, minHeight: 50.0), + alignment: Alignment.center, + child: Row( + children: [ + const Icon( + Icons.add_circle, + color: AppColors.znnColor, + size: 20.0, + ), + const SizedBox(width: 10.0), + Text( + (numberOfAddressesToAdd == 1) + ? 'Add $numberOfAddressesToAdd address ' + : 'Add $numberOfAddressesToAdd addresses', + style: Theme.of(context).textTheme.bodyLarge, + ), + ], + )), + ), + const SizedBox(width: 10.0), + ], ), ); } Widget _getAddresses() { - List _addresses = kDefaultAddressList + List addresses = kDefaultAddressList .map( (e) => Row( children: [ @@ -139,15 +167,15 @@ class AddressesState extends State { controller: _scrollController, key: const PageStorageKey('Addresses list view'), shrinkWrap: true, - itemCount: _addresses.length, + itemCount: addresses.length, itemBuilder: (context, index) { - return _addresses[index]; + return addresses[index]; }, ); if (_shouldScrollToTheEnd) { Timer( - const Duration(seconds: 1), + const Duration(milliseconds: 1), () { if (mounted && _scrollController.hasClients) { _scrollController @@ -210,9 +238,16 @@ class AddressesState extends State { ); } + void _onAddAddressPressedCallback(int value) { + setState(() { + numberOfAddressesToAdd = value; + }); + } + void _onAddressPressedCallback(String? value) { setState(() { _futureChangeDefaultAddress = _changeDefaultAddress(value); + numberOfAddressesToAdd = 1; }); } diff --git a/lib/widgets/modular_widgets/settings_widgets/backup.dart b/lib/widgets/modular_widgets/settings_widgets/backup.dart index d492ac03..7104df51 100644 --- a/lib/widgets/modular_widgets/settings_widgets/backup.dart +++ b/lib/widgets/modular_widgets/settings_widgets/backup.dart @@ -1,17 +1,14 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/dump_mnemonic_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/export/export_wallet_info_screen.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/settings_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_expandable_panel.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class BackupWidget extends StatefulWidget { const BackupWidget({Key? key}) : super(key: key); @override - _BackupWidgetState createState() => _BackupWidgetState(); + State createState() => _BackupWidgetState(); } class _BackupWidgetState extends State { diff --git a/lib/widgets/modular_widgets/settings_widgets/display.dart b/lib/widgets/modular_widgets/settings_widgets/display.dart index a230d0e7..2045d3ae 100644 --- a/lib/widgets/modular_widgets/settings_widgets/display.dart +++ b/lib/widgets/modular_widgets/settings_widgets/display.dart @@ -1,17 +1,14 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notifiers/app_theme_notifier.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notifiers/text_scaling_notifier.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_expandable_panel.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; enum TextScaling { system, @@ -29,7 +26,7 @@ class DisplayWidget extends StatefulWidget { const DisplayWidget({Key? key}) : super(key: key); @override - _DisplayWidget createState() => _DisplayWidget(); + State createState() => _DisplayWidget(); } class _DisplayWidget extends State { @@ -119,7 +116,7 @@ class _DisplayWidget extends State { Expanded( child: Text( text, - style: Theme.of(context).textTheme.bodyText1!.copyWith( + style: Theme.of(context).textTheme.bodyLarge!.copyWith( fontSize: 10.0, ), ), diff --git a/lib/widgets/modular_widgets/settings_widgets/general.dart b/lib/widgets/modular_widgets/settings_widgets/general.dart index f733131b..ca30dcdc 100644 --- a/lib/widgets/modular_widgets/settings_widgets/general.dart +++ b/lib/widgets/modular_widgets/settings_widgets/general.dart @@ -1,15 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:marquee_widget/marquee_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/settings/general_stats_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/model/general_stats.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/number_animation.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class GeneralWidget extends StatefulWidget { const GeneralWidget({Key? key}) : super(key: key); @@ -47,19 +44,12 @@ class GeneralWidgetState extends State { children: [ Text( 'Momentum height', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), Container(height: 10.0), Container( width: 150.0, height: 150.0, - child: Center( - child: NumberAnimation( - end: generalStats.frontierMomentum.height, - isInt: true, - style: Theme.of(context).textTheme.headline2, - ), - ), decoration: const ShapeDecoration( color: Colors.transparent, shape: CircleBorder( @@ -69,6 +59,13 @@ class GeneralWidgetState extends State { ), ), ), + child: Center( + child: NumberAnimation( + end: generalStats.frontierMomentum.height, + isInt: true, + style: Theme.of(context).textTheme.headlineMedium, + ), + ), ), Container(height: 10.0), Row( @@ -94,7 +91,7 @@ class GeneralWidgetState extends State { (generalStats.networkInfo.peers.isNotEmpty) ? Text( 'Peers connected', - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, ) : const Text('Peers available'), const SizedBox( @@ -103,11 +100,11 @@ class GeneralWidgetState extends State { (generalStats.networkInfo.peers.isNotEmpty) ? Text( '${generalStats.networkInfo.peers.length}', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ) : Text( 'No peers found', - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, ), ], ) @@ -132,14 +129,14 @@ class GeneralWidgetState extends State { children: [ Text( 'Timestamp', - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, ), ], ), const SizedBox(width: 10.0), Text( '${generalStats.frontierMomentum.timestamp}', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ], ), @@ -151,10 +148,8 @@ class GeneralWidgetState extends State { minHeight: 40.0, ), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - onPressed: () => NavigationUtils.launchUrl( - kExplorer + - '/momentum/' + - generalStats.frontierMomentum.hash.toString(), + onPressed: () => NavigationUtils.openUrl( + '$kExplorer/momentum/${generalStats.frontierMomentum.hash}', context, ), child: Row( @@ -162,7 +157,7 @@ class GeneralWidgetState extends State { children: [ Text( 'Momentum hash', - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, ), Container(width: 10.0), const Icon( @@ -185,7 +180,7 @@ class GeneralWidgetState extends State { child: Marquee( child: Text( '${generalStats.frontierMomentum.hash}', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ), ), diff --git a/lib/widgets/modular_widgets/settings_widgets/node_management.dart b/lib/widgets/modular_widgets/settings_widgets/node_management.dart index 36d4df87..a9349c7a 100644 --- a/lib/widgets/modular_widgets/settings_widgets/node_management.dart +++ b/lib/widgets/modular_widgets/settings_widgets/node_management.dart @@ -1,23 +1,18 @@ +import 'dart:io'; import 'dart:isolate'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:hive/hive.dart'; import 'package:wakelock/wakelock.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/embedded_node/embedded_node.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/node_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_expandable_panel.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/settings_node.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class NodeManagement extends StatefulWidget { final VoidCallback onNodeChangedCallback; @@ -28,7 +23,7 @@ class NodeManagement extends StatefulWidget { }) : super(key: key); @override - _NodeManagementState createState() => _NodeManagementState(); + State createState() => _NodeManagementState(); } class _NodeManagementState extends State { @@ -36,14 +31,32 @@ class _NodeManagementState extends State { final GlobalKey _confirmNodeButtonKey = GlobalKey(); final GlobalKey _addNodeButtonKey = GlobalKey(); + final GlobalKey _confirmChainIdButtonKey = GlobalKey(); TextEditingController _newNodeController = TextEditingController(); GlobalKey _newNodeKey = GlobalKey(); + TextEditingController _newChainIdController = TextEditingController(); + GlobalKey _newChainIdKey = GlobalKey(); + + late String _selectedNodeConfirmed; + late int _currentChainId; + + int get _newChainId => int.parse(_newChainIdController.text); + @override void didChangeDependencies() { super.didChangeDependencies(); _selectedNode ??= kCurrentNode!; + _selectedNodeConfirmed = _selectedNode!; + _initCurrentChainId(); + } + + void _initCurrentChainId() { + _currentChainId = sharedPrefsService!.get( + kChainIdKey, + defaultValue: kChainIdDefaultValue, + ); } @override @@ -62,6 +75,10 @@ class _NodeManagementState extends State { return ListView( shrinkWrap: true, children: [ + CustomExpandablePanel( + 'Client chain identifier selection', + _getChainIdSelectionExpandableChild(), + ), CustomExpandablePanel( 'Node selection', _getNodeSelectionExpandableChild(), @@ -98,7 +115,7 @@ class _NodeManagementState extends State { Future _onConfirmNodeButtonPressed() async { // Acquire WakeLock - if (!await Wakelock.enabled) { + if (!Platform.isLinux && !await Wakelock.enabled) { Wakelock.enable(); } @@ -107,11 +124,11 @@ class _NodeManagementState extends State { String url = _selectedNode == 'Embedded Node' ? kLocalhostDefaultNodeUrl : _selectedNode!; - bool _isConnectionEstablished = + bool isConnectionEstablished = await NodeUtils.establishConnectionToNode(url); if (_selectedNode == 'Embedded Node') { // Check if node is already running - if (!_isConnectionEstablished) { + if (!isConnectionEstablished) { // Initialize local full node await Isolate.spawn(EmbeddedNode.runNode, [''], onExit: sl(instanceName: 'embeddedStoppedPort') @@ -119,24 +136,26 @@ class _NodeManagementState extends State { kEmbeddedNodeRunning = true; // The node needs a couple of seconds to actually start await Future.delayed(kEmbeddedConnectionDelay); - _isConnectionEstablished = + isConnectionEstablished = await NodeUtils.establishConnectionToNode(url); } } else { - _isConnectionEstablished = + isConnectionEstablished = await NodeUtils.establishConnectionToNode(url); - if (_isConnectionEstablished) { + if (isConnectionEstablished) { await NodeUtils.closeEmbeddedNode(); } } - if (_isConnectionEstablished) { - await sharedPrefsService!.put( - kSelectedNodeKey, - _selectedNode, - ); - kCurrentNode = _selectedNode!; - _sendChangingNodeSuccessNotification(); - widget.onNodeChangedCallback(); + if (isConnectionEstablished) { + if (await _checkForChainIdMismatch()) { + await sharedPrefsService!.put( + kSelectedNodeKey, + _selectedNode, + ); + kCurrentNode = _selectedNode!; + _sendChangingNodeSuccessNotification(); + widget.onNodeChangedCallback(); + } } else { throw 'Connection could not be established to $_selectedNode'; } @@ -204,7 +223,7 @@ class _NodeManagementState extends State { await Hive.openBox(kNodesBox); } Hive.box(kNodesBox).add(_newNodeController.text); - await NodeUtils.loadDbNodes(context); + await NodeUtils.loadDbNodes(); _sendAddNodeSuccessNotification(); _newNodeController = TextEditingController(); _newNodeKey = GlobalKey(); @@ -246,6 +265,7 @@ class _NodeManagementState extends State { onChangedOrDeletedNode: () { setState(() {}); }, + currentNode: _selectedNodeConfirmed, ), ), ], @@ -266,6 +286,7 @@ class _NodeManagementState extends State { @override void dispose() { _newNodeController.dispose(); + _newChainIdController.dispose(); super.dispose(); } @@ -279,4 +300,123 @@ class _NodeManagementState extends State { ), ); } + + Widget _getChainIdSelectionExpandableChild() { + return Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: Form( + key: _newChainIdKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + child: InputField( + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ], + controller: _newChainIdController, + hintText: + 'Current client chain identifier is ${getChainIdentifier().toString()}', + onSubmitted: (value) async { + if (_isChainIdSelectionInputIsValid()) { + _onConfirmChainIdPressed(); + } + }, + onChanged: (String value) { + if (value.isNotEmpty) { + setState(() {}); + } + }, + validator: InputValidators.validateNumber, + ), + )), + StandardTooltipIcon( + (getChainIdentifier() == 1) + ? 'Alphanet chain identifier' + : 'Non-alphanet chain identifier', + MaterialCommunityIcons.network, + iconColor: (getChainIdentifier() == 1) + ? AppColors.znnColor + : Colors.orange, + ), + const StandardTooltipIcon( + 'The chain identifier is used in transaction signing to prevent replay attacks', + MaterialCommunityIcons.alert, + iconColor: Colors.orange, + ), + ], + ), + kVerticalSpacing, + LoadingButton.settings( + onPressed: _isChainIdSelectionInputIsValid() + ? _onConfirmChainIdPressed + : null, + text: 'Confirm', + key: _confirmChainIdButtonKey, + ), + ], + ); + } + + bool _isChainIdSelectionInputIsValid() => + InputValidators.validateNumber(_newChainIdController.text) == null && + _newChainId != _currentChainId; + + Future _onConfirmChainIdPressed() async { + try { + _confirmChainIdButtonKey.currentState?.animateForward(); + setChainIdentifier(chainIdentifier: _newChainId); + await sharedPrefsService!.put(kChainIdKey, _newChainId); + _sendSuccessfullyChangedChainIdNotification(_newChainId); + _initCurrentChainId(); + _newChainIdController = TextEditingController(); + _newChainIdKey = GlobalKey(); + } catch (e) { + NotificationUtils.sendNotificationError( + e, + 'Error while setting the new client chain identifier', + ); + } finally { + _confirmChainIdButtonKey.currentState?.animateReverse(); + } + } + + void _sendSuccessfullyChangedChainIdNotification(int newChainId) { + sl.get().addNotification( + WalletNotification( + title: + 'Successfully changed client chain identifier to $newChainId', + timestamp: DateTime.now().millisecondsSinceEpoch, + details: + 'Successfully changed client chain identifier from $_currentChainId to $_newChainId', + type: NotificationType.changedNode, + ), + ); + } + + Future _checkForChainIdMismatch() async { + bool match = false; + await zenon!.ledger.getFrontierMomentum().then((momentum) async { + int nodeChainId = momentum.chainIdentifier; + if (nodeChainId != _currentChainId) { + match = await _showChainIdWarningDialog(nodeChainId, _currentChainId); + } else { + match = true; + } + }); + return match; + } + + Future _showChainIdWarningDialog( + int nodeChainId, int currentChainId) async { + return await showWarningDialog( + context: context, + title: 'Chain identifier mismatch', + buttonText: 'Proceed anyway', + description: + 'The node $_selectedNode you are connecting to has a different ' + 'chain identifier $nodeChainId than the current client chain identifier $currentChainId', + ); + } } diff --git a/lib/widgets/modular_widgets/settings_widgets/peers.dart b/lib/widgets/modular_widgets/settings_widgets/peers.dart index 765e606f..87284fb7 100644 --- a/lib/widgets/modular_widgets/settings_widgets/peers.dart +++ b/lib/widgets/modular_widgets/settings_widgets/peers.dart @@ -1,17 +1,13 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/sentinels/sentinel_list_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/settings/peers_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_table.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class PeersWidget extends StatefulWidget { const PeersWidget({Key? key}) : super(key: key); @override - _PeersWidget createState() => _PeersWidget(); + State createState() => _PeersWidget(); } class _PeersWidget extends State { diff --git a/lib/widgets/modular_widgets/settings_widgets/security.dart b/lib/widgets/modular_widgets/settings_widgets/security.dart index b6b3f628..5c36b995 100644 --- a/lib/widgets/modular_widgets/settings_widgets/security.dart +++ b/lib/widgets/modular_widgets/settings_widgets/security.dart @@ -2,11 +2,10 @@ import 'dart:io'; import 'dart:typed_data'; import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/change_wallet_password_screen.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/clipboard_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; @@ -14,16 +13,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/settings_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_expandable_panel.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_slider.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/select_file_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; const double _kMaxMinutesOfInactivity = 30.0; @@ -366,11 +356,6 @@ class _SecurityWidgetState extends State { hintText: 'Enter message', suffixIcon: RawMaterialButton( hoverColor: Colors.white12, - child: const Icon( - Icons.content_paste, - color: AppColors.darkHintTextColor, - size: 15.0, - ), shape: const CircleBorder(), onPressed: () { setState(() { @@ -382,6 +367,11 @@ class _SecurityWidgetState extends State { ); }); }, + child: const Icon( + Icons.content_paste, + color: AppColors.darkHintTextColor, + size: 15.0, + ), ), suffixIconConstraints: const BoxConstraints( maxWidth: 45.0, @@ -397,11 +387,6 @@ class _SecurityWidgetState extends State { hintText: 'Enter signature', suffixIcon: RawMaterialButton( hoverColor: Colors.white12, - child: const Icon( - Icons.content_paste, - color: AppColors.darkHintTextColor, - size: 15.0, - ), shape: const CircleBorder(), onPressed: () { setState(() { @@ -413,6 +398,11 @@ class _SecurityWidgetState extends State { ); }); }, + child: const Icon( + Icons.content_paste, + color: AppColors.darkHintTextColor, + size: 15.0, + ), ), suffixIconConstraints: const BoxConstraints( maxWidth: 45.0, @@ -428,11 +418,6 @@ class _SecurityWidgetState extends State { hintText: 'Enter public key', suffixIcon: RawMaterialButton( hoverColor: Colors.white12, - child: const Icon( - Icons.content_paste, - color: AppColors.darkHintTextColor, - size: 15.0, - ), shape: const CircleBorder(), onPressed: () { setState(() { @@ -444,6 +429,11 @@ class _SecurityWidgetState extends State { ); }); }, + child: const Icon( + Icons.content_paste, + color: AppColors.darkHintTextColor, + size: 15.0, + ), ), suffixIconConstraints: const BoxConstraints( maxWidth: 45.0, @@ -517,7 +507,7 @@ class _SecurityWidgetState extends State { _toBeSignedFilePath = path; }); }, - textStyle: Theme.of(context).textTheme.subtitle1, + textStyle: Theme.of(context).textTheme.titleMedium, key: _signSelectFileWidgetKey, ), Visibility( @@ -576,11 +566,11 @@ class _SecurityWidgetState extends State { void _onSignFileButtonPressed() async { try { _signFileButtonKey.currentState?.animateForward(); - File _droppedFile = File( + File droppedFile = File( _toBeSignedFilePath!, ); List fileSignature = await zenon!.defaultKeyPair!.sign(Crypto.digest( - await _droppedFile.readAsBytes(), + await droppedFile.readAsBytes(), )); setState(() { _fileHashController.text = BytesUtils.bytesToHex(fileSignature); @@ -603,7 +593,7 @@ class _SecurityWidgetState extends State { _toBeVerifiedFilePath = path; }); }, - textStyle: Theme.of(context).textTheme.subtitle1, + textStyle: Theme.of(context).textTheme.titleMedium, key: _verifySelectFileWidgetKey, ), Visibility( @@ -633,11 +623,6 @@ class _SecurityWidgetState extends State { hintText: 'Enter signed hash', suffixIcon: RawMaterialButton( hoverColor: Colors.white12, - child: const Icon( - Icons.content_paste, - color: AppColors.darkHintTextColor, - size: 15.0, - ), shape: const CircleBorder(), onPressed: () { setState(() { @@ -649,6 +634,11 @@ class _SecurityWidgetState extends State { ); }); }, + child: const Icon( + Icons.content_paste, + color: AppColors.darkHintTextColor, + size: 15.0, + ), ), suffixIconConstraints: const BoxConstraints( maxWidth: 45.0, @@ -664,11 +654,6 @@ class _SecurityWidgetState extends State { hintText: 'Enter public key', suffixIcon: RawMaterialButton( hoverColor: Colors.white12, - child: const Icon( - Icons.content_paste, - color: AppColors.darkHintTextColor, - size: 15.0, - ), shape: const CircleBorder(), onPressed: () { setState(() { @@ -680,6 +665,11 @@ class _SecurityWidgetState extends State { ); }); }, + child: const Icon( + Icons.content_paste, + color: AppColors.darkHintTextColor, + size: 15.0, + ), ), suffixIconConstraints: const BoxConstraints( maxWidth: 45.0, diff --git a/lib/widgets/modular_widgets/settings_widgets/settings_widgets.dart b/lib/widgets/modular_widgets/settings_widgets/settings_widgets.dart new file mode 100644 index 00000000..6d49f6cc --- /dev/null +++ b/lib/widgets/modular_widgets/settings_widgets/settings_widgets.dart @@ -0,0 +1,9 @@ +export 'account_chain_stats.dart'; +export 'addresses.dart'; +export 'backup.dart'; +export 'display.dart'; +export 'general.dart'; +export 'node_management.dart'; +export 'peers.dart'; +export 'security.dart'; +export 'wallet_options.dart'; diff --git a/lib/widgets/modular_widgets/settings_widgets/wallet_options.dart b/lib/widgets/modular_widgets/settings_widgets/wallet_options.dart index 5d761db0..bef058cd 100644 --- a/lib/widgets/modular_widgets/settings_widgets/wallet_options.dart +++ b/lib/widgets/modular_widgets/settings_widgets/wallet_options.dart @@ -1,20 +1,16 @@ import 'dart:io'; -import 'dart:typed_data'; -import 'package:feedback/feedback.dart'; import 'package:flutter/material.dart'; -import 'package:share_plus/share_plus.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/reset_wallet_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/splash_screen.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/swap/swap_info_screen.dart'; +import 'package:launch_at_startup/launch_at_startup.dart'; +import 'package:package_info_plus/package_info_plus.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/main.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/device_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/settings_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_expandable_panel.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:znn_sdk_dart/znn_sdk_dart.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class WalletOptions extends StatefulWidget { final VoidCallback onResyncWalletPressed; @@ -22,10 +18,26 @@ class WalletOptions extends StatefulWidget { const WalletOptions(this.onResyncWalletPressed, {Key? key}) : super(key: key); @override - _WalletOptionsState createState() => _WalletOptionsState(); + State createState() => _WalletOptionsState(); } class _WalletOptionsState extends State { + bool? _launchAtStartup; + bool? _enableDesktopNotifications; + + @override + void initState() { + super.initState(); + _launchAtStartup = sharedPrefsService!.get( + kLaunchAtStartupKey, + defaultValue: kLaunchAtStartupDefaultValue, + ); + _enableDesktopNotifications = sharedPrefsService!.get( + kEnableDesktopNotificationsKey, + defaultValue: kEnableDesktopNotificationsDefaultValue, + ); + } + @override Widget build(BuildContext context) { return CardScaffold( @@ -41,8 +53,7 @@ class _WalletOptionsState extends State { children: [ CustomExpandablePanel('Delete cache', _getDeleteCacheExpandedWidget()), CustomExpandablePanel('Reset wallet', _getResetWalletExpandedWidget()), - CustomExpandablePanel('Swap wallet', _getSwapWalletExpandedWidget()), - CustomExpandablePanel('Provide feedback', _getProvideFeedbackWidget()), + CustomExpandablePanel('Preferences', _getPreferencesExpandedWidget()), ], ); } @@ -54,7 +65,7 @@ class _WalletOptionsState extends State { Text( 'This option will erase the wallet files. Make sure you have a ' 'backup first', - style: Theme.of(context).textTheme.subtitle2, + style: Theme.of(context).textTheme.titleSmall, ), kVerticalSpacing, Center( @@ -70,38 +81,13 @@ class _WalletOptionsState extends State { ); } - Widget _getSwapWalletExpandedWidget() { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'This option will start the swap procedure', - style: Theme.of(context).textTheme.subtitle2, - ), - kVerticalSpacing, - Center( - child: SettingsButton( - onPressed: () { - NavigationUtils.push( - context, - const SwapInfoScreen(), - ); - }, - text: 'Swap wallet', - ), - ), - kVerticalSpacing, - ], - ); - } - Widget _getDeleteCacheExpandedWidget() { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'This option will delete the wallet cache and close the application', - style: Theme.of(context).textTheme.subtitle2, + style: Theme.of(context).textTheme.titleSmall, ), kVerticalSpacing, Center( @@ -121,68 +107,123 @@ class _WalletOptionsState extends State { ); } - Widget _getProvideFeedbackWidget() { + Widget _getPreferencesExpandedWidget() { return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ + _getLaunchAtStartupWidget(), + _getEnableDesktopNotifications(), + ], + ); + } + + Widget _getLaunchAtStartupWidget() { + return Row( + children: [ Text( - 'This option will open a feedback utility window', - style: Theme.of(context).textTheme.subtitle2, + 'Launch at startup ', + style: Theme.of(context).textTheme.bodyMedium, ), - kVerticalSpacing, - Center( - child: SettingsButton( - onPressed: () { - BetterFeedback.of(context).show( - (feedback) async { - try { - _shareFeedbackScreenshot(feedback.screenshot); - } catch (e) { - NotificationUtils.sendNotificationError( - e, - 'Error while sharing feedback', - ); - } - }, - ); - }, - text: 'Provide feedback', + SyriusCheckbox( + onChanged: (value) { + setState(() { + _launchAtStartup = value; + _changeLaunchAtStartupStatus(value ?? false); + }); + }, + value: _launchAtStartup, + context: context, + ), + ], + ); + } + + Future _setupLaunchAtStartup() async { + PackageInfo packageInfo = await PackageInfo.fromPlatform(); + launchAtStartup.setup( + appName: packageInfo.appName, + appPath: Platform.resolvedExecutable, + ); + } + + Future _changeLaunchAtStartupStatus(bool enabled) async { + try { + await _setupLaunchAtStartup(); + if (enabled) { + await launchAtStartup.enable(); + } else { + await launchAtStartup.disable(); + } + await _saveLaunchAtStartupValueToCache(enabled); + _sendLaunchAtStartupStatusNotification(enabled); + } on Exception catch (e) { + NotificationUtils.sendNotificationError( + e, + 'Something went wrong while setting launch at startup preference', + ); + } + } + + Future _saveLaunchAtStartupValueToCache(bool enabled) async { + await sharedPrefsService!.put( + kLaunchAtStartupKey, + enabled, + ); + } + + void _sendLaunchAtStartupStatusNotification(bool enabled) { + sl.get().addNotification( + WalletNotification( + title: 'Launch startup ${enabled ? 'enabled' : 'disabled'}', + details: + 'Launch at startup preference was ${enabled ? 'enabled' : 'disabled'}', + timestamp: DateTime.now().millisecondsSinceEpoch, + type: NotificationType.paymentSent, ), + ); + } + + Widget _getEnableDesktopNotifications() { + return Row( + children: [ + Text( + 'Enable desktop notifications ', + style: Theme.of(context).textTheme.bodyMedium, + ), + SyriusCheckbox( + onChanged: (value) { + setState(() { + _enableDesktopNotifications = value; + _changeEnableDesktopNotificationsStatus(value ?? false); + }); + }, + value: _enableDesktopNotifications, + context: context, ), ], ); } - void _shareFeedbackScreenshot(Uint8List feedbackScreenshot) async { - final String screenshotFilePath = znnDefaultCacheDirectory.path + - Platform.pathSeparator + - 'feedback_' + - DateTime.now().millisecondsSinceEpoch.toString() + - '.png'; - final File screenshotFile = File(screenshotFilePath); - await screenshotFile.writeAsBytes(feedbackScreenshot); - var screenshotFilePathList = []; - screenshotFilePathList.clear(); - screenshotFilePathList.add(screenshotFile.absolute.path); - if (screenshotFilePath.isNotEmpty) { - await Share.shareFiles(screenshotFilePathList, - text: 'Feedback provided at ' + - DateTime.now().millisecondsSinceEpoch.toString() + - ' running on ' + - DeviceUtils.getDeviceInfo().toString() + - ' syrius wallet version ' + - DeviceUtils.getPackageInfo().toString(), - subject: 'Syrius wallet feedback'); - } else { - await Share.share( - 'Feedback provided at ' + - DateTime.now().millisecondsSinceEpoch.toString() + - ' running on ' + - DeviceUtils.getDeviceInfo().toString() + - ' syrius wallet version ' + - DeviceUtils.getPackageInfo().toString(), - subject: 'Syrius wallet feedback', + Future _changeEnableDesktopNotificationsStatus(bool enabled) async { + try { + await sharedPrefsService!.put(kEnableDesktopNotificationsKey, enabled); + _sendEnabledDesktopNotificationsStatusNotification(enabled); + } on Exception catch (e) { + NotificationUtils.sendNotificationError( + e, + 'Something went wrong while setting desktop notifications preference', ); } } + + void _sendEnabledDesktopNotificationsStatusNotification(bool enabled) { + sl.get().addNotification( + WalletNotification( + title: 'Desktop notifications ${enabled ? 'enabled' : 'disabled'}', + details: + 'Desktop notifications preference was ${enabled ? 'enabled' : 'disabled'}', + timestamp: DateTime.now().millisecondsSinceEpoch, + type: NotificationType.paymentSent, + ), + ); + } } diff --git a/lib/widgets/modular_widgets/staking_widgets/stake_collect.dart b/lib/widgets/modular_widgets/staking_widgets/stake_collect.dart index 5559b40a..0e7da400 100644 --- a/lib/widgets/modular_widgets/staking_widgets/stake_collect.dart +++ b/lib/widgets/modular_widgets/staking_widgets/stake_collect.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/staking/staking_rewards_history_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/staking/staking_uncollected_rewards_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/account_block_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; @@ -8,11 +7,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/number_animation.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class StakeCollect extends StatefulWidget { @@ -24,7 +19,7 @@ class StakeCollect extends StatefulWidget { }) : super(key: key); @override - _StakeCollectState createState() => _StakeCollectState(); + State createState() => _StakeCollectState(); } class _StakeCollectState extends State { @@ -72,7 +67,7 @@ class _StakeCollectState extends State { end: uncollectedReward.qsrAmount.addDecimals(qsrDecimals), isInt: false, after: ' ${kQsrCoin.symbol}', - style: Theme.of(context).textTheme.headline1!.copyWith( + style: Theme.of(context).textTheme.headlineLarge!.copyWith( color: AppColors.qsrColor, fontSize: 30.0, ), diff --git a/lib/widgets/modular_widgets/staking_widgets/staking_list/staking_list.dart b/lib/widgets/modular_widgets/staking_widgets/staking_list/staking_list.dart index cefbc578..7cb4af25 100644 --- a/lib/widgets/modular_widgets/staking_widgets/staking_list/staking_list.dart +++ b/lib/widgets/modular_widgets/staking_widgets/staking_list/staking_list.dart @@ -1,17 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/staking/cancel_stake_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/staking/staking_list_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/cancel_timer.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/formatted_amount_with_tooltip.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/infinite_scroll_table.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class StakingList extends StatefulWidget { @@ -26,7 +21,7 @@ class StakingList extends StatefulWidget { } class _StakingListState extends State { - final List? _stakingList = []; + final List _stakingList = []; bool _sortAscending = true; @@ -77,7 +72,7 @@ class _StakingListState extends State { tokenSymbol: kZnnCoin.symbol, builder: (formattedAmount, tokenSymbol) => Text( '$formattedAmount $tokenSymbol', - style: Theme.of(context).textTheme.subtitle1!.copyWith( + style: Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.subtitleColor, ), ), @@ -129,19 +124,19 @@ class _StakingListState extends State { bool isSelected, String stakeHash, ) { - final GlobalKey _cancelButtonKey = GlobalKey(); + final GlobalKey cancelButtonKey = GlobalKey(); return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (event) { if (event != null) { - _cancelButtonKey.currentState?.animateReverse(); + cancelButtonKey.currentState?.animateReverse(); bloc.refreshResults(); } }, onError: (error) { - _cancelButtonKey.currentState?.animateReverse(); + cancelButtonKey.currentState?.animateReverse(); NotificationUtils.sendNotificationError( error, 'Error while cancelling stake', @@ -152,7 +147,7 @@ class _StakingListState extends State { builder: (_, model, __) => _getCancelButton( model, stakeHash, - _cancelButtonKey, + cancelButtonKey, ), viewModelBuilder: () => CancelStakeBloc(), ); @@ -176,8 +171,8 @@ class _StakingListState extends State { size: 11.0, color: AppColors.errorColor, ), - textStyle: Theme.of(context).textTheme.subtitle2!.copyWith( - color: Theme.of(context).textTheme.bodyText1!.color, + textStyle: Theme.of(context).textTheme.titleSmall!.copyWith( + color: Theme.of(context).textTheme.bodyLarge!.color, ), ); } @@ -186,36 +181,36 @@ class _StakingListState extends State { switch (columnName) { case 'Amount': _sortAscending - ? _stakingList!.sort((a, b) => a.amount.compareTo(b.amount)) - : _stakingList!.sort((a, b) => b.amount.compareTo(a.amount)); + ? _stakingList.sort((a, b) => a.amount.compareTo(b.amount)) + : _stakingList.sort((a, b) => b.amount.compareTo(a.amount)); break; case 'Staking duration': _sortAscending - ? _stakingList!.sort( + ? _stakingList.sort( (a, b) => (a.expirationTimestamp - a.startTimestamp) .compareTo(b.expirationTimestamp - b.startTimestamp), ) - : _stakingList!.sort( + : _stakingList.sort( (a, b) => (b.expirationTimestamp - b.startTimestamp) .compareTo(a.expirationTimestamp - a.startTimestamp), ); break; case 'Recipient': _sortAscending - ? _stakingList!.sort((a, b) => a.address.compareTo(b.address)) - : _stakingList!.sort((a, b) => b.address.compareTo(a.address)); + ? _stakingList.sort((a, b) => a.address.compareTo(b.address)) + : _stakingList.sort((a, b) => b.address.compareTo(a.address)); break; case 'Expiration': _sortAscending - ? _stakingList!.sort((a, b) => + ? _stakingList.sort((a, b) => a.expirationTimestamp.compareTo(b.expirationTimestamp)) - : _stakingList!.sort((a, b) => + : _stakingList.sort((a, b) => b.expirationTimestamp.compareTo(a.expirationTimestamp)); break; default: _sortAscending - ? _stakingList!.sort((a, b) => a.address.compareTo(b.address)) - : _stakingList!.sort((a, b) => b.address.compareTo(a.address)); + ? _stakingList.sort((a, b) => a.address.compareTo(b.address)) + : _stakingList.sort((a, b) => b.address.compareTo(a.address)); break; } diff --git a/lib/widgets/modular_widgets/staking_widgets/staking_options/staking_options.dart b/lib/widgets/modular_widgets/staking_widgets/staking_options/staking_options.dart index f2099eea..857c83ab 100644 --- a/lib/widgets/modular_widgets/staking_widgets/staking_options/staking_options.dart +++ b/lib/widgets/modular_widgets/staking_widgets/staking_options/staking_options.dart @@ -1,9 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/balance_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/staking/staking_list_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/staking/staking_options_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; @@ -13,14 +11,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/amount_suffix_widgets.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/disabled_address_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/stepper_utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class StakingOptions extends StatefulWidget { @@ -162,7 +153,7 @@ class _StakingOptionsState extends State { Widget _getStakeForQsrViewModel() { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (event) { if (event != null) { @@ -235,7 +226,7 @@ class _StakingOptionsState extends State { child: Text( '${duration.inSeconds ~/ stakeTimeUnitSec} $stakeUnitDurationName' '${(duration.inSeconds ~/ stakeTimeUnitSec) > 1 ? 's' : ''}', - style: Theme.of(context).textTheme.bodyText1!.copyWith( + style: Theme.of(context).textTheme.bodyLarge!.copyWith( fontSize: 12.0, color: _selectedStakeDuration?.inDays == duration.inDays ? AppColors.znnColor diff --git a/lib/widgets/modular_widgets/staking_widgets/staking_rewards.dart b/lib/widgets/modular_widgets/staking_widgets/staking_rewards.dart index 56116469..1e2a4cf2 100644 --- a/lib/widgets/modular_widgets/staking_widgets/staking_rewards.dart +++ b/lib/widgets/modular_widgets/staking_widgets/staking_rewards.dart @@ -1,9 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/staking/staking_rewards_history_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/charts/staking_rewards_chart.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class StakingRewards extends StatefulWidget { diff --git a/lib/widgets/modular_widgets/staking_widgets/staking_widgets.dart b/lib/widgets/modular_widgets/staking_widgets/staking_widgets.dart new file mode 100644 index 00000000..27d91560 --- /dev/null +++ b/lib/widgets/modular_widgets/staking_widgets/staking_widgets.dart @@ -0,0 +1,4 @@ +export 'stake_collect.dart'; +export 'staking_list/staking_list.dart'; +export 'staking_options/staking_options.dart'; +export 'staking_rewards.dart'; diff --git a/lib/widgets/modular_widgets/token_widgets/create_token.dart b/lib/widgets/modular_widgets/token_widgets/create_token.dart index 3ca8668a..f4ee7968 100644 --- a/lib/widgets/modular_widgets/token_widgets/create_token.dart +++ b/lib/widgets/modular_widgets/token_widgets/create_token.dart @@ -1,10 +1,8 @@ import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/stepper_screen.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/token_widgets/token_stepper.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/elevated_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class CreateToken extends StatefulWidget { final VoidCallback onStepperNotificationSeeMorePressed; diff --git a/lib/widgets/modular_widgets/token_widgets/token_balance.dart b/lib/widgets/modular_widgets/token_widgets/token_balance.dart index 25a09ca9..953f947d 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_balance.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_balance.dart @@ -1,14 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/balance_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/color_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/formatted_amount_with_tooltip.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class TokenBalance extends StatefulWidget { @@ -89,7 +86,7 @@ class _TokenBalanceState extends State { children: [ Text( '$formattedAmount $tokenSymbol', - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), ], ); @@ -113,7 +110,7 @@ class _TokenBalanceState extends State { children: [ Text( '● ', - style: Theme.of(context).textTheme.bodyText1!.copyWith( + style: Theme.of(context).textTheme.bodyLarge!.copyWith( color: ColorUtils.getTokenColor( _newTokenIds[index].token!.tokenStandard), ), diff --git a/lib/widgets/modular_widgets/token_widgets/token_card.dart b/lib/widgets/modular_widgets/token_widgets/token_card.dart index a28dfa5e..fbfa688c 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_card.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_card.dart @@ -5,14 +5,9 @@ import 'package:flip_card/flip_card.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/balance_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/tokens/burn_token_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/tokens/mint_token_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/tokens/transfer_ownership_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/color_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; @@ -22,17 +17,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/token_widgets/token_favorite.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/stepper_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/chart/standard_pie_chart.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/formatted_amount_with_tooltip.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/amount_suffix_widgets.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/stepper_utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; enum TokenCardBackVersion { @@ -52,7 +37,7 @@ class TokenCard extends StatefulWidget { }) : super(key: key); @override - _TokenCardState createState() => _TokenCardState(); + State createState() => _TokenCardState(); } class _TokenCardState extends State { @@ -145,7 +130,7 @@ class _TokenCardState extends State { message: '${widget.token.name}: ${widget.token.symbol}', child: Text( widget.token.symbol.toUpperCase(), - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), ), const SizedBox( @@ -164,7 +149,7 @@ class _TokenCardState extends State { Expanded( child: Text( widget.token.tokenStandard.toString().toUpperCase(), - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ), CopyToClipboardIcon( @@ -247,7 +232,7 @@ class _TokenCardState extends State { ), Text( '${widget.token.decimals} decimals', - style: Theme.of(context).textTheme.subtitle2, + style: Theme.of(context).textTheme.titleSmall, ), ], ), @@ -264,7 +249,7 @@ class _TokenCardState extends State { kDefaultAddressList.contains(widget.token.owner.toString()) ? kAddressLabelMap[widget.token.owner.toString()]! : widget.token.owner.toShortString(), - style: Theme.of(context).textTheme.subtitle2, + style: Theme.of(context).textTheme.titleSmall, ), CopyToClipboardIcon(widget.token.owner.toString()), ], @@ -277,7 +262,7 @@ class _TokenCardState extends State { materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, shape: const CircleBorder(), onPressed: () => - NavigationUtils.launchUrl(widget.token.domain, context), + NavigationUtils.openUrl(widget.token.domain, context), child: Tooltip( message: 'Visit ${widget.token.domain}', child: Container( @@ -375,7 +360,7 @@ class _TokenCardState extends State { tokenSymbol: token.symbol, builder: (formattedAmount, tokenSymbol) => Text( '$formattedAmount $tokenSymbol', - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, textAlign: TextAlign.center, ), ), @@ -441,7 +426,7 @@ class _TokenCardState extends State { Widget _getBurnButtonViewModel() { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (event) { setState(() { @@ -602,7 +587,7 @@ class _TokenCardState extends State { Widget _getMintButtonViewModel() { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen((event) { setState(() { _beneficiaryAddressKey.currentState!.reset(); @@ -731,7 +716,7 @@ class _TokenCardState extends State { Widget _getTransferOwnershipButtonViewModel() { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen((event) { _sendTransferSuccessfulNotification(); if (mounted) { diff --git a/lib/widgets/modular_widgets/token_widgets/token_favorite.dart b/lib/widgets/modular_widgets/token_widgets/token_favorite.dart index f07d237b..8e990094 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_favorite.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_favorite.dart @@ -1,13 +1,12 @@ import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class TokenFavorite extends StatefulWidget { @@ -21,7 +20,7 @@ class TokenFavorite extends StatefulWidget { }) : super(key: key); @override - _TokenFavoriteState createState() => _TokenFavoriteState(); + State createState() => _TokenFavoriteState(); } class _TokenFavoriteState extends State { diff --git a/lib/widgets/modular_widgets/token_widgets/token_map.dart b/lib/widgets/modular_widgets/token_widgets/token_map.dart index 479b6bfe..ef75db13 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_map.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_map.dart @@ -3,13 +3,9 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:rxdart/rxdart.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/tokens/token_map_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/token_widgets/token_card.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class TokenMap extends StatefulWidget { diff --git a/lib/widgets/modular_widgets/token_widgets/token_stepper.dart b/lib/widgets/modular_widgets/token_widgets/token_stepper.dart index 91c315ec..f1d2a000 100644 --- a/lib/widgets/modular_widgets/token_widgets/token_stepper.dart +++ b/lib/widgets/modular_widgets/token_widgets/token_stepper.dart @@ -4,10 +4,9 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:lottie/lottie.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/dashboard/balance_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/tokens/issue_token_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/new_token_data.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; @@ -16,19 +15,9 @@ import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/stepper_button.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_material_stepper.dart' as custom_material_stepper; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_slider.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dotted_border_info_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/standard_tooltip_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/disabled_address_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/plasma_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/stepper_utils.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; enum TokenStepperStep { @@ -235,7 +224,7 @@ class _TokenStepperState extends State { stepTitle: 'Token Details', stepContent: _getTokenDetailsStepContent(context, accountInfo), stepSubtitle: - '${_tokenNameController.text} ' + _tokenSymbolController.text, + '${_tokenNameController.text} ${_tokenSymbolController.text}', stepState: StepperUtils.getStepState( TokenStepperStep.tokenDetails.index, _lastCompletedStep?.index, @@ -374,6 +363,7 @@ class _TokenStepperState extends State { const StandardTooltipIcon( 'Token status: utility or ' 'non-utility (e.g. security token)', + Icons.help, iconColor: AppColors.ztsColor, ), ], @@ -645,7 +635,7 @@ class _TokenStepperState extends State { children: [ Text( 'This will be your issuance address', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), kVerticalSpacing, Row( @@ -676,11 +666,11 @@ class _TokenStepperState extends State { _saveProgressAndNavigateToNextStep(TokenStepperStep.tokenCreation); } - void _saveProgressAndNavigateToNextStep(TokenStepperStep _completedStep) { + void _saveProgressAndNavigateToNextStep(TokenStepperStep completedStep) { setState(() { - _lastCompletedStep = _completedStep; + _lastCompletedStep = completedStep; if (_lastCompletedStep!.index + 1 < _numSteps) { - _currentStep = TokenStepperStep.values[_completedStep.index + 1]; + _currentStep = TokenStepperStep.values[completedStep.index + 1]; } }); } @@ -720,7 +710,7 @@ class _TokenStepperState extends State { Widget _getIssueTokenViewModel() { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (response) { _createButtonKey.currentState?.animateReverse(); @@ -866,6 +856,7 @@ class _TokenStepperState extends State { ), const StandardTooltipIcon( 'Whether or not this token is mintable after creation', + Icons.help, iconColor: AppColors.ztsColor, ), ], @@ -895,6 +886,7 @@ class _TokenStepperState extends State { ), const StandardTooltipIcon( 'Whether or not only the token owner can burn it', + Icons.help, iconColor: AppColors.ztsColor, ), ], diff --git a/lib/widgets/modular_widgets/token_widgets/token_widgets.dart b/lib/widgets/modular_widgets/token_widgets/token_widgets.dart new file mode 100644 index 00000000..c28b0cc2 --- /dev/null +++ b/lib/widgets/modular_widgets/token_widgets/token_widgets.dart @@ -0,0 +1,6 @@ +export 'create_token.dart'; +export 'token_balance.dart'; +export 'token_card.dart'; +export 'token_favorite.dart'; +export 'token_map.dart'; +export 'token_stepper.dart'; diff --git a/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart b/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart index e69134b3..6c875ab4 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart @@ -1,15 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/sentinels/sentinel_list_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/transfer/latest_transactions_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/color_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/widget_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/formatted_amount_with_tooltip.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/infinite_scroll_table.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; enum LatestTransactionsVersion { standard, dashboard, token } @@ -23,7 +20,7 @@ class LatestTransactions extends StatefulWidget { }) : super(key: key); @override - _LatestTransactionsState createState() => _LatestTransactionsState(); + State createState() => _LatestTransactionsState(); } class _LatestTransactionsState extends State { @@ -97,7 +94,7 @@ class _LatestTransactionsState extends State { tokenSymbol: infoBlock.token?.symbol ?? '', builder: (formattedAmount, tokenSymbol) => Text( formattedAmount, - style: Theme.of(context).textTheme.subtitle1!.copyWith( + style: Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.subtitleColor, ), ), @@ -194,7 +191,7 @@ class _LatestTransactionsState extends State { BlockTypeEnum.values[block.blockType], ), textAlign: TextAlign.center, - style: Theme.of(context).textTheme.subtitle2, + style: Theme.of(context).textTheme.titleSmall, ); } @@ -356,7 +353,7 @@ class _LatestTransactionsState extends State { tokenSymbol: infoBlock.token?.symbol ?? '', builder: (formattedAmount, tokenSymbol) => Text( formattedAmount, - style: Theme.of(context).textTheme.subtitle1!.copyWith( + style: Theme.of(context).textTheme.titleMedium!.copyWith( color: AppColors.subtitleColor, ), ), diff --git a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_large.dart b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_large.dart index 35ec2732..cfd09f9b 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_large.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_large.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/tokens/tokens_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; @@ -8,15 +8,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dropdown/addresses_dropdown.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dropdown/coin_dropdown.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/receive_qr_image.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ReceiveLargeCard extends StatefulWidget { @@ -30,7 +22,7 @@ class ReceiveLargeCard extends StatefulWidget { }) : super(key: key); @override - _ReceiveLargeCardState createState() => _ReceiveLargeCardState(); + State createState() => _ReceiveLargeCardState(); } class _ReceiveLargeCardState extends State { @@ -61,7 +53,7 @@ class _ReceiveLargeCardState extends State { Widget build(BuildContext context) { return CardScaffold( title: 'Receive', - titleFontSize: Theme.of(context).textTheme.headline5!.fontSize, + titleFontSize: Theme.of(context).textTheme.headlineSmall!.fontSize, description: 'Manage receiving funds', childBuilder: () => _getTokensStreamBuilder(), ); @@ -128,7 +120,7 @@ class _ReceiveLargeCardState extends State { autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( - validator: InputValidators.validateNumber, + validator: InputValidators.validateAmount, onChanged: (value) => setState(() {}), inputFormatters: FormatUtils.getAmountTextInputFormatters( diff --git a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_medium.dart b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_medium.dart index 6fb2108f..b71bb859 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_medium.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_medium.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/tokens/tokens_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/extensions.dart'; @@ -8,15 +8,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dropdown/addresses_dropdown.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dropdown/coin_dropdown.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/receive_qr_image.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ReceiveMediumCard extends StatefulWidget { @@ -26,7 +18,7 @@ class ReceiveMediumCard extends StatefulWidget { : super(key: key); @override - _ReceiveMediumCardState createState() => _ReceiveMediumCardState(); + State createState() => _ReceiveMediumCardState(); } class _ReceiveMediumCardState extends State { @@ -58,7 +50,7 @@ class _ReceiveMediumCardState extends State { Widget build(BuildContext context) { return CardScaffold( title: 'Receive', - titleFontSize: Theme.of(context).textTheme.headline5!.fontSize, + titleFontSize: Theme.of(context).textTheme.headlineSmall!.fontSize, description: 'Manage receiving funds', childBuilder: () => _getTokensStreamBuilder(), ); @@ -133,7 +125,7 @@ class _ReceiveMediumCardState extends State { key: _amountKey, autovalidateMode: AutovalidateMode.onUserInteraction, child: InputField( - validator: InputValidators.validateNumber, + validator: InputValidators.validateAmount, onChanged: (value) => setState(() {}), inputFormatters: FormatUtils.getAmountTextInputFormatters( diff --git a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_small.dart b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_small.dart index c01c771b..ff1e7bf1 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/receive/receive_small.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/receive/receive_small.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/transfer_icon_legend.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class ReceiveSmallCard extends StatefulWidget { final VoidCallback onPressed; @@ -12,7 +12,7 @@ class ReceiveSmallCard extends StatefulWidget { }) : super(key: key); @override - _ReceiveSmallCardState createState() => _ReceiveSmallCardState(); + State createState() => _ReceiveSmallCardState(); } class _ReceiveSmallCardState extends State { diff --git a/lib/widgets/modular_widgets/transfer_widgets/send/send_large.dart b/lib/widgets/modular_widgets/transfer_widgets/send/send_large.dart index 845426e9..231f0cab 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/send/send_large.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/send/send_large.dart @@ -1,11 +1,8 @@ import 'package:flutter/material.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/transfer/send_payment_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/transfer/transfer_widgets_balance_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/clipboard_utils.dart'; @@ -16,28 +13,15 @@ import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/available_balance.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/send_payment_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dialogs.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dropdown/addresses_dropdown.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dropdown/coin_dropdown.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/amount_suffix_widgets.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class SendLargeCard extends StatefulWidget { final double? cardWidth; final bool? extendIcon; final VoidCallback? onCollapsePressed; - final VoidCallback onOkBridgeWarningDialogPressed; const SendLargeCard({ - required this.onOkBridgeWarningDialogPressed, Key? key, this.cardWidth, this.extendIcon, @@ -45,7 +29,7 @@ class SendLargeCard extends StatefulWidget { }) : super(key: key); @override - _SendLargeCardState createState() => _SendLargeCardState(); + State createState() => _SendLargeCardState(); } class _SendLargeCardState extends State { @@ -74,7 +58,7 @@ class _SendLargeCardState extends State { Widget build(BuildContext context) { return CardScaffold( title: 'Send', - titleFontSize: Theme.of(context).textTheme.headline5!.fontSize, + titleFontSize: Theme.of(context).textTheme.headlineSmall!.fontSize, description: 'Manage sending funds', childBuilder: () => _getBalanceStreamBuilder(), ); @@ -125,11 +109,6 @@ class _SendLargeCardState extends State { controller: _recipientController, validator: (value) => InputValidators.checkAddress(value), suffixIcon: RawMaterialButton( - child: const Icon( - Icons.content_paste, - color: AppColors.darkHintTextColor, - size: 15.0, - ), shape: const CircleBorder(), onPressed: () { ClipboardUtils.pasteToClipboard(context, (String value) { @@ -137,6 +116,11 @@ class _SendLargeCardState extends State { setState(() {}); }); }, + child: const Icon( + Icons.content_paste, + color: AppColors.darkHintTextColor, + size: 15.0, + ), ), suffixIconConstraints: const BoxConstraints( maxWidth: 45.0, @@ -239,26 +223,14 @@ class _SendLargeCardState extends State { void _onSendPaymentPressed(SendPaymentBloc model) { if (_recipientKey.currentState!.validate() && _amountKey.currentState!.validate()) { - if (Address.parse(_recipientController.text) == bridgeAddress) { - showOkDialog( - context: context, - title: 'Send Payment', - description: 'Use the form from the \'Bridge\' tab to swap coins', - onActionButtonPressed: () { - Navigator.pop(context); - widget.onOkBridgeWarningDialogPressed(); - }, - ); - } else { - showDialogWithNoAndYesOptions( - context: context, - title: 'Send Payment', - description: 'Are you sure you want to transfer ' - '${_amountController.text} ${_selectedToken.symbol} to ' - '${AddressUtils.getLabel(_recipientController.text)} ?', - onYesButtonPressed: () => _sendPayment(model), - ); - } + showDialogWithNoAndYesOptions( + context: context, + title: 'Send Payment', + description: 'Are you sure you want to transfer ' + '${_amountController.text} ${_selectedToken.symbol} to ' + '${AddressUtils.getLabel(_recipientController.text)} ?', + onYesButtonPressed: () => _sendPayment(model), + ); } } @@ -338,7 +310,7 @@ class _SendLargeCardState extends State { Widget _getSendPaymentViewModel(AccountInfo? accountInfo) { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { model.stream.listen( (event) { if (event is AccountBlockTemplate) { diff --git a/lib/widgets/modular_widgets/transfer_widgets/send/send_medium.dart b/lib/widgets/modular_widgets/transfer_widgets/send/send_medium.dart index 2fa65d9e..3628555c 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/send/send_medium.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/send/send_medium.dart @@ -1,11 +1,8 @@ import 'package:flutter/material.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/transfer/send_payment_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/transfer/transfer_widgets_balance_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/notification_type.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/clipboard_utils.dart'; @@ -16,16 +13,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/input_validators.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/zts_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/send_payment_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dialogs.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dropdown/coin_dropdown.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/amount_suffix_widgets.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class SendMediumCard extends StatefulWidget { @@ -39,7 +27,7 @@ class SendMediumCard extends StatefulWidget { }) : super(key: key); @override - _SendMediumCardState createState() => _SendMediumCardState(); + State createState() => _SendMediumCardState(); } class _SendMediumCardState extends State { @@ -68,7 +56,7 @@ class _SendMediumCardState extends State { Widget build(BuildContext context) { return CardScaffold( title: 'Send', - titleFontSize: Theme.of(context).textTheme.headline5!.fontSize, + titleFontSize: Theme.of(context).textTheme.headlineSmall!.fontSize, description: 'Manage sending funds', childBuilder: () => _getBalanceStreamBuilder(), ); @@ -120,11 +108,6 @@ class _SendMediumCardState extends State { validator: (value) => InputValidators.checkAddress(value), controller: _recipientController, suffixIcon: RawMaterialButton( - child: const Icon( - Icons.content_paste, - color: AppColors.darkHintTextColor, - size: 15.0, - ), shape: const CircleBorder(), onPressed: () { ClipboardUtils.pasteToClipboard(context, (String value) { @@ -132,6 +115,11 @@ class _SendMediumCardState extends State { setState(() {}); }); }, + child: const Icon( + Icons.content_paste, + color: AppColors.darkHintTextColor, + size: 15.0, + ), ), suffixIconConstraints: const BoxConstraints( maxWidth: 45.0, @@ -190,27 +178,14 @@ class _SendMediumCardState extends State { void _onSendPaymentPressed(SendPaymentBloc model) { if (_recipientKey.currentState!.validate() && _amountKey.currentState!.validate()) { - if (Address.parse(_recipientController.text) == bridgeAddress) { - showOkDialog( - context: context, - title: 'Send Payment', - description: - 'Use the form from the Bridge tab in order to perform the swap', - onActionButtonPressed: () { - Navigator.pop(context); - widget.onOkBridgeWarningDialogPressed(); - }, - ); - } else { - showDialogWithNoAndYesOptions( - context: context, - title: 'Send Payment', - description: 'Are you sure you want to transfer ' - '${_amountController.text} ${_selectedToken.symbol} to ' - '${AddressUtils.getLabel(_recipientController.text)} ?', - onYesButtonPressed: () => _sendPayment(model), - ); - } + showDialogWithNoAndYesOptions( + context: context, + title: 'Send Payment', + description: 'Are you sure you want to transfer ' + '${_amountController.text} ${_selectedToken.symbol} to ' + '${AddressUtils.getLabel(_recipientController.text)} ?', + onYesButtonPressed: () => _sendPayment(model), + ); } } @@ -275,8 +250,8 @@ class _SendMediumCardState extends State { Widget _getSendPaymentViewModel(AccountInfo? accountInfo) { return ViewModelBuilder.reactive( - fireOnModelReadyOnce: true, - onModelReady: (model) { + fireOnViewModelReadyOnce: true, + onViewModelReady: (model) { model.stream.listen( (event) { if (event is AccountBlockTemplate) { diff --git a/lib/widgets/modular_widgets/transfer_widgets/send/send_small.dart b/lib/widgets/modular_widgets/transfer_widgets/send/send_small.dart index 4734f777..fe6f3595 100644 --- a/lib/widgets/modular_widgets/transfer_widgets/send/send_small.dart +++ b/lib/widgets/modular_widgets/transfer_widgets/send/send_small.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/transfer_icon_legend.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class SendSmallCard extends StatefulWidget { final VoidCallback onClicked; @@ -12,7 +12,7 @@ class SendSmallCard extends StatefulWidget { }) : super(key: key); @override - _SendSmallCardState createState() => _SendSmallCardState(); + State createState() => _SendSmallCardState(); } class _SendSmallCardState extends State { diff --git a/lib/widgets/modular_widgets/transfer_widgets/transfer_widgets.dart b/lib/widgets/modular_widgets/transfer_widgets/transfer_widgets.dart new file mode 100644 index 00000000..7e7f8887 --- /dev/null +++ b/lib/widgets/modular_widgets/transfer_widgets/transfer_widgets.dart @@ -0,0 +1,7 @@ +export 'latest_transactions/latest_transactions_transfer_widget.dart'; +export 'receive/receive_large.dart'; +export 'receive/receive_medium.dart'; +export 'receive/receive_small.dart'; +export 'send/send_large.dart'; +export 'send/send_medium.dart'; +export 'send/send_small.dart'; diff --git a/lib/widgets/reusable_widgets/access_wallet_fluid_cell.dart b/lib/widgets/reusable_widgets/access_wallet_fluid_cell.dart index fb73303e..c969c65c 100644 --- a/lib/widgets/reusable_widgets/access_wallet_fluid_cell.dart +++ b/lib/widgets/reusable_widgets/access_wallet_fluid_cell.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:layout/layout.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class AccessWalletFluidCell extends FluidCell { final VoidCallback? onPressed; @@ -45,7 +45,8 @@ class AccessWalletFluidCell extends FluidCell { color: Colors.transparent, child: SvgPicture.asset( buttonIconLocation, - color: AppColors.znnColor, + colorFilter: const ColorFilter.mode( + AppColors.znnColor, BlendMode.srcIn), ), ), Padding( @@ -56,7 +57,7 @@ class AccessWalletFluidCell extends FluidCell { child: Text( buttonText, textAlign: TextAlign.center, - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), ), ], diff --git a/lib/widgets/reusable_widgets/amount_info_column.dart b/lib/widgets/reusable_widgets/amount_info_column.dart index b45a509e..f703c9dd 100644 --- a/lib/widgets/reusable_widgets/amount_info_column.dart +++ b/lib/widgets/reusable_widgets/amount_info_column.dart @@ -15,11 +15,11 @@ class AmountInfoColumn extends Column { children: [ Text( tokenSymbol, - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), Text( amount, - style: Theme.of(context).textTheme.subtitle2, + style: Theme.of(context).textTheme.titleSmall, ), ], ); diff --git a/lib/widgets/reusable_widgets/buttons/buttons.dart b/lib/widgets/reusable_widgets/buttons/buttons.dart new file mode 100644 index 00000000..e6b268e6 --- /dev/null +++ b/lib/widgets/reusable_widgets/buttons/buttons.dart @@ -0,0 +1,9 @@ +export 'elevated_button.dart'; +export 'loading_button.dart'; +export 'material_icon_button.dart'; +export 'onboarding_button.dart'; +export 'outlined_button.dart'; +export 'send_payment_button.dart'; +export 'settings_button.dart'; +export 'stepper_button.dart'; +export 'transfer_toggle_card_size_button.dart'; diff --git a/lib/widgets/reusable_widgets/buttons/elevated_button.dart b/lib/widgets/reusable_widgets/buttons/elevated_button.dart index 512e6e58..711bda21 100644 --- a/lib/widgets/reusable_widgets/buttons/elevated_button.dart +++ b/lib/widgets/reusable_widgets/buttons/elevated_button.dart @@ -56,7 +56,7 @@ class _SyriusElevatedButtonState extends State { ), Text( widget.text, - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.headlineSmall, ), ], ), diff --git a/lib/widgets/reusable_widgets/buttons/loading_button.dart b/lib/widgets/reusable_widgets/buttons/loading_button.dart index 960435e0..28fe64ea 100644 --- a/lib/widgets/reusable_widgets/buttons/loading_button.dart +++ b/lib/widgets/reusable_widgets/buttons/loading_button.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_theme.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/outlined_button.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; enum ButtonState { busy, idle } @@ -80,7 +80,7 @@ class LoadingButton extends StatefulWidget { minimumSize: kSettingsButtonMinSize, key: key, paddingAroundChild: EdgeInsets.zero, - textStyle: kText2TextStyle, + textStyle: kBodyMediumTextStyle, ); factory LoadingButton.onboarding({ @@ -124,6 +124,7 @@ class LoadingButton extends StatefulWidget { minimumSize: minimumSize, outlineColor: outlineColor, textStyle: textStyle, + key: key, child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, @@ -138,7 +139,6 @@ class LoadingButton extends StatefulWidget { ), ], ), - key: key, ); @override @@ -229,6 +229,7 @@ class LoadingButtonState extends State widget.minimumSize.height / 2, _animation.value, )!, + padding: widget.paddingAroundChild, child: btnState == ButtonState.idle ? widget.child ?? Text(widget.text!) : const SizedBox( @@ -239,7 +240,6 @@ class LoadingButtonState extends State valueColor: AlwaysStoppedAnimation(AppColors.znnColor), ), ), - padding: widget.paddingAroundChild, ); } diff --git a/lib/widgets/reusable_widgets/buttons/material_icon_button.dart b/lib/widgets/reusable_widgets/buttons/material_icon_button.dart index d5bcbfdb..4a05ec33 100644 --- a/lib/widgets/reusable_widgets/buttons/material_icon_button.dart +++ b/lib/widgets/reusable_widgets/buttons/material_icon_button.dart @@ -26,13 +26,13 @@ class MaterialIconButton extends StatelessWidget { hoverColor: hoverColor, constraints: const BoxConstraints.tightForFinite(), padding: EdgeInsets.all(padding), + shape: const CircleBorder(), + onPressed: onPressed, child: Icon( iconData, color: iconColor, size: 15.0, ), - shape: const CircleBorder(), - onPressed: onPressed, ); } } diff --git a/lib/widgets/reusable_widgets/buttons/onboarding_button.dart b/lib/widgets/reusable_widgets/buttons/onboarding_button.dart index 1e9d0a7f..d3366505 100644 --- a/lib/widgets/reusable_widgets/buttons/onboarding_button.dart +++ b/lib/widgets/reusable_widgets/buttons/onboarding_button.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/outlined_button.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class OnboardingButton extends MyOutlinedButton { const OnboardingButton({ diff --git a/lib/widgets/reusable_widgets/buttons/outlined_button.dart b/lib/widgets/reusable_widgets/buttons/outlined_button.dart index f1d68bc2..0083d47c 100644 --- a/lib/widgets/reusable_widgets/buttons/outlined_button.dart +++ b/lib/widgets/reusable_widgets/buttons/outlined_button.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class MyOutlinedButton extends StatefulWidget { final String? text; @@ -61,17 +61,8 @@ class MyOutlinedButtonState extends State { Widget build(BuildContext context) { return OutlinedButton( onPressed: _showLoading ? null : widget.onPressed, - child: _showLoading - ? const SyriusLoadingWidget( - size: 25.0, - ) - : widget.text != null - ? Text( - widget.text!, - ) - : widget.child!, style: OutlinedButton.styleFrom( - primary: widget.textColor, + foregroundColor: widget.textColor, padding: widget.padding, minimumSize: widget.minimumSize, textStyle: widget.textStyle, @@ -106,6 +97,15 @@ class MyOutlinedButtonState extends State { }, ), ), + child: _showLoading + ? const SyriusLoadingWidget( + size: 25.0, + ) + : widget.text != null + ? Text( + widget.text!, + ) + : widget.child!, ); } diff --git a/lib/widgets/reusable_widgets/buttons/send_payment_button.dart b/lib/widgets/reusable_widgets/buttons/send_payment_button.dart index 15af4950..e69d58bd 100644 --- a/lib/widgets/reusable_widgets/buttons/send_payment_button.dart +++ b/lib/widgets/reusable_widgets/buttons/send_payment_button.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class SendPaymentButton extends LoadingButton { const SendPaymentButton({ diff --git a/lib/widgets/reusable_widgets/buttons/settings_button.dart b/lib/widgets/reusable_widgets/buttons/settings_button.dart index f1213e01..68113888 100644 --- a/lib/widgets/reusable_widgets/buttons/settings_button.dart +++ b/lib/widgets/reusable_widgets/buttons/settings_button.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_theme.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/outlined_button.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class SettingsButton extends MyOutlinedButton { const SettingsButton({ @@ -12,7 +12,7 @@ class SettingsButton extends MyOutlinedButton { key: key, onPressed: onPressed, text: text, - textStyle: kText2TextStyle, + textStyle: kBodyMediumTextStyle, minimumSize: kSettingsButtonMinSize, ); } diff --git a/lib/widgets/reusable_widgets/buttons/stepper_button.dart b/lib/widgets/reusable_widgets/buttons/stepper_button.dart index 912bef9d..9df760cd 100644 --- a/lib/widgets/reusable_widgets/buttons/stepper_button.dart +++ b/lib/widgets/reusable_widgets/buttons/stepper_button.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/outlined_button.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class StepperButton extends MyOutlinedButton { const StepperButton({ @@ -70,7 +70,7 @@ class _MyStepperButtonWithIconChild extends StatelessWidget { Icon( iconData, size: 17.0, - color: Theme.of(context).textTheme.headline6!.color, + color: Theme.of(context).textTheme.headlineSmall!.color, ), ], ); diff --git a/lib/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart b/lib/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart index b9bcd440..ceeeab76 100644 --- a/lib/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart +++ b/lib/widgets/reusable_widgets/buttons/transfer_toggle_card_size_button.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pow_generating_status_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -50,7 +50,7 @@ class TransferToggleCardSizeButton extends StatelessWidget { iconData, color: onPressed == null ? Colors.grey - : Theme.of(context).textTheme.headline5!.color, + : Theme.of(context).textTheme.headlineSmall!.color, ), ); } diff --git a/lib/widgets/reusable_widgets/cancel_timer.dart b/lib/widgets/reusable_widgets/cancel_timer.dart index e2491ab5..578dcc1b 100644 --- a/lib/widgets/reusable_widgets/cancel_timer.dart +++ b/lib/widgets/reusable_widgets/cancel_timer.dart @@ -15,7 +15,7 @@ class CancelTimer extends StatefulWidget { }) : super(key: key); @override - _CancelTimerState createState() => _CancelTimerState(); + State createState() => _CancelTimerState(); } class _CancelTimerState extends State { @@ -69,7 +69,7 @@ class _CancelTimerState extends State { ), child: Text( _currentDuration.toString().split('.').first, - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, ), ), ); diff --git a/lib/widgets/reusable_widgets/chart/chart.dart b/lib/widgets/reusable_widgets/chart/chart.dart new file mode 100644 index 00000000..9d45205c --- /dev/null +++ b/lib/widgets/reusable_widgets/chart/chart.dart @@ -0,0 +1,4 @@ +export 'chart_legend.dart'; +export 'standard_chart.dart'; +export 'standard_line_chart_bar_data.dart'; +export 'standard_pie_chart.dart'; diff --git a/lib/widgets/reusable_widgets/chart/chart_legend.dart b/lib/widgets/reusable_widgets/chart/chart_legend.dart index c02b582a..7d8b5c51 100644 --- a/lib/widgets/reusable_widgets/chart/chart_legend.dart +++ b/lib/widgets/reusable_widgets/chart/chart_legend.dart @@ -19,13 +19,13 @@ class ChartLegend extends StatelessWidget { children: [ Text( '● ', - style: Theme.of(context).textTheme.bodyText1!.copyWith( + style: Theme.of(context).textTheme.bodyLarge!.copyWith( color: dotColor, ), ), Text( mainText, - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), const SizedBox( width: 5.0, diff --git a/lib/widgets/reusable_widgets/chart/standard_chart.dart b/lib/widgets/reusable_widgets/chart/standard_chart.dart index f66a8a40..f51c7086 100644 --- a/lib/widgets/reusable_widgets/chart/standard_chart.dart +++ b/lib/widgets/reusable_widgets/chart/standard_chart.dart @@ -27,6 +27,7 @@ class StandardChart extends StatelessWidget { Widget build(BuildContext context) { return Container( margin: const EdgeInsets.only( + left: 5.0, right: 20.0, top: 20.0, bottom: 10.0, @@ -37,7 +38,7 @@ class StandardChart extends StatelessWidget { enabled: true, touchTooltipData: LineTouchTooltipData( fitInsideHorizontally: true, - tooltipBgColor: Theme.of(context).backgroundColor, + tooltipBgColor: Theme.of(context).colorScheme.background, tooltipMargin: 14.0, tooltipPadding: const EdgeInsets.all(4.0), tooltipRoundedRadius: 6.0, @@ -45,7 +46,7 @@ class StandardChart extends StatelessWidget { return touchedSpots.map( (LineBarSpot touchedSpot) { final textStyle = TextStyle( - color: touchedSpot.bar.colors[0], + color: touchedSpot.bar.color, fontWeight: FontWeight.bold, fontSize: 14.0, ); @@ -72,40 +73,51 @@ class StandardChart extends StatelessWidget { }, ), titlesData: FlTitlesData( - bottomTitles: SideTitles( - showTitles: true, - reservedSize: 14.0, - getTextStyles: (context, _) => - Theme.of(context).textTheme.subtitle2!, - margin: 8.0, - interval: 1.0, - getTitles: (value) => FormatUtils.formatDate( - FormatUtils.subtractDaysFromDate( - value.toInt(), titlesReferenceDate), - dateFormat: 'd MMM', + bottomTitles: AxisTitles( + sideTitles: SideTitles( + getTitlesWidget: (value, titleMeta) => Padding( + padding: const EdgeInsets.only(top: 8.0), + child: Text( + FormatUtils.formatDate( + FormatUtils.subtractDaysFromDate( + value.toInt(), titlesReferenceDate), + dateFormat: 'd MMM', + ), + style: Theme.of(context).textTheme.titleSmall!, + ), + ), + showTitles: true, + reservedSize: 22.0, + interval: 1.0, ), ), - leftTitles: SideTitles( - interval: yValuesInterval, - showTitles: true, - getTextStyles: (context, _) => - Theme.of(context).textTheme.subtitle2!, - getTitles: (value) { - return value != 0 - ? convertLeftSideTitlesToInt - ? '${value.toInt()}' - : value.toStringAsFixed(2) - : ''; - }, - margin: 8.0, - reservedSize: 26.0, + leftTitles: AxisTitles( + sideTitles: SideTitles( + interval: yValuesInterval, + showTitles: true, + getTitlesWidget: (value, _) => Padding( + padding: const EdgeInsets.only(top: 8.0), + child: Text( + value != 0 + ? convertLeftSideTitlesToInt + ? '${value.toInt()}' + : value.toStringAsFixed(2) + : '', + style: Theme.of(context).textTheme.titleSmall!, + ), + ), + reservedSize: 26.0, + ), ), - rightTitles: SideTitles( - showTitles: false, + rightTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: false, + ), ), - topTitles: SideTitles( + topTitles: AxisTitles( + sideTitles: SideTitles( showTitles: false, - ), + )), ), borderData: FlBorderData(show: false), minX: 0.0, diff --git a/lib/widgets/reusable_widgets/chart/standard_line_chart_bar_data.dart b/lib/widgets/reusable_widgets/chart/standard_line_chart_bar_data.dart index 2169aa28..63fd1add 100644 --- a/lib/widgets/reusable_widgets/chart/standard_line_chart_bar_data.dart +++ b/lib/widgets/reusable_widgets/chart/standard_line_chart_bar_data.dart @@ -4,12 +4,12 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; class StandardLineChartBarData extends LineChartBarData { StandardLineChartBarData({ - required List colors, + required Color color, required List? spots, }) : super( spots: spots, isCurved: false, - colors: colors, + color: color, barWidth: 3.0, isStrokeCapRound: true, dotData: FlDotData( @@ -17,12 +17,13 @@ class StandardLineChartBarData extends LineChartBarData { ), belowBarData: BarAreaData( show: true, - colors: [ - AppColors.znnColor.withOpacity(0.5), - AppColors.znnColor.withOpacity(0.0), - ], - gradientColorStops: [0.1, 1.0], - gradientTo: const Offset(0.0, 1.0), + gradient: LinearGradient( + colors: [ + AppColors.znnColor.withOpacity(0.5), + AppColors.znnColor.withOpacity(0.0), + ], + stops: const [0.1, 1.0], + ), ), ); } diff --git a/lib/widgets/reusable_widgets/context_menu_region.dart b/lib/widgets/reusable_widgets/context_menu_region.dart new file mode 100644 index 00000000..f5f7b305 --- /dev/null +++ b/lib/widgets/reusable_widgets/context_menu_region.dart @@ -0,0 +1,97 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +typedef ContextMenuBuilder = Widget Function( + BuildContext context, Offset offset); + +/// Shows and hides the context menu based on user gestures. +/// +/// By default, shows the menu on right clicks and long presses. +class ContextMenuRegion extends StatefulWidget { + /// Creates an instance of [ContextMenuRegion]. + const ContextMenuRegion({ + Key? key, + required this.child, + required this.contextMenuBuilder, + }) : super(key: key); + + /// Builds the context menu. + final ContextMenuBuilder contextMenuBuilder; + + /// The child widget that will be listened to for gestures. + final Widget child; + + @override + State createState() => _ContextMenuRegionState(); +} + +class _ContextMenuRegionState extends State { + Offset? _longPressOffset; + + final ContextMenuController _contextMenuController = ContextMenuController(); + + static bool get _longPressEnabled { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + case TargetPlatform.iOS: + return true; + case TargetPlatform.macOS: + case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: + return false; + } + } + + void _onSecondaryTapUp(TapUpDetails details) { + _show(details.globalPosition); + } + + void _onTap() { + if (!_contextMenuController.isShown) { + return; + } + _hide(); + } + + void _onLongPressStart(LongPressStartDetails details) { + _longPressOffset = details.globalPosition; + } + + void _onLongPress() { + assert(_longPressOffset != null); + _show(_longPressOffset!); + _longPressOffset = null; + } + + void _show(Offset position) { + _contextMenuController.show( + context: context, + contextMenuBuilder: (context) { + return widget.contextMenuBuilder(context, position); + }, + ); + } + + void _hide() { + _contextMenuController.remove(); + } + + @override + void dispose() { + _hide(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return GestureDetector( + behavior: HitTestBehavior.opaque, + onSecondaryTapUp: _onSecondaryTapUp, + onTap: _onTap, + onLongPress: _longPressEnabled ? _onLongPress : null, + onLongPressStart: _longPressEnabled ? _onLongPressStart : null, + child: widget.child, + ); + } +} diff --git a/lib/widgets/reusable_widgets/custom_expandable_panel.dart b/lib/widgets/reusable_widgets/custom_expandable_panel.dart index 9e6e3e9c..bd4f582d 100644 --- a/lib/widgets/reusable_widgets/custom_expandable_panel.dart +++ b/lib/widgets/reusable_widgets/custom_expandable_panel.dart @@ -13,7 +13,7 @@ class CustomExpandablePanel extends StatefulWidget { }) : super(key: key); @override - _CustomExpandablePanelState createState() => _CustomExpandablePanelState(); + State createState() => _CustomExpandablePanelState(); static Widget getGenericTextExpandedChild( String expandedText, @@ -21,7 +21,7 @@ class CustomExpandablePanel extends StatefulWidget { ) { return Text( expandedText, - style: Theme.of(context).textTheme.subtitle2, + style: Theme.of(context).textTheme.titleSmall, ); } } @@ -43,7 +43,7 @@ class _CustomExpandablePanelState extends State { ), child: Text( widget.header, - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ), expanded: Padding( diff --git a/lib/widgets/reusable_widgets/custom_material_stepper.dart b/lib/widgets/reusable_widgets/custom_material_stepper.dart index b17614e0..b45313b7 100644 --- a/lib/widgets/reusable_widgets/custom_material_stepper.dart +++ b/lib/widgets/reusable_widgets/custom_material_stepper.dart @@ -219,7 +219,7 @@ class Stepper extends StatefulWidget { final ControlsWidgetBuilder? controlsBuilder; @override - _StepperState createState() => _StepperState(); + State createState() => _StepperState(); } class _StepperState extends State with TickerProviderStateMixin { @@ -389,12 +389,12 @@ class _StepperState extends State with TickerProviderStateMixin { case StepState.indexed: case StepState.editing: case StepState.complete: - return textTheme.bodyText1; + return textTheme.bodyLarge; case StepState.disabled: - return textTheme.bodyText1! + return textTheme.bodyLarge! .copyWith(color: _isDark() ? _kDisabledDark : _kDisabledLight); case StepState.error: - return textTheme.bodyText1! + return textTheme.bodyLarge! .copyWith(color: _isDark() ? _kErrorDark : _kErrorLight); } } @@ -407,12 +407,12 @@ class _StepperState extends State with TickerProviderStateMixin { case StepState.indexed: case StepState.editing: case StepState.complete: - return textTheme.caption; + return textTheme.bodySmall; case StepState.disabled: - return textTheme.caption! + return textTheme.bodySmall! .copyWith(color: _isDark() ? _kDisabledDark : _kDisabledLight); case StepState.error: - return textTheme.caption! + return textTheme.bodySmall! .copyWith(color: _isDark() ? _kErrorDark : _kErrorLight); } } diff --git a/lib/widgets/reusable_widgets/custom_slider.dart b/lib/widgets/reusable_widgets/custom_slider.dart index 00d31100..fa4f8eff 100644 --- a/lib/widgets/reusable_widgets/custom_slider.dart +++ b/lib/widgets/reusable_widgets/custom_slider.dart @@ -166,7 +166,7 @@ class CustomSlider extends StatefulWidget { }) : super(key: key); @override - _CustomSliderState createState() => _CustomSliderState(); + State createState() => _CustomSliderState(); } class _CustomSliderState extends State { @@ -198,7 +198,7 @@ class _CustomSliderState extends State { valueIndicatorColor: widget.activeColor, thumbShape: const _CustomThumbShape(), valueIndicatorShape: const _CustomValueIndicatorShape(), - valueIndicatorTextStyle: theme.textTheme.bodyText1!.copyWith( + valueIndicatorTextStyle: theme.textTheme.bodyLarge!.copyWith( color: Colors.white, ), ), @@ -220,7 +220,7 @@ class _CustomSliderState extends State { ), Text( widget.description, - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ], ), diff --git a/lib/widgets/reusable_widgets/custom_table.dart b/lib/widgets/reusable_widgets/custom_table.dart index 10d6517b..78f4638f 100644 --- a/lib/widgets/reusable_widgets/custom_table.dart +++ b/lib/widgets/reusable_widgets/custom_table.dart @@ -4,7 +4,7 @@ import 'package:marquee_widget/marquee_widget.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class CustomTable extends StatefulWidget { @@ -145,15 +145,15 @@ class _CustomTableState extends State> { Widget _getShowMoreButton() { return TextButton( style: TextButton.styleFrom( - primary: Colors.white12, + foregroundColor: Colors.white12, backgroundColor: Colors.transparent, shape: const RoundedRectangleBorder(), ), + onPressed: widget.onShowMoreButtonPressed, child: Text( 'Show more', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), - onPressed: widget.onShowMoreButtonPressed, ); } @@ -187,7 +187,7 @@ class CustomHeaderColumn extends StatelessWidget { children: [ Text( columnName, - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, ), Visibility( visible: onSortArrowsPressed != null, @@ -317,7 +317,7 @@ class CustomTableCell extends StatelessWidget { AddressUtils.getLabel(address.toString()), textAlign: textAlign, style: textStyle ?? - Theme.of(context).textTheme.subtitle1!.copyWith( + Theme.of(context).textTheme.titleMedium!.copyWith( color: textColor, ), overflow: TextOverflow.ellipsis, @@ -358,7 +358,7 @@ class CustomTableCell extends StatelessWidget { text, textAlign: textAlign, style: textStyle ?? - Theme.of(context).textTheme.subtitle1!.copyWith( + Theme.of(context).textTheme.titleMedium!.copyWith( color: textColor, ), ), @@ -384,9 +384,9 @@ class CustomTableCell extends StatelessWidget { @override Widget build(BuildContext context) { return Flexible( - child: child, flex: flex, fit: FlexFit.tight, + child: child, ); } } diff --git a/lib/widgets/reusable_widgets/dialogs.dart b/lib/widgets/reusable_widgets/dialogs.dart index 111fcb05..652e86d2 100644 --- a/lib/widgets/reusable_widgets/dialogs.dart +++ b/lib/widgets/reusable_widgets/dialogs.dart @@ -1,28 +1,58 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -showOkDialog({ +showWarningDialog({ required BuildContext context, required String title, required String description, - required VoidCallback onActionButtonPressed, -}) => - showDialog( - context: context, - builder: (context) => AlertDialog( - title: Text(title), - content: Text(description), - actions: [ - TextButton( - child: Text( - 'OK', - style: Theme.of(context).textTheme.bodyText1, - ), - onPressed: onActionButtonPressed, - ), - ], + required String buttonText, + VoidCallback? onActionButtonPressed, +}) async { + bool isPressed = false; + await showDialog( + context: context, + builder: (context) => AlertDialog( + icon: const Icon( + Icons.warning, + size: 24.0, + color: Colors.orange, ), - ); + title: Text(title), + content: Text(description), + actions: [ + TextButton( + onPressed: onActionButtonPressed ?? + () { + Navigator.pop(context); + }, + style: const ButtonStyle( + backgroundColor: MaterialStatePropertyAll(Colors.amber), + ), + child: Text( + 'Cancel', + style: Theme.of(context).textTheme.bodyMedium, + ), + ), + TextButton( + onPressed: onActionButtonPressed ?? + () { + isPressed = true; + Navigator.pop(context); + }, + style: const ButtonStyle( + backgroundColor: MaterialStatePropertyAll(Colors.orange), + ), + child: Text( + buttonText.isEmpty ? 'OK' : buttonText, + style: Theme.of(context).textTheme.bodyMedium, + ), + ) + ], + ), + barrierDismissible: false, + ); + return isPressed; +} showDialogWithNoAndYesOptions({ required BuildContext context, @@ -39,22 +69,22 @@ showDialogWithNoAndYesOptions({ TextButton( child: Text( 'No', - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), onPressed: () { Navigator.of(context).pop(); }, ), TextButton( - child: Text( - 'Yes', - style: Theme.of(context).textTheme.bodyText1, - ), onPressed: onYesButtonPressed, style: Theme.of(context).textButtonTheme.style!.copyWith( backgroundColor: MaterialStateColor.resolveWith( (states) => AppColors.errorColor), ), + child: Text( + 'Yes', + style: Theme.of(context).textTheme.bodyLarge, + ), ), ], ), diff --git a/lib/widgets/reusable_widgets/dotted_border_info_widget.dart b/lib/widgets/reusable_widgets/dotted_border_info_widget.dart index ef1ec6dc..d379c9b2 100644 --- a/lib/widgets/reusable_widgets/dotted_border_info_widget.dart +++ b/lib/widgets/reusable_widgets/dotted_border_info_widget.dart @@ -39,7 +39,7 @@ class _DottedBorderInfoWidgetState extends State { Flexible( child: Text( widget.text, - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, textAlign: TextAlign.center, ), ), diff --git a/lib/widgets/reusable_widgets/dropdown/addresses_dropdown.dart b/lib/widgets/reusable_widgets/dropdown/addresses_dropdown.dart index f80d2db3..74a1835e 100644 --- a/lib/widgets/reusable_widgets/dropdown/addresses_dropdown.dart +++ b/lib/widgets/reusable_widgets/dropdown/addresses_dropdown.dart @@ -49,7 +49,7 @@ class AddressesDropdown extends StatelessWidget { value: value, child: Text( kAddressLabelMap[value]!, - style: Theme.of(context).textTheme.bodyText2!.copyWith( + style: Theme.of(context).textTheme.bodyMedium!.copyWith( color: _selectedSelfAddress == value ? onChangedCallback != null ? AppColors.znnColor diff --git a/lib/widgets/reusable_widgets/dropdown/bridge_network_dropdown.dart b/lib/widgets/reusable_widgets/dropdown/bridge_network_dropdown.dart index 464c1e33..9734e317 100644 --- a/lib/widgets/reusable_widgets/dropdown/bridge_network_dropdown.dart +++ b/lib/widgets/reusable_widgets/dropdown/bridge_network_dropdown.dart @@ -49,7 +49,7 @@ class BridgeNetworkDropdown extends StatelessWidget { value: value, child: Text( value, - style: Theme.of(context).textTheme.bodyText2!.copyWith( + style: Theme.of(context).textTheme.bodyMedium!.copyWith( color: _selectedNetwork == value ? onChangedCallback != null ? AppColors.znnColor diff --git a/lib/widgets/reusable_widgets/dropdown/coin_dropdown.dart b/lib/widgets/reusable_widgets/dropdown/coin_dropdown.dart index 58fb8e0b..389a0170 100644 --- a/lib/widgets/reusable_widgets/dropdown/coin_dropdown.dart +++ b/lib/widgets/reusable_widgets/dropdown/coin_dropdown.dart @@ -39,14 +39,14 @@ class CoinDropdown extends StatelessWidget { color: ColorUtils.getTokenColor(e!.tokenStandard), ), child: Padding( - padding: const EdgeInsets.all(5.0), + padding: const EdgeInsets.only(left: 8.0), child: Row( children: [ Text( e.symbol, style: Theme.of(context) .textTheme - .subtitle1! + .titleMedium! .copyWith( color: Colors.white, ), @@ -75,7 +75,7 @@ class CoinDropdown extends StatelessWidget { value: token, child: Text( token!.symbol, - style: Theme.of(context).textTheme.bodyText2!.copyWith( + style: Theme.of(context).textTheme.bodyMedium!.copyWith( color: _selectedToken == token ? AppColors.znnColor : null, diff --git a/lib/widgets/reusable_widgets/dropdown/dropdown.dart b/lib/widgets/reusable_widgets/dropdown/dropdown.dart new file mode 100644 index 00000000..d96b47e1 --- /dev/null +++ b/lib/widgets/reusable_widgets/dropdown/dropdown.dart @@ -0,0 +1,3 @@ +export 'addresses_dropdown.dart'; +export 'bridge_network_dropdown.dart'; +export 'coin_dropdown.dart'; diff --git a/lib/widgets/reusable_widgets/error_widget.dart b/lib/widgets/reusable_widgets/error_widget.dart index 730c6c8d..b248dd48 100644 --- a/lib/widgets/reusable_widgets/error_widget.dart +++ b/lib/widgets/reusable_widgets/error_widget.dart @@ -27,7 +27,7 @@ class SyriusErrorWidget extends StatelessWidget { Text( _getErrorText(error.toString()), textAlign: TextAlign.center, - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, ), ], ), diff --git a/lib/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart b/lib/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart index f998f598..b35d6da7 100644 --- a/lib/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart +++ b/lib/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart @@ -23,13 +23,13 @@ class CopyToClipboardIcon extends StatelessWidget { hoverColor: hoverColor, constraints: const BoxConstraints.tightForFinite(), padding: const EdgeInsets.all(8.0), + shape: const CircleBorder(), + onPressed: () => ClipboardUtils.copyToClipboard(textToBeCopied!, context), child: Icon( Icons.content_copy, color: iconColor, size: 15.0, ), - shape: const CircleBorder(), - onPressed: () => ClipboardUtils.copyToClipboard(textToBeCopied!, context), ); } } diff --git a/lib/widgets/reusable_widgets/icons/icons.dart b/lib/widgets/reusable_widgets/icons/icons.dart new file mode 100644 index 00000000..f3ef375a --- /dev/null +++ b/lib/widgets/reusable_widgets/icons/icons.dart @@ -0,0 +1,2 @@ +export 'copy_to_clipboard_icon.dart'; +export 'standard_tooltip_icon.dart'; diff --git a/lib/widgets/reusable_widgets/icons/standard_tooltip_icon.dart b/lib/widgets/reusable_widgets/icons/standard_tooltip_icon.dart index 329aacce..f01f03f8 100644 --- a/lib/widgets/reusable_widgets/icons/standard_tooltip_icon.dart +++ b/lib/widgets/reusable_widgets/icons/standard_tooltip_icon.dart @@ -4,9 +4,11 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; class StandardTooltipIcon extends StatelessWidget { final String tooltipMessage; final Color iconColor; + final IconData iconData; const StandardTooltipIcon( - this.tooltipMessage, { + this.tooltipMessage, + this.iconData, { this.iconColor = AppColors.znnColor, Key? key, }) : super(key: key); @@ -19,7 +21,7 @@ class StandardTooltipIcon extends StatelessWidget { constraints: const BoxConstraints(), iconSize: 15.0, icon: Icon( - Icons.help_sharp, + iconData, color: iconColor, ), onPressed: () {}, diff --git a/lib/widgets/reusable_widgets/infinite_scroll_table.dart b/lib/widgets/reusable_widgets/infinite_scroll_table.dart index de8f409d..7206289c 100644 --- a/lib/widgets/reusable_widgets/infinite_scroll_table.dart +++ b/lib/widgets/reusable_widgets/infinite_scroll_table.dart @@ -4,13 +4,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:marquee_widget/marquee_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/infinite_scroll_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/address_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class InfiniteScrollTable extends StatefulWidget { @@ -207,7 +205,7 @@ class InfiniteScrollTableHeaderColumn extends StatelessWidget { Expanded( child: Text( columnName, - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, ), ), Visibility( @@ -348,7 +346,7 @@ class InfiniteScrollTableCell extends StatelessWidget { AddressUtils.getLabel(address.toString()), textAlign: textAlign, style: textStyle ?? - Theme.of(context).textTheme.subtitle1!.copyWith( + Theme.of(context).textTheme.titleMedium!.copyWith( color: textColor, ), overflow: TextOverflow.ellipsis, @@ -393,7 +391,7 @@ class InfiniteScrollTableCell extends StatelessWidget { text, textAlign: textAlign, style: textStyle ?? - Theme.of(context).textTheme.subtitle1!.copyWith( + Theme.of(context).textTheme.titleMedium!.copyWith( color: textColor, ), ), @@ -421,9 +419,9 @@ class InfiniteScrollTableCell extends StatelessWidget { @override Widget build(BuildContext context) { return Flexible( - child: child, flex: flex, fit: FlexFit.tight, + child: child, ); } } diff --git a/lib/widgets/reusable_widgets/input_field/amount_suffix_widgets.dart b/lib/widgets/reusable_widgets/input_fields/amount_suffix_widgets.dart similarity index 94% rename from lib/widgets/reusable_widgets/input_field/amount_suffix_widgets.dart rename to lib/widgets/reusable_widgets/input_fields/amount_suffix_widgets.dart index 593084b9..4466c9e6 100644 --- a/lib/widgets/reusable_widgets/input_field/amount_suffix_widgets.dart +++ b/lib/widgets/reusable_widgets/input_fields/amount_suffix_widgets.dart @@ -54,7 +54,7 @@ class AmountSuffixTokenSymbolWidget extends Container { ), child: Text( token.symbol, - style: Theme.of(context).textTheme.subtitle1!.copyWith( + style: Theme.of(context).textTheme.titleMedium!.copyWith( color: Colors.white, ), ), @@ -84,7 +84,7 @@ class AmountSuffixMaxWidget extends InkWell { ), child: Text( 'MAX', - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ), ); diff --git a/lib/widgets/reusable_widgets/input_field/disabled_address_field.dart b/lib/widgets/reusable_widgets/input_fields/disabled_address_field.dart similarity index 87% rename from lib/widgets/reusable_widgets/input_field/disabled_address_field.dart rename to lib/widgets/reusable_widgets/input_fields/disabled_address_field.dart index e69cc03d..30171a32 100644 --- a/lib/widgets/reusable_widgets/input_field/disabled_address_field.dart +++ b/lib/widgets/reusable_widgets/input_fields/disabled_address_field.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class DisabledAddressField extends StatelessWidget { final TextEditingController _addressController; diff --git a/lib/widgets/reusable_widgets/input_field/input_field.dart b/lib/widgets/reusable_widgets/input_fields/input_field.dart similarity index 77% rename from lib/widgets/reusable_widgets/input_field/input_field.dart rename to lib/widgets/reusable_widgets/input_fields/input_field.dart index 7c3b9601..f0f8c1b7 100644 --- a/lib/widgets/reusable_widgets/input_field/input_field.dart +++ b/lib/widgets/reusable_widgets/input_fields/input_field.dart @@ -64,6 +64,26 @@ class _InputFieldState extends State { @override Widget build(BuildContext context) { return TextFormField( + contextMenuBuilder: (context, editableTextState) { + return AdaptiveTextSelectionToolbar( + anchors: editableTextState.contextMenuAnchors, + children: editableTextState.contextMenuButtonItems + .map((ContextMenuButtonItem buttonItem) { + return Row(children: [ + Expanded( + child: TextButton( + onPressed: buttonItem.onPressed, + style: TextButton.styleFrom( + shape: const RoundedRectangleBorder(), + ), + child: Text( + AdaptiveTextSelectionToolbar.getButtonLabel( + context, buttonItem), + style: Theme.of(context).textTheme.bodyMedium), + )) + ]); + }).toList()); + }, maxLines: widget.maxLines, obscureText: widget.obscureText, onChanged: widget.onChanged, diff --git a/lib/widgets/reusable_widgets/input_fields/input_fields.dart b/lib/widgets/reusable_widgets/input_fields/input_fields.dart new file mode 100644 index 00000000..539fbd4d --- /dev/null +++ b/lib/widgets/reusable_widgets/input_fields/input_fields.dart @@ -0,0 +1,4 @@ +export 'amount_suffix_widgets.dart'; +export 'disabled_address_field.dart'; +export 'input_field.dart'; +export 'password_input_field.dart'; diff --git a/lib/widgets/reusable_widgets/input_field/password_input_field.dart b/lib/widgets/reusable_widgets/input_fields/password_input_field.dart similarity index 90% rename from lib/widgets/reusable_widgets/input_field/password_input_field.dart rename to lib/widgets/reusable_widgets/input_fields/password_input_field.dart index 26d0f920..45ad4a96 100644 --- a/lib/widgets/reusable_widgets/input_field/password_input_field.dart +++ b/lib/widgets/reusable_widgets/input_fields/password_input_field.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class PasswordInputField extends StatefulWidget { final TextEditingController controller; @@ -22,7 +22,7 @@ class PasswordInputField extends StatefulWidget { }) : super(key: key); @override - _PasswordInputFieldState createState() => _PasswordInputFieldState(); + State createState() => _PasswordInputFieldState(); } class _PasswordInputFieldState extends State { diff --git a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart index de5be6ba..fa900c2c 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart @@ -6,14 +6,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:lottie/lottie.dart'; import 'package:stacked/stacked.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/hide_widget_status_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/widget_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/password_input_field.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class CardScaffold extends StatefulWidget { final String? title; @@ -38,7 +35,7 @@ class CardScaffold extends StatefulWidget { }) : super(key: key); @override - _CardScaffoldState createState() => _CardScaffoldState(); + State> createState() => _CardScaffoldState(); } class _CardScaffoldState extends State> { @@ -120,7 +117,7 @@ class _CardScaffoldState extends State> { ExpandablePanel( collapsed: Container(), theme: ExpandableThemeData( - iconColor: Theme.of(context).textTheme.bodyText1!.color, + iconColor: Theme.of(context).textTheme.bodyLarge!.color, headerAlignment: ExpandablePanelHeaderAlignment.center, iconPlacement: ExpandablePanelIconPlacement.right, ), @@ -137,7 +134,7 @@ class _CardScaffoldState extends State> { Expanded( child: Text( 'Description', - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), ), ], @@ -150,7 +147,7 @@ class _CardScaffoldState extends State> { ), child: Text( widget.description, - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ), ), @@ -165,9 +162,11 @@ class _CardScaffoldState extends State> { const SizedBox( width: 5.0, ), - Text( - 'Discreet mode', - style: Theme.of(context).textTheme.bodyText1, + Expanded( + child: Text( + 'Discreet mode', + style: Theme.of(context).textTheme.bodyLarge, + ), ), const Spacer(), Switch( @@ -222,22 +221,26 @@ class _CardScaffoldState extends State> { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Padding( - padding: const EdgeInsets.all(14.0), - child: Row( - children: [ - Text( - title, - style: Theme.of(context).textTheme.bodyText1!.copyWith( - fontSize: widget.titleFontSize, - height: 1.0, - ), - ), - const SizedBox( - width: 5.0, - ), - widget.titleIcon != null ? widget.titleIcon! : Container(), - ], + Expanded( + child: Padding( + padding: const EdgeInsets.all(14.0), + child: Row( + children: [ + Expanded( + child: Text( + title, + style: Theme.of(context).textTheme.bodyText1!.copyWith( + fontSize: widget.titleFontSize, + height: 1.0, + ), + ), + ), + const SizedBox( + width: 5.0, + ), + widget.titleIcon != null ? widget.titleIcon! : Container(), + ], + ), ), ), Row( @@ -265,7 +268,7 @@ class _CardScaffoldState extends State> { splashRadius: 15.0, icon: const Icon(Icons.more_horiz), iconSize: 18.0, - color: Theme.of(context).textTheme.bodyText1!.color, + color: Theme.of(context).textTheme.bodyLarge!.color, onPressed: () { cardKey.currentState!.toggleCard(); }, @@ -302,7 +305,7 @@ class _CardScaffoldState extends State> { Widget _getHideWidgetInfoViewModel() { return ViewModelBuilder.reactive( - onModelReady: (model) { + onViewModelReady: (model) { _actionButton = _getActionButton(model); // Stream will tell us if the widget info is hidden or not model.stream.listen( @@ -356,7 +359,8 @@ class _CardScaffoldState extends State> { if (snapshot.hasError) { return SyriusErrorWidget(snapshot.error!); } else if (snapshot.hasData) { - return widget.onCompletedStatusCallback!(snapshot.data!); + return widget + .onCompletedStatusCallback!(snapshot.data as T); } return const SyriusLoadingWidget(); }, diff --git a/lib/widgets/reusable_widgets/layout_scaffold/layout_scaffold.dart b/lib/widgets/reusable_widgets/layout_scaffold/layout_scaffold.dart new file mode 100644 index 00000000..a254a06d --- /dev/null +++ b/lib/widgets/reusable_widgets/layout_scaffold/layout_scaffold.dart @@ -0,0 +1,4 @@ +export 'card_scaffold.dart'; +export 'overscroll_remover.dart'; +export 'standard_fluid_layout.dart'; +export 'widget_animator.dart'; diff --git a/lib/widgets/reusable_widgets/layout_scaffold/overscroll_remover.dart b/lib/widgets/reusable_widgets/layout_scaffold/overscroll_remover.dart index 6c4c035a..5b8ee4e7 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/overscroll_remover.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/overscroll_remover.dart @@ -2,11 +2,8 @@ import 'package:flutter/material.dart'; class RemoveOverscrollEffect extends ScrollBehavior { @override - Widget buildViewportChrome( - BuildContext context, - Widget child, - AxisDirection axisDirection, - ) { + Widget buildOverscrollIndicator( + BuildContext context, Widget child, ScrollableDetails details) { return child; } } diff --git a/lib/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart b/lib/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart index 3fc91667..fd4497e1 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:layout/layout.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/overscroll_remover.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/widget_animator.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; const int kStaggeredNumOfColumns = 12; @@ -20,48 +19,45 @@ class StandardFluidLayout extends StatelessWidget { @override Widget build(BuildContext context) { - return ScrollConfiguration( - behavior: RemoveOverscrollEffect(), - child: Layout( - format: FluidLayoutFormat(), - child: Builder( - builder: (context) { - const int crossAxisCount = kStaggeredNumOfColumns; - return CustomScrollView( - slivers: [ - SliverStaggeredGrid( - delegate: SliverChildListDelegate.fixed( - List.generate( - children.length, - (index) => WidgetAnimator( - curve: Curves.linear, - child: children[index].child, - animationOffset: Duration( - milliseconds: ((children.length > 5 ? 800 : 400) ~/ - children.length) * - (index + 1), - ), + return Layout( + format: FluidLayoutFormat(), + child: Builder( + builder: (context) { + const int crossAxisCount = kStaggeredNumOfColumns; + return CustomScrollView( + slivers: [ + SliverStaggeredGrid( + delegate: SliverChildListDelegate.fixed( + List.generate( + children.length, + (index) => WidgetAnimator( + curve: Curves.linear, + animationOffset: Duration( + milliseconds: ((children.length > 5 ? 800 : 400) ~/ + children.length) * + (index + 1), ), + child: children[index].child, ), ), - gridDelegate: - SliverStaggeredGridDelegateWithFixedCrossAxisCount( - mainAxisSpacing: - context.breakpoint < LayoutBreakpoint.sm ? 4 : 12.0, - crossAxisSpacing: - context.breakpoint < LayoutBreakpoint.sm ? 4 : 12.0, - crossAxisCount: crossAxisCount, - staggeredTileCount: children.length, - staggeredTileBuilder: (index) => StaggeredTile.count( - children[index].width ?? defaultCellWidth!, - children[index].height ?? defaultCellHeight!, - ), + ), + gridDelegate: + SliverStaggeredGridDelegateWithFixedCrossAxisCount( + mainAxisSpacing: + context.breakpoint < LayoutBreakpoint.sm ? 4 : 12.0, + crossAxisSpacing: + context.breakpoint < LayoutBreakpoint.sm ? 4 : 12.0, + crossAxisCount: crossAxisCount, + staggeredTileCount: children.length, + staggeredTileBuilder: (index) => StaggeredTile.count( + children[index].width ?? defaultCellWidth!, + children[index].height ?? defaultCellHeight!, ), ), - ], - ); - }, - ), + ), + ], + ); + }, ), ); } diff --git a/lib/widgets/reusable_widgets/layout_scaffold/widget_animator.dart b/lib/widgets/reusable_widgets/layout_scaffold/widget_animator.dart index 5623337f..8574d320 100644 --- a/lib/widgets/reusable_widgets/layout_scaffold/widget_animator.dart +++ b/lib/widgets/reusable_widgets/layout_scaffold/widget_animator.dart @@ -17,7 +17,7 @@ class WidgetAnimator extends StatefulWidget { }) : super(key: key); @override - _WidgetAnimatorState createState() => _WidgetAnimatorState(); + State createState() => _WidgetAnimatorState(); } class _WidgetAnimatorState extends State diff --git a/lib/widgets/reusable_widgets/notification_widget.dart b/lib/widgets/reusable_widgets/notification_widget.dart index 7b2ba76c..5b92840e 100644 --- a/lib/widgets/reusable_widgets/notification_widget.dart +++ b/lib/widgets/reusable_widgets/notification_widget.dart @@ -1,10 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/notifications_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/main_app_container.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/widget_animator.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class NotificationWidget extends StatefulWidget { final VoidCallback? onSeeMorePressed; @@ -21,7 +20,7 @@ class NotificationWidget extends StatefulWidget { }) : super(key: key); @override - _NotificationWidgetState createState() => _NotificationWidgetState(); + State createState() => _NotificationWidgetState(); } class _NotificationWidgetState extends State { @@ -93,7 +92,7 @@ class _NotificationWidgetState extends State { ), Text( notification.title!, - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, ), ], ); @@ -113,7 +112,7 @@ class _NotificationWidgetState extends State { onPressed: _navigateToNotification, child: Text( 'See more', - style: Theme.of(context).textTheme.subtitle1!.copyWith( + style: Theme.of(context).textTheme.titleMedium!.copyWith( color: notification.getColor(), ), ), @@ -131,7 +130,7 @@ class _NotificationWidgetState extends State { onPressed: _dismissNotification, child: Text( 'Dismiss', - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, ), ), ], diff --git a/lib/widgets/reusable_widgets/number_animation.dart b/lib/widgets/reusable_widgets/number_animation.dart index c948265a..274a4fad 100644 --- a/lib/widgets/reusable_widgets/number_animation.dart +++ b/lib/widgets/reusable_widgets/number_animation.dart @@ -64,7 +64,7 @@ class NumberAnimation extends StatefulWidget { /// create state @override - _NumberAnimationState createState() => _NumberAnimationState(); + State createState() => _NumberAnimationState(); } /// state diff --git a/lib/widgets/reusable_widgets/receive_qr_image.dart b/lib/widgets/reusable_widgets/receive_qr_image.dart index 45891a44..638985f2 100644 --- a/lib/widgets/reusable_widgets/receive_qr_image.dart +++ b/lib/widgets/reusable_widgets/receive_qr_image.dart @@ -1,6 +1,16 @@ +import 'dart:io'; +import 'dart:typed_data'; + import 'package:flutter/material.dart'; +import 'package:flutter_vector_icons/flutter_vector_icons.dart'; +import 'package:open_filex/open_filex.dart'; +import 'package:path/path.dart' as path; import 'package:pretty_qr_code/pretty_qr_code.dart'; +import 'package:screenshot/screenshot.dart'; +import 'package:share_plus/share_plus.dart'; import 'package:zenon_syrius_wallet_flutter/utils/color_utils.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/context_menu_region.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class ReceiveQrImage extends StatelessWidget { @@ -9,7 +19,9 @@ class ReceiveQrImage extends StatelessWidget { final TokenStandard tokenStandard; final BuildContext context; - const ReceiveQrImage({ + final ScreenshotController screenshotController = ScreenshotController(); + + ReceiveQrImage({ required this.data, required this.size, required this.tokenStandard, @@ -19,25 +31,129 @@ class ReceiveQrImage extends StatelessWidget { @override Widget build(BuildContext context) { - return ClipRRect( - borderRadius: BorderRadius.circular( - 15.0, - ), - child: Container( - padding: const EdgeInsets.all( - 10.0, - ), - color: Theme.of(context).backgroundColor, - child: PrettyQr( - data: data, - size: size, - elementColor: ColorUtils.getTokenColor(tokenStandard), - image: const AssetImage('assets/images/qr_code_child_image_znn.png'), - typeNumber: 7, - errorCorrectLevel: QrErrorCorrectLevel.M, - roundEdges: true, - ), - ), - ); + return Screenshot( + controller: screenshotController, + child: ClipRRect( + borderRadius: BorderRadius.circular( + 15.0, + ), + child: Container( + padding: const EdgeInsets.all( + 10.0, + ), + color: Theme.of(context).colorScheme.background, + child: ContextMenuRegion( + contextMenuBuilder: (context, offset) { + return AdaptiveTextSelectionToolbar( + anchors: TextSelectionToolbarAnchors( + primaryAnchor: offset, + ), + children: [ + Row( + children: [ + Expanded( + child: Directionality( + textDirection: TextDirection.rtl, + child: TextButton.icon( + icon: Icon( + MaterialCommunityIcons.share, + color: + Theme.of(context).colorScheme.onBackground, + size: 14, + ), + onPressed: () { + ContextMenuController.removeAny(); + _shareQR(); + }, + style: TextButton.styleFrom( + shape: const RoundedRectangleBorder(), + ), + label: Text( + AdaptiveTextSelectionToolbar.getButtonLabel( + context, + ContextMenuButtonItem( + label: 'Share QR', onPressed: () {})), + style: + Theme.of(context).textTheme.bodyMedium), + ), + ), + ), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + flex: 1, + child: Directionality( + textDirection: TextDirection.rtl, + child: TextButton.icon( + icon: Icon( + Icons.save_alt, + color: + Theme.of(context).colorScheme.onBackground, + size: 14, + ), + onPressed: () { + ContextMenuController.removeAny(); + _saveQR(); + }, + style: TextButton.styleFrom( + shape: const RoundedRectangleBorder(), + ), + label: Text( + AdaptiveTextSelectionToolbar.getButtonLabel( + context, + ContextMenuButtonItem( + label: 'Save QR', onPressed: () {})), + style: + Theme.of(context).textTheme.bodyMedium), + ), + ), + ), + ], + ), + ], + ); + }, + child: PrettyQr( + data: data, + size: size, + elementColor: ColorUtils.getTokenColor(tokenStandard), + image: const AssetImage( + 'assets/images/qr_code_child_image_znn.png'), + typeNumber: 7, + errorCorrectLevel: QrErrorCorrectLevel.M, + roundEdges: true, + ), + ), + ), + )); + } + + void _saveQR() async { + Uint8List? capture = await screenshotController.capture( + delay: const Duration(milliseconds: 20)); + if (capture != null) { + String fileName = DateTime.now().millisecondsSinceEpoch.toString(); + final imagePath = await File( + '${znnDefaultPaths.cache.path}${path.separator}$fileName.png') + .create(); + await imagePath.writeAsBytes(capture); + await OpenFilex.open(imagePath.path); + } + } + + void _shareQR() async { + Uint8List? capture = await screenshotController.capture( + delay: const Duration(milliseconds: 20)); + if (capture != null) { + String fileName = DateTime.now().millisecondsSinceEpoch.toString(); + final imagePath = await File( + '${znnDefaultPaths.cache.path}${path.separator}$fileName.png') + .create(); + await imagePath.writeAsBytes(capture); + await Share.shareXFiles([XFile(imagePath.path)]); + } } } diff --git a/lib/widgets/reusable_widgets/reusable_widgets.dart b/lib/widgets/reusable_widgets/reusable_widgets.dart new file mode 100644 index 00000000..cc0c70c4 --- /dev/null +++ b/lib/widgets/reusable_widgets/reusable_widgets.dart @@ -0,0 +1,35 @@ +export 'buttons/buttons.dart'; +export 'chart/chart.dart'; +export 'dropdown/dropdown.dart'; +export 'icons/icons.dart'; +export 'input_fields/input_fields.dart'; +export 'layout_scaffold/layout_scaffold.dart'; +export 'accelerator_project_details.dart'; +export 'access_wallet_fluid_cell.dart'; +export 'amount_info_column.dart'; +export 'available_balance.dart'; +export 'cancel_timer.dart'; +export 'custom_expandable_panel.dart'; +export 'custom_material_stepper.dart'; +export 'custom_slider.dart'; +export 'custom_table.dart'; +export 'dialogs.dart'; +export 'dotted_border_info_widget.dart'; +export 'error_widget.dart'; +export 'formatted_amount_with_tooltip.dart'; +export 'infinite_scroll_table.dart'; +export 'loading_widget.dart'; +export 'notification_widget.dart'; +export 'number_animation.dart'; +export 'plasma_icon.dart'; +export 'progress_bars.dart'; +export 'receive_qr_image.dart'; +export 'seed/seed_choice.dart'; +export 'seed/seed_grid.dart'; +export 'select_file_widget.dart'; +export 'settings_address.dart'; +export 'settings_node.dart'; +export 'stepper_utils.dart'; +export 'tag_widget.dart'; +export 'transfer_icon_legend.dart'; +export 'syrius_checkbox.dart'; diff --git a/lib/widgets/reusable_widgets/seed/seed_choice.dart b/lib/widgets/reusable_widgets/seed/seed_choice.dart index 81db0d76..8774c417 100644 --- a/lib/widgets/reusable_widgets/seed/seed_choice.dart +++ b/lib/widgets/reusable_widgets/seed/seed_choice.dart @@ -71,9 +71,11 @@ class _SeedChoiceState extends State { ), child: SvgPicture.asset( 'assets/svg/ic_seed_24.svg', - color: widget.isSeed12Selected - ? _seed24Color - : AppColors.selectedSeedChoiceColor, + colorFilter: ColorFilter.mode( + widget.isSeed12Selected + ? _seed24Color + : AppColors.selectedSeedChoiceColor, + BlendMode.srcIn), ), ), ), @@ -113,9 +115,11 @@ class _SeedChoiceState extends State { ), child: SvgPicture.asset( 'assets/svg/ic_seed_12.svg', - color: widget.isSeed12Selected - ? AppColors.selectedSeedChoiceColor - : _seed12Color, + colorFilter: ColorFilter.mode( + widget.isSeed12Selected + ? AppColors.selectedSeedChoiceColor + : _seed12Color, + BlendMode.srcIn), ), ), ), diff --git a/lib/widgets/reusable_widgets/seed/seed_grid.dart b/lib/widgets/reusable_widgets/seed/seed_grid.dart index 324eb74c..a2ffe9f4 100644 --- a/lib/widgets/reusable_widgets/seed/seed_grid.dart +++ b/lib/widgets/reusable_widgets/seed/seed_grid.dart @@ -114,12 +114,12 @@ class SeedGridState extends State { Widget _seedWordWidget(int seedWordIndex) { String seedWord = _seedGridElements[seedWordIndex].word; - final TextEditingController _controller = TextEditingController(); - _controller.text = seedWord; + final TextEditingController controller = TextEditingController(); + controller.text = seedWord; if (_textCursor == seedWordIndex) { - _controller.selection = TextSelection.collapsed( - offset: _controller.text.length, + controller.selection = TextSelection.collapsed( + offset: controller.text.length, ); } return SizedBox( @@ -161,7 +161,7 @@ class SeedGridState extends State { child: Center( child: Text( (seedWordIndex + 1).toString(), - style: Theme.of(context).textTheme.bodyText1!.copyWith( + style: Theme.of(context).textTheme.bodyLarge!.copyWith( color: Colors.white, ), ), @@ -192,7 +192,7 @@ class SeedGridState extends State { child: TextField( focusNode: _focusNodes[seedWordIndex], onChanged: (text) { - _controller.text = text; + controller.text = text; _seedGridElements[seedWordIndex].word = text; _seedGridElements[seedWordIndex].isValid = Mnemonic.isValidWord(text); @@ -204,7 +204,7 @@ class SeedGridState extends State { }, inputFormatters: [LengthLimitingTextInputFormatter(8)], enabled: widget.enableSeedInputFields, - controller: _controller, + controller: controller, obscureText: _onHoverText == seedWordIndex ? false : _seedGridElements[seedWordIndex].isShown, diff --git a/lib/widgets/reusable_widgets/select_file_widget.dart b/lib/widgets/reusable_widgets/select_file_widget.dart index a7415246..db36d87d 100644 --- a/lib/widgets/reusable_widgets/select_file_widget.dart +++ b/lib/widgets/reusable_widgets/select_file_widget.dart @@ -1,6 +1,6 @@ import 'package:desktop_drop/desktop_drop.dart'; import 'package:dotted_border/dotted_border.dart'; -import 'package:file_selector_platform_interface/file_selector_platform_interface.dart'; +import 'package:file_selector/file_selector.dart'; import 'package:flutter/material.dart'; import 'package:path_provider/path_provider.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; @@ -55,8 +55,7 @@ class SelectFileWidgetState extends State { onTap: () async { String? initialDirectory; initialDirectory = (await getApplicationDocumentsDirectory()).path; - final XFile? selectedFile = - await FileSelectorPlatform.instance.openFile( + final selectedFile = await openFile( acceptedTypeGroups: [ XTypeGroup( label: 'file', @@ -92,7 +91,7 @@ class SelectFileWidgetState extends State { borderType: BorderType.RRect, color: _browseButtonHover ? AppColors.znnColor - : Theme.of(context).textTheme.headline5!.color!, + : Theme.of(context).textTheme.headlineSmall!.color!, strokeWidth: 2.0, dashPattern: const [8.0, 5.0], radius: const Radius.circular(10.0), @@ -114,7 +113,7 @@ class SelectFileWidgetState extends State { _messageToUser, maxLines: 2, style: widget.textStyle ?? - Theme.of(context).textTheme.headline5, + Theme.of(context).textTheme.headlineSmall, softWrap: true, textAlign: TextAlign.center, ), diff --git a/lib/widgets/reusable_widgets/settings_address.dart b/lib/widgets/reusable_widgets/settings_address.dart index 2002c2ad..4912b508 100644 --- a/lib/widgets/reusable_widgets/settings_address.dart +++ b/lib/widgets/reusable_widgets/settings_address.dart @@ -4,11 +4,7 @@ import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/material_icon_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/outlined_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/settings_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class SettingsAddress extends StatefulWidget { final String? address; @@ -21,7 +17,7 @@ class SettingsAddress extends StatefulWidget { }) : super(key: key); @override - _SettingsAddressState createState() => _SettingsAddressState(); + State createState() => _SettingsAddressState(); } class _SettingsAddressState extends State { @@ -34,7 +30,11 @@ class _SettingsAddressState extends State { @override void initState() { super.initState(); - _labelController.text = kAddressLabelMap[widget.address]!; + if (kAddressLabelMap[widget.address] != null) { + _labelController.text = kAddressLabelMap[widget.address]!; + } else { + _labelController.text = 'Address 1'; + } } @override @@ -65,10 +65,10 @@ class _SettingsAddressState extends State { children: [ Text( _labelController.text, - style: Theme.of(context).textTheme.bodyText1!.copyWith( + style: Theme.of(context).textTheme.bodyLarge!.copyWith( color: Theme.of(context) .textTheme - .bodyText1! + .bodyLarge! .color! .withOpacity(0.7), ), @@ -126,7 +126,7 @@ class _SettingsAddressState extends State { setState(() {}); }, inputtedTextStyle: - Theme.of(context).textTheme.bodyText2!.copyWith( + Theme.of(context).textTheme.bodyMedium!.copyWith( color: AppColors.znnColor, ), enabledBorder: OutlineInputBorder( @@ -191,7 +191,7 @@ class _SettingsAddressState extends State { Text _getAddressTextWidget() { return Text( widget.address!, - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, ); } diff --git a/lib/widgets/reusable_widgets/settings_node.dart b/lib/widgets/reusable_widgets/settings_node.dart index 16bee686..b2e61aa4 100644 --- a/lib/widgets/reusable_widgets/settings_node.dart +++ b/lib/widgets/reusable_widgets/settings_node.dart @@ -1,31 +1,30 @@ import 'package:flutter/material.dart'; +import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:hive/hive.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/node_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/material_icon_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/outlined_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/settings_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dialogs.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/standard_tooltip_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/input_field.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; +import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class SettingsNode extends StatefulWidget { final String node; final void Function(String?) onNodePressed; final VoidCallback onChangedOrDeletedNode; + final String currentNode; const SettingsNode({ required this.node, required this.onNodePressed, required this.onChangedOrDeletedNode, + required this.currentNode, Key? key, }) : super(key: key); @override - _SettingsNodeState createState() => _SettingsNodeState(); + State createState() => _SettingsNodeState(); } class _SettingsNodeState extends State { @@ -35,10 +34,18 @@ class _SettingsNodeState extends State { final GlobalKey _changeButtonKey = GlobalKey(); + int connectedNodeChainIdentifier = 1; + @override void initState() { - super.initState(); _nodeController.text = widget.node; + + NodeUtils.getNodeChainIdentifier().then((chainIdentifier) { + connectedNodeChainIdentifier = chainIdentifier; + setState(() {}); + }); + + super.initState(); } @override @@ -55,6 +62,7 @@ class _SettingsNodeState extends State { return Row( children: [ Expanded( + flex: 1, child: InkWell( borderRadius: BorderRadius.circular( 10.0, @@ -68,10 +76,10 @@ class _SettingsNodeState extends State { children: [ Text( _nodeController.text, - style: Theme.of(context).textTheme.bodyText1!.copyWith( + style: Theme.of(context).textTheme.bodyLarge!.copyWith( color: Theme.of(context) .textTheme - .bodyText1! + .bodyLarge! .color! .withOpacity(0.7), ), @@ -81,13 +89,48 @@ class _SettingsNodeState extends State { ), ), ), + Visibility( + visible: widget.currentNode.contains(widget.node), + child: StandardTooltipIcon( + (connectedNodeChainIdentifier == getChainIdentifier()) + ? 'Client chain identifier: ${getChainIdentifier().toString()}\n' + 'Node chain identifier: $connectedNodeChainIdentifier' + : 'Chain identifier mismatch\n' + 'Client chain identifier: ${getChainIdentifier().toString()}\n' + 'Node chain identifier: $connectedNodeChainIdentifier', + MaterialCommunityIcons.identifier, + iconColor: + (getChainIdentifier() == connectedNodeChainIdentifier) + ? AppColors.znnColor + : AppColors.errorColor)), const SizedBox( - width: 5.0, + width: 8.0, + ), + Visibility( + visible: widget.node.contains('wss://'), + child: const StandardTooltipIcon('Encrypted connection', Icons.lock), ), Visibility( - visible: widget.node.contains("Embedded"), + visible: widget.node.contains('ws://'), child: const StandardTooltipIcon( - 'The Embedded Node can take several hours to fully sync with the network', + 'Unencrypted connection', + Icons.lock_open, + iconColor: AppColors.errorColor, + ), + ), + Visibility( + visible: widget.node.contains('Embedded'), + child: const StandardTooltipIcon( + 'Integrated Full Node: enhanced security and privacy', + MaterialCommunityIcons.security, + ), + ), + Visibility( + visible: widget.node.contains('Embedded'), + child: const StandardTooltipIcon( + 'The Embedded Node validates all network transactions\n' + 'It may take several hours to fully sync with the network', + MaterialCommunityIcons.clock, ), ), const SizedBox( @@ -105,9 +148,6 @@ class _SettingsNodeState extends State { materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ), ), - const SizedBox( - width: 5.0, - ), Visibility( visible: !kDefaultNodes.contains(widget.node), child: MaterialIconButton( @@ -124,6 +164,7 @@ class _SettingsNodeState extends State { ); }, iconData: Icons.delete_forever, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ), ), ], @@ -150,7 +191,7 @@ class _SettingsNodeState extends State { setState(() {}); }, inputtedTextStyle: - Theme.of(context).textTheme.bodyText2!.copyWith( + Theme.of(context).textTheme.bodyMedium!.copyWith( color: AppColors.znnColor, ), enabledBorder: OutlineInputBorder( @@ -221,7 +262,7 @@ class _SettingsNodeState extends State { (key) => nodesBox.get(key) == widget.node, ); await nodesBox.put(key, _nodeController.text); - await NodeUtils.loadDbNodes(context); + await NodeUtils.loadDbNodes(); setState(() { _editable = false; }); @@ -263,6 +304,7 @@ class _SettingsNodeState extends State { ); await nodesBox.delete(nodeKey); kDbNodes.remove(node); + if (!mounted) return; Navigator.pop(context); widget.onChangedOrDeletedNode(); } catch (e) { diff --git a/lib/widgets/reusable_widgets/stepper_utils.dart b/lib/widgets/reusable_widgets/stepper_utils.dart index 02f1b1d6..97fb1777 100644 --- a/lib/widgets/reusable_widgets/stepper_utils.dart +++ b/lib/widgets/reusable_widgets/stepper_utils.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/available_balance.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_material_stepper.dart' as custom_material_stepper; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; @@ -19,14 +19,14 @@ class StepperUtils { return custom_material_stepper.Step( title: Text( stepTitle, - style: Theme.of(context).textTheme.headline2, + style: Theme.of(context).textTheme.headlineMedium, ), subtitle: stepState == custom_material_stepper.StepState.complete ? Row( children: [ Text( stepSubtitle, - style: Theme.of(context).textTheme.bodyText1!.copyWith( + style: Theme.of(context).textTheme.bodyLarge!.copyWith( fontSize: 12.0, color: stepSubtitleColor, ), diff --git a/lib/widgets/reusable_widgets/syrius_checkbox.dart b/lib/widgets/reusable_widgets/syrius_checkbox.dart new file mode 100644 index 00000000..1b119d80 --- /dev/null +++ b/lib/widgets/reusable_widgets/syrius_checkbox.dart @@ -0,0 +1,17 @@ +import 'package:flutter/material.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; + +class SyriusCheckbox extends Checkbox { + SyriusCheckbox({ + Key? key, + required Function(bool?) onChanged, + required bool? value, + required BuildContext context, + }) : super( + key: key, + onChanged: onChanged, + value: value, + checkColor: Theme.of(context).scaffoldBackgroundColor, + activeColor: AppColors.znnColor, + ); +} diff --git a/lib/widgets/reusable_widgets/tag_widget.dart b/lib/widgets/reusable_widgets/tag_widget.dart index ff9c392f..89193ed5 100644 --- a/lib/widgets/reusable_widgets/tag_widget.dart +++ b/lib/widgets/reusable_widgets/tag_widget.dart @@ -50,7 +50,7 @@ class TagWidget extends StatelessWidget { ), Text( text, - style: kText2TextStyle.copyWith( + style: kBodySmallTextStyle.copyWith( color: Colors.white, ), ), diff --git a/lib/widgets/reusable_widgets/transfer_icon_legend.dart b/lib/widgets/reusable_widgets/transfer_icon_legend.dart index 047848fa..03680c5f 100644 --- a/lib/widgets/reusable_widgets/transfer_icon_legend.dart +++ b/lib/widgets/reusable_widgets/transfer_icon_legend.dart @@ -27,7 +27,7 @@ class TransferIconLegend extends StatelessWidget { children: [ Text( legendText, - style: Theme.of(context).textTheme.bodyText2, + style: Theme.of(context).textTheme.bodyMedium, ), ], ), diff --git a/lib/widgets/tab_children_widgets/accelerator_tab_child.dart b/lib/widgets/tab_children_widgets/accelerator_tab_child.dart index 85ed0929..c7615d16 100644 --- a/lib/widgets/tab_children_widgets/accelerator_tab_child.dart +++ b/lib/widgets/tab_children_widgets/accelerator_tab_child.dart @@ -4,14 +4,7 @@ import 'package:provider/provider.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notifiers/default_address_notifier.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/accelerator_widgets/accelerator_donations.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/accelerator_widgets/accelerator_stats.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/accelerator_widgets/create_project.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/accelerator_widgets/project_list.dart' - as project_list; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class AcceleratorTabChild extends StatelessWidget { @@ -81,7 +74,7 @@ class AcceleratorTabChild extends StatelessWidget { FluidCell( width: kStaggeredNumOfColumns, child: Consumer( - builder: (_, __, ___) => project_list.ProjectList( + builder: (_, __, ___) => AccProjectList( onStepperNotificationSeeMorePressed: onStepperNotificationSeeMorePressed, pillarInfo: pillarInfo, diff --git a/lib/widgets/tab_children_widgets/bridge_tab_child.dart b/lib/widgets/tab_children_widgets/bridge_tab_child.dart index 0766fd85..477850a1 100644 --- a/lib/widgets/tab_children_widgets/bridge_tab_child.dart +++ b/lib/widgets/tab_children_widgets/bridge_tab_child.dart @@ -1,49 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:layout/layout.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/bridge_widgets/dynamic_multiplier_rewards_card.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/bridge_widgets/join_liquidity_program_card.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/bridge_widgets/swap_card.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class BridgeTabChild extends StatelessWidget { const BridgeTabChild({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - return StandardFluidLayout( - children: [ - FluidCell( - width: context.layout.value( - xl: kStaggeredNumOfColumns ~/ 3, - lg: kStaggeredNumOfColumns ~/ 3, - md: kStaggeredNumOfColumns ~/ 3, - sm: kStaggeredNumOfColumns, - xs: kStaggeredNumOfColumns, - ), - child: const JoinLiquidityProgramCard(), - ), - FluidCell( - height: kStaggeredNumOfColumns / 2, - width: context.layout.value( - xl: kStaggeredNumOfColumns ~/ 1.5, - lg: kStaggeredNumOfColumns ~/ 1.5, - md: kStaggeredNumOfColumns ~/ 1.5, - sm: kStaggeredNumOfColumns, - xs: kStaggeredNumOfColumns, - ), - child: const SwapCard(), - ), - FluidCell( - width: context.layout.value( - xl: kStaggeredNumOfColumns ~/ 3, - lg: kStaggeredNumOfColumns ~/ 3, - md: kStaggeredNumOfColumns ~/ 3, - sm: kStaggeredNumOfColumns ~/ 2, - xs: kStaggeredNumOfColumns, - ), - child: const DynamicMultiplierRewardsCard(), - ), - ], - ); + return const SwapCard(); } } diff --git a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart index d5f5e751..e8016d46 100644 --- a/lib/widgets/tab_children_widgets/dashboard_tab_child.dart +++ b/lib/widgets/tab_children_widgets/dashboard_tab_child.dart @@ -1,21 +1,8 @@ import 'package:flutter/material.dart'; import 'package:layout/layout.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/plasma/plasma_stats_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/main_app_container.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/dashboard_widgets/balance.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/dashboard_widgets/delegation_stats.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/dashboard_widgets/dual_coin_stats.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/dashboard_widgets/pillars.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/dashboard_widgets/realtime_statistics.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/dashboard_widgets/sentinels.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/dashboard_widgets/staking.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/dashboard_widgets/swap_decay.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/dashboard_widgets/total_hourly_transactions.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/dashboard_widgets/transfer.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class DashboardTabChild extends StatefulWidget { final void Function( @@ -27,7 +14,7 @@ class DashboardTabChild extends StatefulWidget { const DashboardTabChild({Key? key, this.changePage}) : super(key: key); @override - _DashboardTabChildState createState() => _DashboardTabChildState(); + State createState() => _DashboardTabChildState(); } class _DashboardTabChildState extends State { @@ -65,7 +52,7 @@ class _DashboardTabChildState extends State { ), const FluidCell( child: TotalHourlyTransactions(), - height: kStaggeredNumOfColumns / 8, + height: kStaggeredNumOfColumns / 4, ), const FluidCell( child: Pillars(), @@ -75,17 +62,12 @@ class _DashboardTabChildState extends State { child: Staking(), height: kStaggeredNumOfColumns / 8, ), - const FluidCell( - child: SwapDecay(), - height: kStaggeredNumOfColumns / 8, - ), const FluidCell( child: DelegationStats(), height: kStaggeredNumOfColumns / 8, ), - FluidCell( - child: const Sentinels(), - width: defaultCellWidth, + const FluidCell( + child: Sentinels(), height: kStaggeredNumOfColumns / 8, ), FluidCell( diff --git a/lib/widgets/tab_children_widgets/help_tab_child.dart b/lib/widgets/tab_children_widgets/help_tab_child.dart index 75ae0b6d..3536ac8a 100644 --- a/lib/widgets/tab_children_widgets/help_tab_child.dart +++ b/lib/widgets/tab_children_widgets/help_tab_child.dart @@ -1,9 +1,6 @@ import 'package:flutter/material.dart'; import 'package:layout/layout.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/help_widgets/about_card.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/help_widgets/community_card.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/help_widgets/update_card.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class HelpTabChild extends StatelessWidget { const HelpTabChild({Key? key}) : super(key: key); diff --git a/lib/widgets/tab_children_widgets/lock_tab_child.dart b/lib/widgets/tab_children_widgets/lock_tab_child.dart index 9f1ca1e4..b0c3d627 100644 --- a/lib/widgets/tab_children_widgets/lock_tab_child.dart +++ b/lib/widgets/tab_children_widgets/lock_tab_child.dart @@ -1,16 +1,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/screens/splash_screen.dart'; +import 'package:zenon_syrius_wallet_flutter/screens/screens.dart'; import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/global.dart'; +import 'package:zenon_syrius_wallet_flutter/utils/init_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/keystore_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/navigation_utils.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notification_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/utils/utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/buttons/loading_button.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/input_field/password_input_field.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; import 'package:znn_sdk_dart/znn_sdk_dart.dart'; class LockTabChild extends StatefulWidget { @@ -22,7 +21,7 @@ class LockTabChild extends StatefulWidget { : super(key: key); @override - _LockTabChildState createState() => _LockTabChildState(); + State createState() => _LockTabChildState(); } class _LockTabChildState extends State { @@ -50,7 +49,7 @@ class _LockTabChildState extends State { children: [ const Icon( Fontisto.locked, - color: Color.fromRGBO(63, 63, 63, 1), + color: AppColors.znnColor, size: 50.0, ), const SizedBox( @@ -58,14 +57,14 @@ class _LockTabChildState extends State { ), Text( 'Welcome Back', - style: Theme.of(context).textTheme.headline2, + style: Theme.of(context).textTheme.headlineMedium, ), const SizedBox( height: 20.0, ), Text( 'Enter the password to access the wallet', - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineSmall, ), const SizedBox( height: 40.0, @@ -97,11 +96,11 @@ class _LockTabChildState extends State { ? Text( 'Last attempt. The wallet will be reset if this ' 'attempt fails', - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineSmall, ) : Text( '${kAutoEraseWalletLimit!.toInt() - kNumFailedUnlockAttempts!} attempts left', - style: Theme.of(context).textTheme.headline4, + style: Theme.of(context).textTheme.headlineSmall, ), ), Visibility( @@ -110,7 +109,7 @@ class _LockTabChildState extends State { padding: const EdgeInsets.only(top: 30.0), child: Text( _messageToUser, - style: Theme.of(context).textTheme.bodyText1, + style: Theme.of(context).textTheme.bodyLarge, ), ), ), @@ -165,7 +164,7 @@ class _LockTabChildState extends State { setState(() { _messageToUser = 'Initializing wallet, please wait'; }); - await Utils.initWalletAfterDecryption(context); + await InitUtils.initWalletAfterDecryption(); widget.afterInitCallback(); } else { await widget.afterUnlockCallback(_passwordController.text); diff --git a/lib/widgets/tab_children_widgets/notifications_tab_child.dart b/lib/widgets/tab_children_widgets/notifications_tab_child.dart index a7fe633b..8762ea66 100644 --- a/lib/widgets/tab_children_widgets/notifications_tab_child.dart +++ b/lib/widgets/tab_children_widgets/notifications_tab_child.dart @@ -2,21 +2,17 @@ import 'package:expandable/expandable.dart'; import 'package:flutter/material.dart'; import 'package:flutter_vector_icons/flutter_vector_icons.dart'; import 'package:hive/hive.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/sentinels/sentinel_list_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/model/database/wallet_notification.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/constants.dart'; import 'package:zenon_syrius_wallet_flutter/utils/format_utils.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/custom_table.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/icons/copy_to_clipboard_icon.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/overscroll_remover.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/widget_animator.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class NotificationsTabChild extends StatefulWidget { const NotificationsTabChild({Key? key}) : super(key: key); @override - _NotificationsTabChildState createState() => _NotificationsTabChildState(); + State createState() => _NotificationsTabChildState(); } class _NotificationsTabChildState extends State { @@ -26,12 +22,9 @@ class _NotificationsTabChildState extends State { Widget build(BuildContext context) { _loadNotifications(); - return ScrollConfiguration( - behavior: RemoveOverscrollEffect(), - child: WidgetAnimator( - curve: Curves.linear, - child: _getNotificationsContainer(), - ), + return WidgetAnimator( + curve: Curves.linear, + child: _getNotificationsContainer(), ); } @@ -59,7 +52,7 @@ class _NotificationsTabChildState extends State { return ExpandablePanel( collapsed: Container(), theme: ExpandableThemeData( - iconColor: Theme.of(context).textTheme.subtitle1!.color, + iconColor: Theme.of(context).textTheme.titleMedium!.color, headerAlignment: ExpandablePanelHeaderAlignment.center, iconPlacement: ExpandablePanelIconPlacement.right, ), @@ -72,7 +65,7 @@ class _NotificationsTabChildState extends State { Expanded( child: Text( notification.title!, - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ), ], @@ -84,7 +77,7 @@ class _NotificationsTabChildState extends State { Expanded( child: Text( notification.details!, - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), ), CopyToClipboardIcon(notification.details), @@ -97,12 +90,12 @@ class _NotificationsTabChildState extends State { RawMaterialButton _getClearIcon(WalletNotification? notification) { return RawMaterialButton( onPressed: () => _deleteNotification(notification!.timestamp), + shape: const CircleBorder(), child: Icon( SimpleLineIcons.close, color: Theme.of(context).colorScheme.secondary, size: 20.0, ), - shape: const CircleBorder(), ); } diff --git a/lib/widgets/tab_children_widgets/pillars_tab_child.dart b/lib/widgets/tab_children_widgets/pillars_tab_child.dart index 958b49e3..e383791f 100644 --- a/lib/widgets/tab_children_widgets/pillars_tab_child.dart +++ b/lib/widgets/tab_children_widgets/pillars_tab_child.dart @@ -1,11 +1,7 @@ import 'package:flutter/material.dart'; import 'package:layout/layout.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/pillars/pillar_rewards_history_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/pillars_widgets/create_pillar.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/pillars_widgets/pillar_collect.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/pillars_widgets/pillar_rewards.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/pillars_widgets/pillars_list_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class PillarsTabChild extends StatefulWidget { final VoidCallback onStepperNotificationSeeMorePressed; diff --git a/lib/widgets/tab_children_widgets/plasma_tab_child.dart b/lib/widgets/tab_children_widgets/plasma_tab_child.dart index 7c74ea9f..34a6fb52 100644 --- a/lib/widgets/tab_children_widgets/plasma_tab_child.dart +++ b/lib/widgets/tab_children_widgets/plasma_tab_child.dart @@ -1,16 +1,11 @@ import 'package:flutter/material.dart'; import 'package:layout/layout.dart'; import 'package:provider/provider.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/plasma/plasma_list_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/plasma/plasma_stats_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/main.dart'; -import 'package:zenon_syrius_wallet_flutter/model/plasma_info_wrapper.dart'; +import 'package:zenon_syrius_wallet_flutter/model/model.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notifiers/plasma_generated_notifier.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/dashboard_widgets/plasma_stats.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/plasma_widgets/plasma_list/plasma_list.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/plasma_widgets/plasma_options/plasma_options.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/loading_widget.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class PlasmaTabChild extends StatefulWidget { const PlasmaTabChild({Key? key}) : super(key: key); diff --git a/lib/widgets/tab_children_widgets/sentinels_tab_child.dart b/lib/widgets/tab_children_widgets/sentinels_tab_child.dart index 913a67b0..3ba19c8c 100644 --- a/lib/widgets/tab_children_widgets/sentinels_tab_child.dart +++ b/lib/widgets/tab_children_widgets/sentinels_tab_child.dart @@ -1,11 +1,7 @@ import 'package:flutter/material.dart'; import 'package:layout/layout.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/sentinels/sentinel_rewards_history_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/sentinel_widgets/create_sentinel.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/sentinel_widgets/sentinel_collect.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/sentinel_widgets/sentinel_rewards.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/sentinel_widgets/sentinels_list_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class SentinelsTabChild extends StatefulWidget { final VoidCallback onStepperNotificationSeeMorePressed; diff --git a/lib/widgets/tab_children_widgets/settings_tab_child.dart b/lib/widgets/tab_children_widgets/settings_tab_child.dart index 434e832a..88aee2de 100644 --- a/lib/widgets/tab_children_widgets/settings_tab_child.dart +++ b/lib/widgets/tab_children_widgets/settings_tab_child.dart @@ -1,16 +1,7 @@ import 'package:flutter/material.dart'; import 'package:layout/layout.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/settings/account_chain_stats_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/settings_widgets/account_chain_stats.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/settings_widgets/addresses.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/settings_widgets/backup.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/settings_widgets/display.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/settings_widgets/general.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/settings_widgets/node_management.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/settings_widgets/peers.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/settings_widgets/security.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/settings_widgets/wallet_options.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class SettingsTabChild extends StatefulWidget { final VoidCallback _onChangeAutoLockTime; diff --git a/lib/widgets/tab_children_widgets/staking_tab_child.dart b/lib/widgets/tab_children_widgets/staking_tab_child.dart index a03198aa..f6faf556 100644 --- a/lib/widgets/tab_children_widgets/staking_tab_child.dart +++ b/lib/widgets/tab_children_widgets/staking_tab_child.dart @@ -1,14 +1,9 @@ import 'package:flutter/material.dart'; import 'package:layout/layout.dart'; import 'package:provider/provider.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/staking/staking_list_bloc.dart'; -import 'package:zenon_syrius_wallet_flutter/blocs/staking/staking_rewards_history_bloc.dart'; +import 'package:zenon_syrius_wallet_flutter/blocs/blocs.dart'; import 'package:zenon_syrius_wallet_flutter/utils/notifiers/default_address_notifier.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/staking_widgets/stake_collect.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/staking_widgets/staking_list/staking_list.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/staking_widgets/staking_options/staking_options.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/staking_widgets/staking_rewards.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class StakingTabChild extends StatefulWidget { const StakingTabChild({Key? key}) : super(key: key); diff --git a/lib/widgets/tab_children_widgets/tab_children_widgets.dart b/lib/widgets/tab_children_widgets/tab_children_widgets.dart new file mode 100644 index 00000000..75d2bb11 --- /dev/null +++ b/lib/widgets/tab_children_widgets/tab_children_widgets.dart @@ -0,0 +1,13 @@ +export 'accelerator_tab_child.dart'; +export 'bridge_tab_child.dart'; +export 'dashboard_tab_child.dart'; +export 'help_tab_child.dart'; +export 'lock_tab_child.dart'; +export 'notifications_tab_child.dart'; +export 'pillars_tab_child.dart'; +export 'plasma_tab_child.dart'; +export 'sentinels_tab_child.dart'; +export 'settings_tab_child.dart'; +export 'staking_tab_child.dart'; +export 'tokens_tab_child.dart'; +export 'transfer_tab_child.dart'; diff --git a/lib/widgets/tab_children_widgets/tokens_tab_child.dart b/lib/widgets/tab_children_widgets/tokens_tab_child.dart index bfa5a11a..c586af38 100644 --- a/lib/widgets/tab_children_widgets/tokens_tab_child.dart +++ b/lib/widgets/tab_children_widgets/tokens_tab_child.dart @@ -1,9 +1,6 @@ import 'package:flutter/material.dart'; import 'package:layout/layout.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/token_widgets/create_token.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/token_widgets/token_balance.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/token_widgets/token_map.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; class TokensTabChild extends StatelessWidget { final VoidCallback onStepperNotificationSeeMorePressed; diff --git a/lib/widgets/tab_children_widgets/transfer_tab_child.dart b/lib/widgets/tab_children_widgets/transfer_tab_child.dart index 6dcc446f..dfc12a9a 100644 --- a/lib/widgets/tab_children_widgets/transfer_tab_child.dart +++ b/lib/widgets/tab_children_widgets/transfer_tab_child.dart @@ -1,13 +1,6 @@ import 'package:flutter/material.dart'; import 'package:layout/layout.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/transfer_widgets/latest_transactions/latest_transactions_transfer_widget.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/transfer_widgets/receive/receive_large.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/transfer_widgets/receive/receive_medium.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/transfer_widgets/receive/receive_small.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/transfer_widgets/send/send_large.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/transfer_widgets/send/send_medium.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/transfer_widgets/send/send_small.dart'; -import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/standard_fluid_layout.dart'; +import 'package:zenon_syrius_wallet_flutter/widgets/widgets.dart'; enum DimensionCard { small, medium, large } @@ -24,7 +17,7 @@ class TransferTabChild extends StatefulWidget { }) : super(key: key); @override - _TransferTabChildState createState() => _TransferTabChildState(); + State createState() => _TransferTabChildState(); } class _TransferTabChildState extends State { @@ -71,7 +64,6 @@ class _TransferTabChildState extends State { SendLargeCard( extendIcon: true, onCollapsePressed: _onCollapse, - onOkBridgeWarningDialogPressed: widget.navigateToBridgeTab, ), ); diff --git a/lib/widgets/widgets.dart b/lib/widgets/widgets.dart new file mode 100644 index 00000000..7a7c38dc --- /dev/null +++ b/lib/widgets/widgets.dart @@ -0,0 +1,8 @@ +export 'charts/pillar_rewards_chart.dart'; +export 'charts/realtime_txs_chart.dart'; +export 'charts/sentinel_rewards_chart.dart'; +export 'charts/staking_rewards_chart.dart'; +export 'main_app_container.dart'; +export 'modular_widgets/modular_widgets.dart'; +export 'reusable_widgets/reusable_widgets.dart'; +export 'tab_children_widgets/tab_children_widgets.dart'; diff --git a/linux/.gitignore b/linux/.gitignore new file mode 100644 index 00000000..d3896c98 --- /dev/null +++ b/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt new file mode 100644 index 00000000..16b029a0 --- /dev/null +++ b/linux/CMakeLists.txt @@ -0,0 +1,177 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.10) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "syrius") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "network.zenon.syrius") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Define the application target. To change its name, change BINARY_NAME above, +# not the value here, or `flutter run` will no longer work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Bundle required ZNN libraries for Syrius +set(SYRIUS_PROJECT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/..") + +# Leveraging flutter to identify dependency locations +file(STRINGS "${SYRIUS_PROJECT_DIRECTORY}/.dart_tool/package_config.json" + ZNN_SDK_DART_PATH REGEX "(file:).*(znn_sdk_dart).*\\/\"" ) + +if (ZNN_SDK_DART_PATH STREQUAL "") + file(STRINGS "${SYRIUS_PROJECT_DIRECTORY}/.dart_tool/package_config.json" + ZNN_SDK_DART_PATH REGEX "(rootUri).*(znn_sdk_dart).*\"" ) + string(REPLACE "\"rootUri\": \"" "" ZNN_SDK_DART_PATH "${ZNN_SDK_DART_PATH}") + string(REPLACE "/\"," "" ZNN_SDK_DART_PATH "${ZNN_SDK_DART_PATH}") + string(REPLACE "\"," "" ZNN_SDK_DART_PATH "${ZNN_SDK_DART_PATH}") + string(STRIP "${ZNN_SDK_DART_PATH}" ZNN_SDK_DART_PATH) +else() + string(REPLACE "\"rootUri\": \"file://" "" ZNN_SDK_DART_PATH "${ZNN_SDK_DART_PATH}") + string(REPLACE "/\"," "" ZNN_SDK_DART_PATH "${ZNN_SDK_DART_PATH}") + string(STRIP "${ZNN_SDK_DART_PATH}" ZNN_SDK_DART_PATH) +endif() + +list(APPEND SYRIUS_LIBRARIES + "${SYRIUS_PROJECT_DIRECTORY}/lib/embedded_node/blobs/libznn.so" + "${ZNN_SDK_DART_PATH}/lib/src/argon2/blobs/libargon2_ffi_plugin.so" + "${ZNN_SDK_DART_PATH}/lib/src/pow/blobs/libpow_links.so" +) + +foreach(znn_library ${SYRIUS_LIBRARIES}) + install(FILES "${znn_library}" + DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + message(STATUS "Copy ZNN library: \"${znn_library}\"") +endforeach(znn_library) + +add_custom_target( + "git_metadata" ALL + COMMAND "${CMAKE_HOME_DIRECTORY}/create-git-metadata.sh" + WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY} +) \ No newline at end of file diff --git a/linux/create-git-metadata.sh b/linux/create-git-metadata.sh new file mode 100755 index 00000000..4711295d --- /dev/null +++ b/linux/create-git-metadata.sh @@ -0,0 +1,14 @@ +GIT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) +GIT_COMMIT_HASH=$(git rev-parse HEAD) +GIT_COMMIT_MESSAGE=$(git log -1 --pretty=%s) +GIT_COMMIT_DATE=$(git --no-pager log -1 --format="%ai") +GIT_ORIGIN_URL=$(git config --get remote.origin.url) +GIT_COMMIT_FILE="../lib/utils/metadata.dart" + +sed --i '1,5d' $GIT_COMMIT_FILE + +echo "const String gitBranchName = '$GIT_BRANCH_NAME';" >> $GIT_COMMIT_FILE +echo "const String gitCommitHash = '$GIT_COMMIT_HASH';" >> $GIT_COMMIT_FILE +echo "const String gitCommitMessage = '$GIT_COMMIT_MESSAGE';" >> $GIT_COMMIT_FILE +echo "const String gitCommitDate = '$GIT_COMMIT_DATE';" >> $GIT_COMMIT_FILE +echo "const String gitOriginUrl = '$GIT_ORIGIN_URL';" >> $GIT_COMMIT_FILE diff --git a/linux/flutter/CMakeLists.txt b/linux/flutter/CMakeLists.txt new file mode 100644 index 00000000..d5bd0164 --- /dev/null +++ b/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 00000000..d5a08dfd --- /dev/null +++ b/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,39 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include +#include +#include +#include +#include +#include +#include + +void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) desktop_drop_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopDropPlugin"); + desktop_drop_plugin_register_with_registrar(desktop_drop_registrar); + g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); + file_selector_plugin_register_with_registrar(file_selector_linux_registrar); + g_autoptr(FlPluginRegistrar) local_notifier_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "LocalNotifierPlugin"); + local_notifier_plugin_register_with_registrar(local_notifier_registrar); + g_autoptr(FlPluginRegistrar) screen_retriever_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin"); + screen_retriever_plugin_register_with_registrar(screen_retriever_registrar); + g_autoptr(FlPluginRegistrar) tray_manager_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "TrayManagerPlugin"); + tray_manager_plugin_register_with_registrar(tray_manager_registrar); + g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); + url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); + g_autoptr(FlPluginRegistrar) window_manager_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin"); + window_manager_plugin_register_with_registrar(window_manager_registrar); +} diff --git a/linux/flutter/generated_plugin_registrant.h b/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 00000000..e0f0a47b --- /dev/null +++ b/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake new file mode 100644 index 00000000..5ff4a42c --- /dev/null +++ b/linux/flutter/generated_plugins.cmake @@ -0,0 +1,30 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + desktop_drop + file_selector_linux + local_notifier + screen_retriever + tray_manager + url_launcher_linux + window_manager +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/linux/main.cc b/linux/main.cc new file mode 100644 index 00000000..e7c5c543 --- /dev/null +++ b/linux/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/linux/my_application.cc b/linux/my_application.cc new file mode 100644 index 00000000..6e89d935 --- /dev/null +++ b/linux/my_application.cc @@ -0,0 +1,106 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "syrius"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "syrius"); + } + + // gtk_window_set_icon_from_file(GTK_WINDOW(window), "linux/resources/app_icon.png", NULL); + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/linux/my_application.h b/linux/my_application.h new file mode 100644 index 00000000..72271d5e --- /dev/null +++ b/linux/my_application.h @@ -0,0 +1,18 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/linux/resources/app_icon.png b/linux/resources/app_icon.png new file mode 100644 index 00000000..8ce81d3f Binary files /dev/null and b/linux/resources/app_icon.png differ diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 9d952dd3..d23ae2d5 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ isa = PBXAggregateTarget; buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; buildPhases = ( + 96A0E3322987BEC500EDD131 /* ShellScript */, 33CC111E2044C6BF0003C045 /* ShellScript */, ); dependencies = ( @@ -27,6 +28,9 @@ 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; 74B27E3AADF4DA759158BD4B /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E5DFBCCB2F3B416824983EAB /* Pods_Runner.framework */; }; + 9631FB752956060A007ED711 /* ../lib/embedded_node/blobs/libznn.dylib in Resources */ = {isa = PBXBuildFile; fileRef = 04CC766027C81F7E00DBC357 /* ../lib/embedded_node/blobs/libznn.dylib */; }; + 9631FB86295610FB007ED711 /* libargon2_ffi.dylib in Resources */ = {isa = PBXBuildFile; fileRef = 9631FB7A29560ECB007ED711 /* libargon2_ffi.dylib */; }; + 9631FB87295610FF007ED711 /* libpow_links.dylib in Resources */ = {isa = PBXBuildFile; fileRef = 9631FB8229560F53007ED711 /* libpow_links.dylib */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -53,10 +57,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 04CC765727C81EF600DBC357 /* libExportWallet.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libExportWallet.dylib; sourceTree = ""; }; - 04CC765827C81EF600DBC357 /* libargon2_ffi.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libargon2_ffi.dylib; sourceTree = ""; }; - 04CC765927C81EF600DBC357 /* libpow_links.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libpow_links.dylib; sourceTree = ""; }; - 04CC766027C81F7E00DBC357 /* libznn.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libznn.dylib; sourceTree = ""; }; + 04CC766027C81F7E00DBC357 /* ../lib/embedded_node/blobs/libznn.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = ../lib/embedded_node/blobs/libznn.dylib; sourceTree = ""; }; 159BBDEDF6B164A788D81F92 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; @@ -74,6 +75,8 @@ 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; 42B5975FEA7102303C16308A /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9631FB7A29560ECB007ED711 /* libargon2_ffi.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libargon2_ffi.dylib; sourceTree = ""; }; + 9631FB8229560F53007ED711 /* libpow_links.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libpow_links.dylib; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; DDCA1E2CBCCC96B9436CF502 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; E5DFBCCB2F3B416824983EAB /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -124,10 +127,9 @@ 33CC11242044D66E0003C045 /* Resources */ = { isa = PBXGroup; children = ( - 04CC766027C81F7E00DBC357 /* libznn.dylib */, - 04CC765827C81EF600DBC357 /* libargon2_ffi.dylib */, - 04CC765727C81EF600DBC357 /* libExportWallet.dylib */, - 04CC765927C81EF600DBC357 /* libpow_links.dylib */, + 9631FB7A29560ECB007ED711 /* libargon2_ffi.dylib */, + 9631FB8229560F53007ED711 /* libpow_links.dylib */, + 04CC766027C81F7E00DBC357 /* ../lib/embedded_node/blobs/libznn.dylib */, 33CC10F22044A3C60003C045 /* Assets.xcassets */, 33CC10F42044A3C60003C045 /* MainMenu.xib */, 33CC10F72044A3C60003C045 /* Info.plist */, @@ -186,6 +188,7 @@ buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( 26152DF600C95C6136D5E940 /* [CP] Check Pods Manifest.lock */, + 96DA24F0296EB70E00545E88 /* ShellScript */, 33CC10E92044A3C60003C045 /* Sources */, 33CC10EA2044A3C60003C045 /* Frameworks */, 33CC10EB2044A3C60003C045 /* Resources */, @@ -210,7 +213,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1400; ORGANIZATIONNAME = ""; TargetAttributes = { 33CC10EC2044A3C60003C045 = { @@ -253,6 +256,9 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 9631FB87295610FF007ED711 /* libpow_links.dylib in Resources */, + 9631FB86295610FB007ED711 /* libargon2_ffi.dylib in Resources */, + 9631FB752956060A007ED711 /* ../lib/embedded_node/blobs/libznn.dylib in Resources */, 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, ); @@ -291,6 +297,7 @@ inputFileListPaths = ( ); inputPaths = ( + "", ); outputFileListPaths = ( ); @@ -318,7 +325,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire\n"; }; 50C0A8AFDC34B7D28837F481 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; @@ -337,6 +344,40 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; + 96A0E3322987BEC500EDD131 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "GIT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)\nGIT_COMMIT_HASH=$(git rev-parse HEAD)\nGIT_COMMIT_MESSAGE=$(git log -1 --pretty=%s)\nGIT_COMMIT_DATE=$(git --no-pager log -1 --format=\"%ai\")\nGIT_ORIGIN_URL=$(git config --get remote.origin.url)\nGIT_COMMIT_FILE=\"../lib/utils/metadata.dart\"\n\nsed -i '' '1,5d' $GIT_COMMIT_FILE\necho \"const String gitBranchName = '$GIT_BRANCH_NAME';\" >> $GIT_COMMIT_FILE\necho \"const String gitCommitHash = '$GIT_COMMIT_HASH';\" >> $GIT_COMMIT_FILE\necho \"const String gitCommitMessage = '$GIT_COMMIT_MESSAGE';\" >> $GIT_COMMIT_FILE\necho \"const String gitCommitDate = '$GIT_COMMIT_DATE';\" >> $GIT_COMMIT_FILE\necho \"const String gitOriginUrl = '$GIT_ORIGIN_URL';\" >> $GIT_COMMIT_FILE\n\n\n"; + }; + 96DA24F0296EB70E00545E88 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 12; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "OUTPUT_DIRECTORY=\"./\"\n\nPACKAGE_CONFIG=\"../.dart_tool/package_config.json\"\nZNN_SDK_DART_PATH=`cat $PACKAGE_CONFIG | grep git/znn_sdk_dart | sed 's/\"rootUri\": \"file:\\/\\///' | sed 's/\\/\",//' | xargs` \n\nSYRIUS_LIBRARIES=(\n \"$ZNN_SDK_DART_PATH/lib/src/argon2/blobs/libargon2_ffi.dylib\"\n \"$ZNN_SDK_DART_PATH/lib/src/pow/blobs/libpow_links.dylib\"\n)\n\necho \"$OUTPUT_DIRECTORY\"\n\nfor znn_library in ${SYRIUS_LIBRARIES[@]}; do\n echo \"Copy ZNN library: $znn_library\"\n cp $znn_library \"$OUTPUT_DIRECTORY\"\ndone\n"; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -401,6 +442,7 @@ CLANG_WARN_SUSPICIOUS_MOVE = YES; CODE_SIGN_IDENTITY = "-"; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -411,7 +453,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -437,7 +479,8 @@ "$(inherited)", "$(PROJECT_DIR)", ); - MARKETING_VERSION = "v0.0.5-alphanet"; + MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; + MARKETING_VERSION = "v0.0.6-alphanet"; PRODUCT_BUNDLE_IDENTIFIER = network.zenon.syrius; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; @@ -448,6 +491,8 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Manual; + DEAD_CODE_STRIPPING = YES; + MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Profile; @@ -480,6 +525,7 @@ CLANG_WARN_SUSPICIOUS_MOVE = YES; CODE_SIGN_IDENTITY = "-"; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -496,7 +542,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -533,6 +579,7 @@ CLANG_WARN_SUSPICIOUS_MOVE = YES; CODE_SIGN_IDENTITY = "-"; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -543,7 +590,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -569,7 +616,8 @@ "$(inherited)", "$(PROJECT_DIR)", ); - MARKETING_VERSION = "v0.0.5-alphanet"; + MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; + MARKETING_VERSION = "v0.0.6-alphanet"; PRODUCT_BUNDLE_IDENTIFIER = network.zenon.syrius; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -595,7 +643,8 @@ "$(inherited)", "$(PROJECT_DIR)", ); - MARKETING_VERSION = "v0.0.5-alphanet"; + MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; + MARKETING_VERSION = "v0.0.6-alphanet"; PRODUCT_BUNDLE_IDENTIFIER = network.zenon.syrius; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; @@ -606,6 +655,8 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Manual; + DEAD_CODE_STRIPPING = YES; + MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -614,6 +665,8 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; + DEAD_CODE_STRIPPING = YES; + MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; diff --git a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 8fddbeb1..2b6fa26c 100644 --- a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ =3.0.0-134.0.dev <4.0.0" + flutter: ">=3.7.0-0" diff --git a/pubspec.yaml b/pubspec.yaml index dae6ba1b..e05590c9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: zenon_syrius_wallet_flutter description: Zenon cross-platform non-custodial wallet -version: 0.0.5 +version: 0.0.6 publish_to: none environment: @@ -10,68 +10,60 @@ dependencies: flutter: sdk: flutter - fl_chart: ^0.41.0 - overlay_support: ^1.2.1 - lottie: ^1.2.1 + fl_chart: ^0.60.0 + overlay_support: ^2.1.0 + lottie: ^2.1.0 dotted_border: ^2.0.0+2 - flutter_svg: ^1.0.3 - flutter_vector_icons: ^1.0.0 + flutter_svg: ^2.0.0+1 + flutter_vector_icons: ^2.0.0 expandable: ^5.0.1 marquee_widget: ^1.2.0 layout: ^1.0.2 flutter_staggered_grid_view: 0.4.0 - flip_card: ^0.6.0 + flip_card: ^0.7.0 auto_size_text: ^3.0.0 - window_manager: 0.2.0 - stacked: ^2.2.8 + window_manager: ^0.3.0 + stacked: ^3.1.0 path_provider: ^2.0.8 rxdart: ^0.27.3 hive: ^2.0.5 url_launcher: ^6.0.18 provider: ^6.0.2 - intl: ^0.17.0 - feedback: '>=2.0.0 <2.3.0' - package_info_plus: ^1.3.0 - device_info_plus: ^3.2.1 + intl: ^0.18.0 + package_info_plus: ^3.0.2 + device_info_plus: ^8.0.0 infinite_scroll_pagination: ^3.1.0 - share_plus: ^4.0.4 + share_plus: ^6.3.0 page_transition: ^2.0.4 - file_selector_platform_interface: ^2.0.4 - pretty_qr_code: ^2.0.2 - desktop_drop: ^0.3.0 - network_info_plus: ^2.1.2 + file_selector: ^0.9.2+2 + pretty_qr_code: ^2.0.3 + screenshot: ^1.3.0 + desktop_drop: ^0.4.0 validators: ^3.0.0 wakelock: ^0.6.1+2 - file_selector_windows: - git: - url: https://github.com/google/flutter-desktop-embedding.git - path: plugins/file_selector/file_selector_windows - ref: 38c4c9024665483cf4afadd768fdfcb32e43bd64 - file_selector_macos: - git: - url: https://github.com/google/flutter-desktop-embedding.git - path: plugins/file_selector/file_selector_macos - ref: d28f8ae6c289f999e08f5f37b9901fad2bc33b65 - file_selector_linux: - git: - url: https://github.com/google/flutter-desktop-embedding.git - path: plugins/file_selector/file_selector_linux - ref: 38c4c9024665483cf4afadd768fdfcb32e43bd64 + number_selector: ^1.0.5 znn_sdk_dart: git: url: https://github.com/zenon-network/znn_sdk_dart.git - ref: 367ddc7fbfefb6484d7553d9ac7e4532003a7008 - znn_swap_utility: - git: - url: https://github.com/zenon-network/znn_swap_utility.git - ref: 417d3a42bb0ce1f9fab5dd4d6e8481112afbbbfc + ref: master + json_rpc_2: ^3.0.2 + path: ^1.8.2 + ffi: ^2.0.1 + get_it: ^7.2.0 + hex: ^0.2.0 + local_notifier: ^0.1.5 + tray_manager: ^0.2.0 + open_filex: ^4.3.2 + launch_at_startup: ^0.2.1 + logging: ^1.1.1 dev_dependencies: flutter_test: sdk: flutter build_runner: ^2.1.7 - hive_generator: ^1.1.2 - flutter_lints: ^1.0.4 + hive_generator: ^2.0.0 + flutter_lints: ^2.0.1 + dependency_validator: ^3.0.0 flutter: uses-material-design: true diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt index 6970178c..c8b15803 100644 --- a/windows/CMakeLists.txt +++ b/windows/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.15) project(syrius LANGUAGES CXX) set(BINARY_NAME "syrius") +set(APPLICATION_ID "network.zenon.syrius") cmake_policy(SET CMP0063 NEW) @@ -93,3 +94,31 @@ install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) + +# Bundle required ZNN libraries for Syrius +set(SYRIUS_PROJECT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/..") + +# Leveraging flutter to identify dependency locations +file(STRINGS "${SYRIUS_PROJECT_DIRECTORY}/.dart_tool/package_config.json" + ZNN_SDK_DART_PATH REGEX "(file:).*(znn_sdk_dart).*\\/\"" ) + +string(REPLACE "\"rootUri\": \"file:///" "" ZNN_SDK_DART_PATH "${ZNN_SDK_DART_PATH}") +string(REPLACE "/\"," "" ZNN_SDK_DART_PATH "${ZNN_SDK_DART_PATH}") +string(STRIP "${ZNN_SDK_DART_PATH}" ZNN_SDK_DART_PATH) + +list(APPEND SYRIUS_LIBRARIES + "${SYRIUS_PROJECT_DIRECTORY}/lib/embedded_node/blobs/libznn.dll" + "${ZNN_SDK_DART_PATH}/lib/src/argon2/blobs/argon2_ffi_plugin.dll" + "${ZNN_SDK_DART_PATH}/lib/src/pow/blobs/libpow_links.dll" +) + +foreach(znn_library ${SYRIUS_LIBRARIES}) + install(FILES "${znn_library}" + DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + message(STATUS "Copy ZNN library: \"${znn_library}\"") +endforeach(znn_library) + +find_program(POWERSHELL_PATH NAMES powershell) +add_custom_target("git_metadata" ALL + COMMAND ${POWERSHELL_PATH} "${CMAKE_HOME_DIRECTORY}/CreateGitMetadata.ps1") \ No newline at end of file diff --git a/windows/CreateGitMetadata.ps1 b/windows/CreateGitMetadata.ps1 new file mode 100644 index 00000000..e376da88 --- /dev/null +++ b/windows/CreateGitMetadata.ps1 @@ -0,0 +1,14 @@ +$GIT_BRANCH_NAME = git rev-parse --abbrev-ref HEAD +$GIT_COMMIT_HASH = git rev-parse HEAD +$GIT_COMMIT_MESSAGE = git log -1 --pretty=%s +$GIT_COMMIT_DATE = git --no-pager log -1 --format="%ai" +$GIT_ORIGIN_URL = git config --get remote.origin.url +$GIT_COMMIT_FILE = "${PSScriptRoot}\..\lib\utils\metadata.dart" + +Clear-Content $GIT_COMMIT_FILE -Force + +Add-Content $GIT_COMMIT_FILE "const String gitBranchName = '$GIT_BRANCH_NAME';" +Add-Content $GIT_COMMIT_FILE "const String gitCommitHash = '$GIT_COMMIT_HASH';" +Add-Content $GIT_COMMIT_FILE "const String gitCommitMessage = '$GIT_COMMIT_MESSAGE';" +Add-Content $GIT_COMMIT_FILE "const String gitCommitDate = '$GIT_COMMIT_DATE';" +Add-Content $GIT_COMMIT_FILE "const String gitOriginUrl = '$GIT_ORIGIN_URL';" \ No newline at end of file diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index a484df4d..bf871b3a 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,18 +7,27 @@ #include "generated_plugin_registrant.h" #include -#include -#include +#include +#include +#include +#include +#include #include #include void RegisterPlugins(flutter::PluginRegistry* registry) { DesktopDropPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("DesktopDropPlugin")); - FileSelectorPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("FileSelectorPlugin")); - NetworkInfoPlusWindowsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("NetworkInfoPlusWindowsPlugin")); + FileSelectorWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FileSelectorWindows")); + LocalNotifierPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("LocalNotifierPlugin")); + ScreenRetrieverPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("ScreenRetrieverPlugin")); + SharePlusWindowsPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi")); + TrayManagerPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("TrayManagerPlugin")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); WindowManagerPluginRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 98d879bf..ed4b229a 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -5,11 +5,17 @@ list(APPEND FLUTTER_PLUGIN_LIST desktop_drop file_selector_windows - network_info_plus_windows + local_notifier + screen_retriever + share_plus + tray_manager url_launcher_windows window_manager ) +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -18,3 +24,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/windows/runner/Runner.rc b/windows/runner/Runner.rc index eb7a075c..19a2e0d8 100644 --- a/windows/runner/Runner.rc +++ b/windows/runner/Runner.rc @@ -63,13 +63,13 @@ IDI_APP_ICON ICON "resources\\app_icon.ico" #ifdef FLUTTER_BUILD_NUMBER #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER #else -#define VERSION_AS_NUMBER 0,0,4 +#define VERSION_AS_NUMBER 0,0,6 #endif #ifdef FLUTTER_BUILD_NAME #define VERSION_AS_STRING #FLUTTER_BUILD_NAME #else -#define VERSION_AS_STRING "0.0.5-alphanet" +#define VERSION_AS_STRING "0.0.6-alphanet" #endif VS_VERSION_INFO VERSIONINFO @@ -90,10 +90,10 @@ BEGIN BLOCK "040904e4" BEGIN VALUE "CompanyName", "network.zenon.syrius" "\0" - VALUE "FileDescription", "s y r i u s (v0.0.5-alphanet)" "\0" + VALUE "FileDescription", "s y r i u s (v0.0.6-alphanet)" "\0" VALUE "FileVersion", VERSION_AS_STRING "\0" VALUE "InternalName", "syrius" "\0" - VALUE "LegalCopyright", "(C) 2022 Zenon Network" "\0" + VALUE "LegalCopyright", "(C) 2023 Zenon Network" "\0" VALUE "OriginalFilename", "syrius.exe" "\0" VALUE "ProductName", "syrius" "\0" VALUE "ProductVersion", VERSION_AS_STRING "\0"