From 662a4bea7ac3d69a3354c89b3e5f6add044b0964 Mon Sep 17 00:00:00 2001 From: PuPha Date: Wed, 4 Sep 2024 11:18:19 +0700 Subject: [PATCH 01/12] remove bitmark-sdk in libauk-kotlin --- android/app/build.gradle | 2 +- pubspec.lock | 4 ++-- pubspec.yaml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index ec89f88bd..137d7b17c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -161,7 +161,7 @@ dependencies { implementation 'com.google.android.gms:play-services-auth-blockstore:16.2.0' implementation 'io.reactivex.rxjava2:rxjava:2.2.10' implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' - implementation('com.github.bitmark-inc:libauk-kotlin:0.6.3') { + implementation('com.github.bitmark-inc:libauk-kotlin:317c1e9c4d') { exclude group: 'com.google.protobuf' exclude module: 'jetified-protobuf-java' } diff --git a/pubspec.lock b/pubspec.lock index d93ab9875..42ac972fa 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1685,8 +1685,8 @@ packages: dependency: "direct main" description: path: "." - ref: "598a4627345f746d7e8fd62e7d0da4766ed29fb6" - resolved-ref: "598a4627345f746d7e8fd62e7d0da4766ed29fb6" + ref: ee2fc1780a6c854390edfd97da935596e1673680 + resolved-ref: ee2fc1780a6c854390edfd97da935596e1673680 url: "https://github.com/autonomy-system/libauk-dart.git" source: git version: "0.0.1" diff --git a/pubspec.yaml b/pubspec.yaml index 47a606ee1..ea8471c9b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -69,7 +69,7 @@ dependencies: libauk_dart: git: url: https://github.com/autonomy-system/libauk-dart.git - ref: 598a4627345f746d7e8fd62e7d0da4766ed29fb6 + ref: ee2fc1780a6c854390edfd97da935596e1673680 local_auth: ^2.2.0 logging: ^1.2.0 measured_size: ^1.0.0 From 5363a3a6bce972fa71162338f25c2b4b56575965 Mon Sep 17 00:00:00 2001 From: PuPha Date: Wed, 4 Sep 2024 11:27:57 +0700 Subject: [PATCH 02/12] Remove didKey JWT --- lib/gateway/iap_api.dart | 4 --- lib/gateway/iap_api.g.dart | 28 ---------------- lib/screen/cloud/cloud_android_page.dart | 11 +------ lib/service/auth_service.dart | 42 ++++-------------------- lib/util/dio_interceptors.dart | 4 +-- 5 files changed, 8 insertions(+), 81 deletions(-) diff --git a/lib/gateway/iap_api.dart b/lib/gateway/iap_api.dart index 38e141790..3109824a1 100644 --- a/lib/gateway/iap_api.dart +++ b/lib/gateway/iap_api.dart @@ -19,15 +19,11 @@ part 'iap_api.g.dart'; @RestApi(baseUrl: '') abstract class IAPApi { - static const authenticationPath = '/apis/v1/auth'; static const addressAuthenticationPath = '/apis/v2/addresses/auth'; static const registerPrimaryAddressPath = '/apis/v2/addresses/primary'; factory IAPApi(Dio dio, {String baseUrl}) = _IAPApi; - @POST(authenticationPath) - Future auth(@Body() Map body); - @POST(addressAuthenticationPath) Future authAddress(@Body() Map body); diff --git a/lib/gateway/iap_api.g.dart b/lib/gateway/iap_api.g.dart index 0805b952c..951cce869 100644 --- a/lib/gateway/iap_api.g.dart +++ b/lib/gateway/iap_api.g.dart @@ -18,34 +18,6 @@ class _IAPApi implements IAPApi { String? baseUrl; - @override - Future auth(Map body) async { - const _extra = {}; - final queryParameters = {}; - final _headers = {}; - final _data = {}; - _data.addAll(body); - final _result = - await _dio.fetch>(_setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/apis/v1/auth', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final value = JWT.fromJson(_result.data!); - return value; - } - @override Future authAddress(Map body) async { const _extra = {}; diff --git a/lib/screen/cloud/cloud_android_page.dart b/lib/screen/cloud/cloud_android_page.dart index c20e8658f..3bfc7a6fe 100644 --- a/lib/screen/cloud/cloud_android_page.dart +++ b/lib/screen/cloud/cloud_android_page.dart @@ -145,16 +145,7 @@ class _CloudAndroidPageState extends State Widget _buttonsGroup(BuildContext context) { if (isEncryptionAvailable == true) { - return Row( - children: [ - Expanded( - child: PrimaryButton( - text: 'go_back'.tr(), - onTap: () => _continue(context), - ), - ), - ], - ); + return const SizedBox(); } else { return Column( children: [ diff --git a/lib/service/auth_service.dart b/lib/service/auth_service.dart index cda6b51d8..0537ca1b9 100644 --- a/lib/service/auth_service.dart +++ b/lib/service/auth_service.dart @@ -17,7 +17,6 @@ import 'package:autonomy_flutter/service/configuration_service.dart'; import 'package:autonomy_flutter/util/log.dart'; import 'package:autonomy_flutter/util/notification_util.dart'; import 'package:autonomy_flutter/util/primary_address_channel.dart'; -import 'package:libauk_dart/libauk_dart.dart'; class AuthService { final IAPApi _authApi; @@ -87,46 +86,17 @@ class AuthService { return newJwt; } - Future getAuthToken( - {String? messageToSign, - String? receiptData, - bool forceRefresh = false, - bool shouldGetDidKeyInstead = false}) async { + Future getAuthToken({ + String? messageToSign, + String? receiptData, + bool forceRefresh = false, + }) async { if (!forceRefresh && _jwt != null && _jwt!.isValid()) { return _jwt!; } final primaryAddressAuthToken = await _getPrimaryAddressAuthToken(receiptData: receiptData); - final newJwt = primaryAddressAuthToken ?? - (shouldGetDidKeyInstead ? await getDidKeyAuthToken() : null); - return newJwt; - } - - Future _getAuthTokenByAccount(WalletStorage account) async { - final didKey = await account.getAccountDID(); - final message = DateTime.now().millisecondsSinceEpoch.toString(); - _addressService.getFeralfileAccountMessage( - address: didKey, - timestamp: DateTime.now().millisecondsSinceEpoch.toString(), - ); - final signature = await account.getAccountDIDSignature(message); - - Map payload = { - 'requester': didKey, - 'timestamp': message, - 'signature': signature, - }; - try { - var newJwt = await _authApi.auth(payload); - return newJwt; - } catch (e) { - rethrow; - } - } - - Future getDidKeyAuthToken() async { - final defaultAccount = await injector().getDefaultAccount(); - return _getAuthTokenByAccount(defaultAccount); + return primaryAddressAuthToken; } Future registerPrimaryAddress( diff --git a/lib/util/dio_interceptors.dart b/lib/util/dio_interceptors.dart index a0be18999..8d01d8890 100644 --- a/lib/util/dio_interceptors.dart +++ b/lib/util/dio_interceptors.dart @@ -145,13 +145,11 @@ class AutonomyAuthInterceptor extends Interceptor { Future onRequest( RequestOptions options, RequestInterceptorHandler handler) async { final shouldIgnoreAuthorizationPath = [ - IAPApi.authenticationPath, IAPApi.addressAuthenticationPath, IAPApi.registerPrimaryAddressPath, ]; if (!shouldIgnoreAuthorizationPath.contains(options.path)) { - final jwt = await injector() - .getAuthToken(shouldGetDidKeyInstead: true); + final jwt = await injector().getAuthToken(); if (jwt == null) { unawaited(Sentry.captureMessage('JWT is null')); } From ab38afb355c67fdfae09cef94534a3d5d9cb384b Mon Sep 17 00:00:00 2001 From: PuPha Date: Wed, 4 Sep 2024 11:46:39 +0700 Subject: [PATCH 03/12] Remove playlist suffle --- lib/model/play_control_model.dart | 49 ------ lib/model/play_list_model.dart | 23 +-- .../view_playlist/view_playlist.dart | 143 ++++++++---------- .../view_playlist/view_playlist_bloc.dart | 15 -- .../view_playlist/view_playlist_state.dart | 18 +-- 5 files changed, 75 insertions(+), 173 deletions(-) delete mode 100644 lib/model/play_control_model.dart diff --git a/lib/model/play_control_model.dart b/lib/model/play_control_model.dart deleted file mode 100644 index d05b39a74..000000000 --- a/lib/model/play_control_model.dart +++ /dev/null @@ -1,49 +0,0 @@ -class PlayControlModel { - int timer; - bool isShuffle; - - PlayControlModel({ - this.timer = 0, - this.isShuffle = false, - }); - - PlayControlModel onChangeTime() { - if (timer < 20) { - return copyWith(timer: timer == 0 ? 10 : timer + 5); - } else { - return copyWith(timer: 0); - } - } - - PlayControlModel copyWith({ - int? timer, - bool? isShuffle, - }) => - PlayControlModel( - timer: timer ?? this.timer, - isShuffle: isShuffle ?? this.isShuffle, - ); - - Map toJson() => { - 'timer': timer, - 'isShuffle': isShuffle, - }; - - factory PlayControlModel.fromJson(Map map) => - PlayControlModel( - timer: map['timer'] as int, - isShuffle: map['isShuffle'] as bool, - ); - - @override - bool operator ==(covariant PlayControlModel other) { - if (identical(this, other)) { - return true; - } - - return other.timer == timer && other.isShuffle == isShuffle; - } - - @override - int get hashCode => timer.hashCode ^ isShuffle.hashCode; -} diff --git a/lib/model/play_list_model.dart b/lib/model/play_list_model.dart index 42d6820e2..ca088da37 100644 --- a/lib/model/play_list_model.dart +++ b/lib/model/play_list_model.dart @@ -1,4 +1,3 @@ -import 'package:autonomy_flutter/model/play_control_model.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/foundation.dart'; @@ -7,14 +6,12 @@ class PlayListModel { String? name; String? thumbnailURL; List? tokenIDs; - PlayControlModel? playControlModel; PlayListModel({ this.id, this.name, this.thumbnailURL, this.tokenIDs, - this.playControlModel, }); PlayListModel copyWith({ @@ -22,20 +19,18 @@ class PlayListModel { String? name, String? thumbnailURL, List? tokenIDs, - PlayControlModel? playControlModel, }) => PlayListModel( id: id ?? this.id, name: name ?? this.name, thumbnailURL: thumbnailURL ?? this.thumbnailURL, tokenIDs: tokenIDs ?? this.tokenIDs, - playControlModel: playControlModel ?? this.playControlModel, ); @override String toString() => 'PlayListModel(id: $id, name: $name, thumbnailURL: $thumbnailURL, ' - 'tokenIDs: $tokenIDs, playControlModel: $playControlModel)'; + 'tokenIDs: $tokenIDs)'; @override bool operator ==(covariant PlayListModel other) { @@ -46,24 +41,18 @@ class PlayListModel { return other.id == id && other.name == name && other.thumbnailURL == thumbnailURL && - listEquals(other.tokenIDs, tokenIDs) && - other.playControlModel == playControlModel; + listEquals(other.tokenIDs, tokenIDs); } @override int get hashCode => - id.hashCode ^ - name.hashCode ^ - thumbnailURL.hashCode ^ - tokenIDs.hashCode ^ - playControlModel.hashCode; + id.hashCode ^ name.hashCode ^ thumbnailURL.hashCode ^ tokenIDs.hashCode; Map toJson() => { 'id': id, 'name': name, 'thumbnailURL': thumbnailURL, - 'tokenIDs': tokenIDs, - 'playControlModel': playControlModel?.toJson(), + 'tokenIDs': tokenIDs }; factory PlayListModel.fromJson(Map map) => PlayListModel( @@ -74,10 +63,6 @@ class PlayListModel { tokenIDs: map['tokenIDs'] != null ? List.from(map['tokenIDs'] as List) : null, - playControlModel: map['playControlModel'] != null - ? PlayControlModel.fromJson( - map['playControlModel'] as Map) - : null, ); String getName() => name ?? tr('untitled'); diff --git a/lib/screen/playlists/view_playlist/view_playlist.dart b/lib/screen/playlists/view_playlist/view_playlist.dart index cbb1954b9..3df86f1d1 100644 --- a/lib/screen/playlists/view_playlist/view_playlist.dart +++ b/lib/screen/playlists/view_playlist/view_playlist.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'package:autonomy_flutter/common/injector.dart'; -import 'package:autonomy_flutter/model/play_control_model.dart'; import 'package:autonomy_flutter/model/play_list_model.dart'; import 'package:autonomy_flutter/screen/app_router.dart'; import 'package:autonomy_flutter/screen/detail/artwork_detail_page.dart'; @@ -199,18 +198,6 @@ class _ViewPlaylistScreenState extends State { ); } - void _onShufferTap(PlayListModel? playList) { - final playControlModel = playList?.playControlModel ?? PlayControlModel(); - playControlModel.isShuffle = !playControlModel.isShuffle; - bloc.add(UpdatePlayControl(playControlModel: playControlModel)); - } - - void _onTimerTap(PlayListModel? playList) { - final playControlModel = playList?.playControlModel ?? PlayControlModel(); - bloc.add( - UpdatePlayControl(playControlModel: playControlModel.onChangeTime())); - } - Widget _appBarTitle(BuildContext context, PlayListModel playList) { final theme = Theme.of(context); return Row( @@ -283,74 +270,72 @@ class _ViewPlaylistScreenState extends State { ]; @override - Widget build(BuildContext context) { - return BlocConsumer( - bloc: bloc, - listener: (context, state) {}, - builder: (context, state) { - if (state.playListModel == null) { - return const SizedBox(); - } - - final PlayListModel playList = state.playListModel!; - return Scaffold( - backgroundColor: AppColor.primaryBlack, - appBar: getPlaylistAppBar( - context, - title: _appBarTitle(context, playList), - actions: _appBarAction(context, playList), - ), - body: BlocBuilder( - bloc: nftBloc, - builder: (context, nftState) => Column( - children: [ - BlocBuilder( - bloc: _canvasDeviceBloc, - builder: (context, canvasDeviceState) { - final displayKey = _getDisplayKey(playList); - final isPlaylistCasting = canvasDeviceState - .lastSelectedActiveDeviceForKey(displayKey ?? '') != - null; - if (isPlaylistCasting) { - return Padding( - padding: const EdgeInsets.all(15), - child: PlaylistControl( - displayKey: displayKey!, - ), - ); - } else { - return const SizedBox(); - } - }, - ), - Expanded( - child: NftCollectionGrid( - state: nftState.state, - tokens: _setupPlayList( - tokens: widget.payload.collectionType == - CollectionType.featured - ? _featureTokens - : nftState.tokens.items, - selectedTokens: playList.tokenIDs, - ), - customGalleryViewBuilder: (context, tokens) => - _assetsWidget( - context, - tokens, - accountIdentities: accountIdentities, - playlist: playList, - onShuffleTap: () => _onShufferTap(playList), - onTimerTap: () => _onTimerTap(playList), + Widget build(BuildContext context) => + BlocConsumer( + bloc: bloc, + listener: (context, state) {}, + builder: (context, state) { + if (state.playListModel == null) { + return const SizedBox(); + } + + final PlayListModel playList = state.playListModel!; + return Scaffold( + backgroundColor: AppColor.primaryBlack, + appBar: getPlaylistAppBar( + context, + title: _appBarTitle(context, playList), + actions: _appBarAction(context, playList), + ), + body: BlocBuilder( + bloc: nftBloc, + builder: (context, nftState) => Column( + children: [ + BlocBuilder( + bloc: _canvasDeviceBloc, + builder: (context, canvasDeviceState) { + final displayKey = _getDisplayKey(playList); + final isPlaylistCasting = + canvasDeviceState.lastSelectedActiveDeviceForKey( + displayKey ?? '') != + null; + if (isPlaylistCasting) { + return Padding( + padding: const EdgeInsets.all(15), + child: PlaylistControl( + displayKey: displayKey!, + ), + ); + } else { + return const SizedBox(); + } + }, + ), + Expanded( + child: NftCollectionGrid( + state: nftState.state, + tokens: _setupPlayList( + tokens: widget.payload.collectionType == + CollectionType.featured + ? _featureTokens + : nftState.tokens.items, + selectedTokens: playList.tokenIDs, + ), + customGalleryViewBuilder: (context, tokens) => + _assetsWidget( + context, + tokens, + accountIdentities: accountIdentities, + playlist: playList, + ), ), ), - ), - ], + ], + ), ), - ), - ); - }, - ); - } + ); + }, + ); String? _getDisplayKey(PlayListModel playList) => playList.displayKey; @@ -375,8 +360,6 @@ class _ViewPlaylistScreenState extends State { List tokens, { required List accountIdentities, required PlayListModel playlist, - Function()? onShuffleTap, - Function()? onTimerTap, }) { int cellPerRow = ResponsiveLayout.isMobile ? cellPerRowPhone : cellPerRowTablet; diff --git a/lib/screen/playlists/view_playlist/view_playlist_bloc.dart b/lib/screen/playlists/view_playlist/view_playlist_bloc.dart index 329c862f0..663a702a0 100644 --- a/lib/screen/playlists/view_playlist/view_playlist_bloc.dart +++ b/lib/screen/playlists/view_playlist/view_playlist_bloc.dart @@ -39,20 +39,5 @@ class ViewPlaylistBloc extends AuBloc { } emit(state.copyWith(isRename: false)); }); - - on((event, emit) async { - final playListModel = state.playListModel; - playListModel?.playControlModel = event.playControlModel; - - final playlists = await _playlistService.getPlayList(); - final index = - playlists.indexWhere((element) => element.id == playListModel?.id); - if (index != -1 && playListModel != null) { - playlists[index] = playListModel; - await _playlistService.setPlayList(playlists, override: true); - unawaited(injector.get().backup()); - } - emit(state.copyWith(playListModel: playListModel)); - }); } } diff --git a/lib/screen/playlists/view_playlist/view_playlist_state.dart b/lib/screen/playlists/view_playlist/view_playlist_state.dart index e91802d65..2bb35ccef 100644 --- a/lib/screen/playlists/view_playlist/view_playlist_state.dart +++ b/lib/screen/playlists/view_playlist/view_playlist_state.dart @@ -1,26 +1,23 @@ -import 'package:autonomy_flutter/model/play_control_model.dart'; import 'package:autonomy_flutter/model/play_list_model.dart'; abstract class ViewPlaylistEvent {} class GetPlayList extends ViewPlaylistEvent { final PlayListModel? playListModel; + GetPlayList({this.playListModel}); } class ChangeRename extends ViewPlaylistEvent { final bool value; + ChangeRename({required this.value}); } class SavePlaylist extends ViewPlaylistEvent { final String? name; - SavePlaylist({this.name}); -} -class UpdatePlayControl extends ViewPlaylistEvent { - final PlayControlModel? playControlModel; - UpdatePlayControl({this.playControlModel}); + SavePlaylist({this.name}); } class ViewPlaylistState { @@ -35,8 +32,9 @@ class ViewPlaylistState { ViewPlaylistState copyWith({ PlayListModel? playListModel, bool? isRename, - }) => ViewPlaylistState( - playListModel: playListModel ?? this.playListModel, - isRename: isRename ?? this.isRename, - ); + }) => + ViewPlaylistState( + playListModel: playListModel ?? this.playListModel, + isRename: isRename ?? this.isRename, + ); } From 02e2bbcb54d67c539f89d7e06c0d0fb281f0ac48 Mon Sep 17 00:00:00 2001 From: PuPha Date: Wed, 4 Sep 2024 14:22:12 +0700 Subject: [PATCH 04/12] remove unused model --- lib/gateway/branch_api.dart | 3 --- lib/gateway/branch_api.g.dart | 31 +----------------------- lib/gateway/iap_api.dart | 6 ----- lib/gateway/iap_api.g.dart | 31 ------------------------ lib/gateway/pubdoc_api.dart | 15 +++++------- lib/gateway/pubdoc_api.g.dart | 26 -------------------- lib/gateway/tzkt_api.dart | 11 --------- lib/gateway/tzkt_api.g.dart | 45 ----------------------------------- lib/model/airdrop_data.dart | 13 ---------- pubspec.yaml | 1 + 10 files changed, 8 insertions(+), 174 deletions(-) delete mode 100644 lib/model/airdrop_data.dart diff --git a/lib/gateway/branch_api.dart b/lib/gateway/branch_api.dart index 5ad9cd969..e7d480e9c 100644 --- a/lib/gateway/branch_api.dart +++ b/lib/gateway/branch_api.dart @@ -19,7 +19,4 @@ abstract class BranchApi { @Query("branch_key") String? key, @Query("url") String? url, ); - - @POST("/v1/url") - Future getUrl(@Body() Map body); } diff --git a/lib/gateway/branch_api.g.dart b/lib/gateway/branch_api.g.dart index 1fbcc6897..5dee0e0d7 100644 --- a/lib/gateway/branch_api.g.dart +++ b/lib/gateway/branch_api.g.dart @@ -31,8 +31,7 @@ class _BranchApi implements BranchApi { r'url': url, }; queryParameters.removeWhere((k, v) => v == null); - final _headers = {r'content-length': 0}; - _headers.removeWhere((k, v) => v == null); + final _headers = {}; final Map? _data = null; final _result = await _dio.fetch(_setStreamType(Options( method: 'GET', @@ -54,34 +53,6 @@ class _BranchApi implements BranchApi { return value; } - @override - Future getUrl(Map body) async { - const _extra = {}; - final queryParameters = {}; - final _headers = {r'content-length': 0}; - _headers.removeWhere((k, v) => v == null); - final _data = {}; - _data.addAll(body); - final _result = await _dio.fetch(_setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/v1/url', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final value = _result.data; - return value; - } - RequestOptions _setStreamType(RequestOptions requestOptions) { if (T != dynamic && !(requestOptions.responseType == ResponseType.bytes || diff --git a/lib/gateway/iap_api.dart b/lib/gateway/iap_api.dart index 3109824a1..a5f398c78 100644 --- a/lib/gateway/iap_api.dart +++ b/lib/gateway/iap_api.dart @@ -39,12 +39,6 @@ abstract class IAPApi { @Part(name: 'data') File data, ); - @GET('/apis/v1/premium/profile-data/versions') - Future getProfileVersions( - @Header('requester') String requester, - @Query('filename') String filename, - ); - @GET('/apis/v1/premium/profile-data') Future getProfileData( @Header('requester') String requester, diff --git a/lib/gateway/iap_api.g.dart b/lib/gateway/iap_api.g.dart index 951cce869..2a90946b6 100644 --- a/lib/gateway/iap_api.g.dart +++ b/lib/gateway/iap_api.g.dart @@ -119,37 +119,6 @@ class _IAPApi implements IAPApi { return value; } - @override - Future getProfileVersions( - String requester, - String filename, - ) async { - const _extra = {}; - final queryParameters = {r'filename': filename}; - final _headers = {r'requester': requester}; - _headers.removeWhere((k, v) => v == null); - final Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/apis/v1/premium/profile-data/versions', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final value = BackupVersions.fromJson(_result.data!); - return value; - } - @override Future getProfileData( String requester, diff --git a/lib/gateway/pubdoc_api.dart b/lib/gateway/pubdoc_api.dart index 664c3568d..8a0e37b90 100644 --- a/lib/gateway/pubdoc_api.dart +++ b/lib/gateway/pubdoc_api.dart @@ -33,9 +33,6 @@ abstract class PubdocAPI { @GET('/configs/postcard/postcard_configs.json') Future getConfigs(); - - @GET('/configs/user_test.json') - Future getUserTestConfigs(); } extension PubdocAPIHelpers on PubdocAPI { @@ -46,17 +43,17 @@ extension PubdocAPIHelpers on PubdocAPI { Future> getDemoAccountFromGithub() async { final value = await getDemoAccount(); - final list = (jsonDecode(value) as List?)?.map((element) { - return PlayListModel.fromJson(element); - }).toList(); + final list = (jsonDecode(value) as List?) + ?.map((element) => PlayListModel.fromJson(element)) + .toList(); return list ?? []; } Future> getSuggestedArtistsFromGithub() async { final value = await getSuggestedArtists(); - final list = (jsonDecode(value) as List?)?.map((element) { - return SuggestedArtist.fromJson(element); - }).toList(); + final list = (jsonDecode(value) as List?) + ?.map((element) => SuggestedArtist.fromJson(element)) + .toList(); return list ?? []; } } diff --git a/lib/gateway/pubdoc_api.g.dart b/lib/gateway/pubdoc_api.g.dart index a05ff2887..145a3132c 100644 --- a/lib/gateway/pubdoc_api.g.dart +++ b/lib/gateway/pubdoc_api.g.dart @@ -148,32 +148,6 @@ class _PubdocAPI implements PubdocAPI { return value; } - @override - Future getUserTestConfigs() async { - const _extra = {}; - final queryParameters = {}; - final _headers = {}; - final Map? _data = null; - final _result = await _dio.fetch(_setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/configs/user_test.json', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final value = _result.data!; - return value; - } - RequestOptions _setStreamType(RequestOptions requestOptions) { if (T != dynamic && !(requestOptions.responseType == ResponseType.bytes || diff --git a/lib/gateway/tzkt_api.dart b/lib/gateway/tzkt_api.dart index efec65806..97102a033 100644 --- a/lib/gateway/tzkt_api.dart +++ b/lib/gateway/tzkt_api.dart @@ -15,17 +15,6 @@ part 'tzkt_api.g.dart'; abstract class TZKTApi { factory TZKTApi(Dio dio, {String baseUrl}) = _TZKTApi; - @GET("/v1/accounts/{address}/operations") - Future> getOperations( - @Path("address") String address, { - @Query("type") String type = "transaction", - @Query("quote") String quote = "usd", - @Query("sort") int sort = 1, - @Query("limit") int limit = 100, - @Query("lastId") int? lastId, - @Query("initiator.ne") String? initiator, - }); - @GET("/v1/tokens/transfers") Future> getTokenTransfer({ @Query("anyof.from.to") String? anyOf, diff --git a/lib/gateway/tzkt_api.g.dart b/lib/gateway/tzkt_api.g.dart index 76aacf169..a5fafe230 100644 --- a/lib/gateway/tzkt_api.g.dart +++ b/lib/gateway/tzkt_api.g.dart @@ -18,51 +18,6 @@ class _TZKTApi implements TZKTApi { String? baseUrl; - @override - Future> getOperations( - String address, { - String type = "transaction", - String quote = "usd", - int sort = 1, - int limit = 100, - int? lastId, - String? initiator, - }) async { - const _extra = {}; - final queryParameters = { - r'type': type, - r'quote': quote, - r'sort': sort, - r'limit': limit, - r'lastId': lastId, - r'initiator.ne': initiator, - }; - queryParameters.removeWhere((k, v) => v == null); - final _headers = {}; - final Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType>(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/v1/accounts/${address}/operations', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - var value = _result.data! - .map((dynamic i) => TZKTOperation.fromJson(i as Map)) - .toList(); - return value; - } - @override Future> getTokenTransfer({ String? anyOf, diff --git a/lib/model/airdrop_data.dart b/lib/model/airdrop_data.dart deleted file mode 100644 index a50d26ce3..000000000 --- a/lib/model/airdrop_data.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:autonomy_flutter/model/otp.dart'; - -class AirdropQrData { - final String? exhibitionId; - final String? seriesId; - final Otp? otp; - - AirdropQrData({ - this.exhibitionId, - this.seriesId, - this.otp, - }); -} diff --git a/pubspec.yaml b/pubspec.yaml index ea8471c9b..c729c3099 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -171,6 +171,7 @@ dependency_overrides: intl: 0.18.0 archive: ^3.6.1 package_info_plus: ^6.0.0 + frontend_server_client: ^4.0.0 dev_dependencies: flutter_lints: null From 7cba21c7cf49a6bee8d8099a03e03d2fee211586 Mon Sep 17 00:00:00 2001 From: PuPha Date: Wed, 4 Sep 2024 14:33:49 +0700 Subject: [PATCH 05/12] Update Mock Test --- .../dao/mock_asset_token_dao.mocks.dart | 9 + .../gateway/mock_iap_api.mocks.dart | 134 +++---- .../service/mock_account_service.mocks.dart | 4 +- .../mock_configuration_service.mocks.dart | 41 +-- .../mock_feral_file_service.mocks.dart | 339 +++++++++++++++--- .../mock_navigation_service.mocks.dart | 56 ++- 6 files changed, 400 insertions(+), 183 deletions(-) diff --git a/test/generate_mock/dao/mock_asset_token_dao.mocks.dart b/test/generate_mock/dao/mock_asset_token_dao.mocks.dart index d80cee19d..a0f090096 100644 --- a/test/generate_mock/dao/mock_asset_token_dao.mocks.dart +++ b/test/generate_mock/dao/mock_asset_token_dao.mocks.dart @@ -268,4 +268,13 @@ class MockAssetTokenDao extends _i1.Mock implements _i4.AssetTokenDao { ), returnValue: _i3.Future>.value([]), ) as _i3.Future>); + @override + _i3.Future> countAssetTokensByOwner(List? owners) => + (super.noSuchMethod( + Invocation.method( + #countAssetTokensByOwner, + [owners], + ), + returnValue: _i3.Future>.value({}), + ) as _i3.Future>); } diff --git a/test/generate_mock/gateway/mock_iap_api.mocks.dart b/test/generate_mock/gateway/mock_iap_api.mocks.dart index 101cfbc51..5c5e178e9 100644 --- a/test/generate_mock/gateway/mock_iap_api.mocks.dart +++ b/test/generate_mock/gateway/mock_iap_api.mocks.dart @@ -3,16 +3,15 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; -import 'dart:io' as _i7; +import 'dart:async' as _i5; +import 'dart:io' as _i6; -import 'package:autonomy_flutter/gateway/iap_api.dart' as _i5; -import 'package:autonomy_flutter/model/announcement/announcement.dart' as _i8; +import 'package:autonomy_flutter/gateway/iap_api.dart' as _i4; +import 'package:autonomy_flutter/model/announcement/announcement.dart' as _i7; import 'package:autonomy_flutter/model/announcement/announcement_request.dart' - as _i9; -import 'package:autonomy_flutter/model/backup_versions.dart' as _i3; + as _i8; import 'package:autonomy_flutter/model/jwt.dart' as _i2; -import 'package:autonomy_flutter/model/ok_response.dart' as _i4; +import 'package:autonomy_flutter/model/ok_response.dart' as _i3; import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: type=lint @@ -38,20 +37,9 @@ class _FakeJWT_0 extends _i1.SmartFake implements _i2.JWT { ); } -class _FakeBackupVersions_1 extends _i1.SmartFake - implements _i3.BackupVersions { - _FakeBackupVersions_1( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeOnesignalIdentityHash_2 extends _i1.SmartFake +class _FakeOnesignalIdentityHash_1 extends _i1.SmartFake implements _i2.OnesignalIdentityHash { - _FakeOnesignalIdentityHash_2( + _FakeOnesignalIdentityHash_1( Object parent, Invocation parentInvocation, ) : super( @@ -60,8 +48,8 @@ class _FakeOnesignalIdentityHash_2 extends _i1.SmartFake ); } -class _FakeOkResponse_3 extends _i1.SmartFake implements _i4.OkResponse { - _FakeOkResponse_3( +class _FakeOkResponse_2 extends _i1.SmartFake implements _i3.OkResponse { + _FakeOkResponse_2( Object parent, Invocation parentInvocation, ) : super( @@ -73,56 +61,42 @@ class _FakeOkResponse_3 extends _i1.SmartFake implements _i4.OkResponse { /// A class which mocks [IAPApi]. /// /// See the documentation for Mockito's code generation for more information. -class MockIAPApi extends _i1.Mock implements _i5.IAPApi { +class MockIAPApi extends _i1.Mock implements _i4.IAPApi { MockIAPApi() { _i1.throwOnMissingStub(this); } @override - _i6.Future<_i2.JWT> auth(Map? body) => (super.noSuchMethod( - Invocation.method( - #auth, - [body], - ), - returnValue: _i6.Future<_i2.JWT>.value(_FakeJWT_0( - this, - Invocation.method( - #auth, - [body], - ), - )), - ) as _i6.Future<_i2.JWT>); - @override - _i6.Future<_i2.JWT> authAddress(Map? body) => + _i5.Future<_i2.JWT> authAddress(Map? body) => (super.noSuchMethod( Invocation.method( #authAddress, [body], ), - returnValue: _i6.Future<_i2.JWT>.value(_FakeJWT_0( + returnValue: _i5.Future<_i2.JWT>.value(_FakeJWT_0( this, Invocation.method( #authAddress, [body], ), )), - ) as _i6.Future<_i2.JWT>); + ) as _i5.Future<_i2.JWT>); @override - _i6.Future registerPrimaryAddress(Map? body) => + _i5.Future registerPrimaryAddress(Map? body) => (super.noSuchMethod( Invocation.method( #registerPrimaryAddress, [body], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future uploadProfile( + _i5.Future uploadProfile( String? requester, String? filename, String? appVersion, - _i7.File? data, + _i6.File? data, ) => (super.noSuchMethod( Invocation.method( @@ -134,34 +108,10 @@ class MockIAPApi extends _i1.Mock implements _i5.IAPApi { data, ], ), - returnValue: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future<_i3.BackupVersions> getProfileVersions( - String? requester, - String? filename, - ) => - (super.noSuchMethod( - Invocation.method( - #getProfileVersions, - [ - requester, - filename, - ], - ), - returnValue: _i6.Future<_i3.BackupVersions>.value(_FakeBackupVersions_1( - this, - Invocation.method( - #getProfileVersions, - [ - requester, - filename, - ], - ), - )), - ) as _i6.Future<_i3.BackupVersions>); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future getProfileData( + _i5.Future getProfileData( String? requester, String? filename, String? version, @@ -175,65 +125,65 @@ class MockIAPApi extends _i1.Mock implements _i5.IAPApi { version, ], ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future deleteAllProfiles(String? requester) => + _i5.Future deleteAllProfiles(String? requester) => (super.noSuchMethod( Invocation.method( #deleteAllProfiles, [requester], ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future deleteUserData() => (super.noSuchMethod( + _i5.Future deleteUserData() => (super.noSuchMethod( Invocation.method( #deleteUserData, [], ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future<_i2.OnesignalIdentityHash> generateIdentityHash( + _i5.Future<_i2.OnesignalIdentityHash> generateIdentityHash( Map? body) => (super.noSuchMethod( Invocation.method( #generateIdentityHash, [body], ), - returnValue: _i6.Future<_i2.OnesignalIdentityHash>.value( - _FakeOnesignalIdentityHash_2( + returnValue: _i5.Future<_i2.OnesignalIdentityHash>.value( + _FakeOnesignalIdentityHash_1( this, Invocation.method( #generateIdentityHash, [body], ), )), - ) as _i6.Future<_i2.OnesignalIdentityHash>); + ) as _i5.Future<_i2.OnesignalIdentityHash>); @override - _i6.Future> getAnnouncements( - _i9.AnnouncementRequest? body) => + _i5.Future> getAnnouncements( + _i8.AnnouncementRequest? body) => (super.noSuchMethod( Invocation.method( #getAnnouncements, [body], ), returnValue: - _i6.Future>.value(<_i8.Announcement>[]), - ) as _i6.Future>); + _i5.Future>.value(<_i7.Announcement>[]), + ) as _i5.Future>); @override - _i6.Future<_i4.OkResponse> redeemGiftCode(String? id) => (super.noSuchMethod( + _i5.Future<_i3.OkResponse> redeemGiftCode(String? id) => (super.noSuchMethod( Invocation.method( #redeemGiftCode, [id], ), - returnValue: _i6.Future<_i4.OkResponse>.value(_FakeOkResponse_3( + returnValue: _i5.Future<_i3.OkResponse>.value(_FakeOkResponse_2( this, Invocation.method( #redeemGiftCode, [id], ), )), - ) as _i6.Future<_i4.OkResponse>); + ) as _i5.Future<_i3.OkResponse>); } diff --git a/test/generate_mock/service/mock_account_service.mocks.dart b/test/generate_mock/service/mock_account_service.mocks.dart index f0e6a5e7c..01ba26895 100644 --- a/test/generate_mock/service/mock_account_service.mocks.dart +++ b/test/generate_mock/service/mock_account_service.mocks.dart @@ -479,12 +479,10 @@ class MockAccountService extends _i1.Mock implements _i6.AccountService { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - _i7.Future restoreIfNeeded({bool? isCreateNew = true}) => - (super.noSuchMethod( + _i7.Future restoreIfNeeded() => (super.noSuchMethod( Invocation.method( #restoreIfNeeded, [], - {#isCreateNew: isCreateNew}, ), returnValue: _i7.Future.value(), returnValueForMissingStub: _i7.Future.value(), diff --git a/test/generate_mock/service/mock_configuration_service.mocks.dart b/test/generate_mock/service/mock_configuration_service.mocks.dart index 3a7a6141d..46e9004f9 100644 --- a/test/generate_mock/service/mock_configuration_service.mocks.dart +++ b/test/generate_mock/service/mock_configuration_service.mocks.dart @@ -73,22 +73,6 @@ class MockConfigurationService extends _i1.Mock ), ) as _i2.ValueNotifier); @override - _i2.ValueNotifier get showProTip => (super.noSuchMethod( - Invocation.getter(#showProTip), - returnValue: _FakeValueNotifier_0( - this, - Invocation.getter(#showProTip), - ), - ) as _i2.ValueNotifier); - @override - _i2.ValueNotifier get showTvAppTip => (super.noSuchMethod( - Invocation.getter(#showTvAppTip), - returnValue: _FakeValueNotifier_0( - this, - Invocation.getter(#showTvAppTip), - ), - ) as _i2.ValueNotifier); - @override _i2.ValueNotifier get showCreatePlaylistTip => (super.noSuchMethod( Invocation.getter(#showCreatePlaylistTip), returnValue: _FakeValueNotifier_0( @@ -97,21 +81,22 @@ class MockConfigurationService extends _i1.Mock ), ) as _i2.ValueNotifier); @override - _i2.ValueNotifier get showLinkOrImportTip => (super.noSuchMethod( - Invocation.getter(#showLinkOrImportTip), - returnValue: _FakeValueNotifier_0( - this, - Invocation.getter(#showLinkOrImportTip), + bool isDoneNewOnboarding() => (super.noSuchMethod( + Invocation.method( + #isDoneNewOnboarding, + [], ), - ) as _i2.ValueNotifier); + returnValue: false, + ) as bool); @override - _i2.ValueNotifier get showBackupSettingTip => (super.noSuchMethod( - Invocation.getter(#showBackupSettingTip), - returnValue: _FakeValueNotifier_0( - this, - Invocation.getter(#showBackupSettingTip), + _i5.Future setDoneNewOnboarding(bool? value) => (super.noSuchMethod( + Invocation.method( + #setDoneNewOnboarding, + [value], ), - ) as _i2.ValueNotifier); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); @override _i5.Future setLastPullAnnouncementTime(int? lastPullTime) => (super.noSuchMethod( diff --git a/test/generate_mock/service/mock_feral_file_service.mocks.dart b/test/generate_mock/service/mock_feral_file_service.mocks.dart index ebdb952cb..b034b4ec6 100644 --- a/test/generate_mock/service/mock_feral_file_service.mocks.dart +++ b/test/generate_mock/service/mock_feral_file_service.mocks.dart @@ -3,14 +3,18 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; +import 'dart:async' as _i10; +import 'package:autonomy_flutter/model/dailies.dart' as _i12; +import 'package:autonomy_flutter/model/explore_statistics_data.dart' as _i8; import 'package:autonomy_flutter/model/ff_account.dart' as _i3; import 'package:autonomy_flutter/model/ff_artwork.dart' as _i6; import 'package:autonomy_flutter/model/ff_exhibition.dart' as _i4; import 'package:autonomy_flutter/model/ff_list_response.dart' as _i5; import 'package:autonomy_flutter/model/ff_series.dart' as _i2; -import 'package:autonomy_flutter/service/feralfile_service.dart' as _i7; +import 'package:autonomy_flutter/model/ff_user.dart' as _i7; +import 'package:autonomy_flutter/screen/feralfile_home/filter_bar.dart' as _i11; +import 'package:autonomy_flutter/service/feralfile_service.dart' as _i9; import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: type=lint @@ -78,16 +82,37 @@ class _FakeArtwork_4 extends _i1.SmartFake implements _i6.Artwork { ); } +class _FakeFFUserDetails_5 extends _i1.SmartFake implements _i7.FFUserDetails { + _FakeFFUserDetails_5( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeExploreStatisticsData_6 extends _i1.SmartFake + implements _i8.ExploreStatisticsData { + _FakeExploreStatisticsData_6( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [FeralFileService]. /// /// See the documentation for Mockito's code generation for more information. -class MockFeralFileService extends _i1.Mock implements _i7.FeralFileService { +class MockFeralFileService extends _i1.Mock implements _i9.FeralFileService { MockFeralFileService() { _i1.throwOnMissingStub(this); } @override - _i8.Future<_i2.FFSeries> getSeries( + _i10.Future<_i2.FFSeries> getSeries( String? id, { String? exhibitionID, bool? includeFirstArtwork = false, @@ -101,7 +126,7 @@ class MockFeralFileService extends _i1.Mock implements _i7.FeralFileService { #includeFirstArtwork: includeFirstArtwork, }, ), - returnValue: _i8.Future<_i2.FFSeries>.value(_FakeFFSeries_0( + returnValue: _i10.Future<_i2.FFSeries>.value(_FakeFFSeries_0( this, Invocation.method( #getSeries, @@ -112,9 +137,9 @@ class MockFeralFileService extends _i1.Mock implements _i7.FeralFileService { }, ), )), - ) as _i8.Future<_i2.FFSeries>); + ) as _i10.Future<_i2.FFSeries>); @override - _i8.Future> getListSeries( + _i10.Future> getListSeries( String? exhibitionId, { bool? includeFirstArtwork = false, }) => @@ -124,25 +149,25 @@ class MockFeralFileService extends _i1.Mock implements _i7.FeralFileService { [exhibitionId], {#includeFirstArtwork: includeFirstArtwork}, ), - returnValue: _i8.Future>.value(<_i2.FFSeries>[]), - ) as _i8.Future>); + returnValue: _i10.Future>.value(<_i2.FFSeries>[]), + ) as _i10.Future>); @override - _i8.Future<_i4.Exhibition?> getExhibitionFromTokenID(String? artworkID) => + _i10.Future<_i4.Exhibition?> getExhibitionFromTokenID(String? artworkID) => (super.noSuchMethod( Invocation.method( #getExhibitionFromTokenID, [artworkID], ), - returnValue: _i8.Future<_i4.Exhibition?>.value(), - ) as _i8.Future<_i4.Exhibition?>); + returnValue: _i10.Future<_i4.Exhibition?>.value(), + ) as _i10.Future<_i4.Exhibition?>); @override - _i8.Future<_i3.FeralFileResaleInfo> getResaleInfo(String? exhibitionID) => + _i10.Future<_i3.FeralFileResaleInfo> getResaleInfo(String? exhibitionID) => (super.noSuchMethod( Invocation.method( #getResaleInfo, [exhibitionID], ), - returnValue: _i8.Future<_i3.FeralFileResaleInfo>.value( + returnValue: _i10.Future<_i3.FeralFileResaleInfo>.value( _FakeFeralFileResaleInfo_1( this, Invocation.method( @@ -150,18 +175,18 @@ class MockFeralFileService extends _i1.Mock implements _i7.FeralFileService { [exhibitionID], ), )), - ) as _i8.Future<_i3.FeralFileResaleInfo>); + ) as _i10.Future<_i3.FeralFileResaleInfo>); @override - _i8.Future getPartnerFullName(String? exhibitionId) => + _i10.Future getPartnerFullName(String? exhibitionId) => (super.noSuchMethod( Invocation.method( #getPartnerFullName, [exhibitionId], ), - returnValue: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i10.Future.value(), + ) as _i10.Future); @override - _i8.Future<_i4.Exhibition> getExhibition( + _i10.Future<_i4.Exhibition> getExhibition( String? id, { bool? includeFirstArtwork = false, }) => @@ -171,7 +196,7 @@ class MockFeralFileService extends _i1.Mock implements _i7.FeralFileService { [id], {#includeFirstArtwork: includeFirstArtwork}, ), - returnValue: _i8.Future<_i4.Exhibition>.value(_FakeExhibition_2( + returnValue: _i10.Future<_i4.Exhibition>.value(_FakeExhibition_2( this, Invocation.method( #getExhibition, @@ -179,13 +204,16 @@ class MockFeralFileService extends _i1.Mock implements _i7.FeralFileService { {#includeFirstArtwork: includeFirstArtwork}, ), )), - ) as _i8.Future<_i4.Exhibition>); + ) as _i10.Future<_i4.Exhibition>); @override - _i8.Future> getAllExhibitions({ + _i10.Future> getAllExhibitions({ String? sortBy = r'openAt', String? sortOrder = r'DESC', int? limit = 8, int? offset = 0, + String? keywork = r'', + List? relatedAccountIDs = const [], + Map<_i11.FilterType, _i11.FilterValue>? filters = const {}, }) => (super.noSuchMethod( Invocation.method( @@ -196,65 +224,70 @@ class MockFeralFileService extends _i1.Mock implements _i7.FeralFileService { #sortOrder: sortOrder, #limit: limit, #offset: offset, + #keywork: keywork, + #relatedAccountIDs: relatedAccountIDs, + #filters: filters, }, ), - returnValue: _i8.Future>.value(<_i4.Exhibition>[]), - ) as _i8.Future>); + returnValue: + _i10.Future>.value(<_i4.Exhibition>[]), + ) as _i10.Future>); @override - _i8.Future<_i4.Exhibition> getSourceExhibition() => (super.noSuchMethod( + _i10.Future<_i4.Exhibition> getSourceExhibition() => (super.noSuchMethod( Invocation.method( #getSourceExhibition, [], ), - returnValue: _i8.Future<_i4.Exhibition>.value(_FakeExhibition_2( + returnValue: _i10.Future<_i4.Exhibition>.value(_FakeExhibition_2( this, Invocation.method( #getSourceExhibition, [], ), )), - ) as _i8.Future<_i4.Exhibition>); + ) as _i10.Future<_i4.Exhibition>); @override - _i8.Future<_i4.Exhibition?> getUpcomingExhibition() => (super.noSuchMethod( + _i10.Future<_i4.Exhibition?> getUpcomingExhibition() => (super.noSuchMethod( Invocation.method( #getUpcomingExhibition, [], ), - returnValue: _i8.Future<_i4.Exhibition?>.value(), - ) as _i8.Future<_i4.Exhibition?>); + returnValue: _i10.Future<_i4.Exhibition?>.value(), + ) as _i10.Future<_i4.Exhibition?>); @override - _i8.Future<_i4.Exhibition> getFeaturedExhibition() => (super.noSuchMethod( + _i10.Future<_i4.Exhibition> getFeaturedExhibition() => (super.noSuchMethod( Invocation.method( #getFeaturedExhibition, [], ), - returnValue: _i8.Future<_i4.Exhibition>.value(_FakeExhibition_2( + returnValue: _i10.Future<_i4.Exhibition>.value(_FakeExhibition_2( this, Invocation.method( #getFeaturedExhibition, [], ), )), - ) as _i8.Future<_i4.Exhibition>); + ) as _i10.Future<_i4.Exhibition>); @override - _i8.Future> getOngoingExhibitions() => + _i10.Future> getOngoingExhibitions() => (super.noSuchMethod( Invocation.method( #getOngoingExhibitions, [], ), - returnValue: _i8.Future>.value(<_i4.Exhibition>[]), - ) as _i8.Future>); + returnValue: + _i10.Future>.value(<_i4.Exhibition>[]), + ) as _i10.Future>); @override - _i8.Future> getFeaturedArtworks() => (super.noSuchMethod( + _i10.Future> getFeaturedArtworks() => (super.noSuchMethod( Invocation.method( #getFeaturedArtworks, [], ), - returnValue: _i8.Future>.value(<_i6.Artwork>[]), - ) as _i8.Future>); + returnValue: _i10.Future>.value(<_i6.Artwork>[]), + ) as _i10.Future>); @override - _i8.Future<_i5.FeralFileListResponse<_i6.Artwork>> getSeriesArtworks( + _i10.Future<_i5.FeralFileListResponse<_i6.Artwork>> getSeriesArtworks( String? seriesId, String? exhibitionID, { bool? withSeries = false, @@ -274,7 +307,7 @@ class MockFeralFileService extends _i1.Mock implements _i7.FeralFileService { #limit: limit, }, ), - returnValue: _i8.Future<_i5.FeralFileListResponse<_i6.Artwork>>.value( + returnValue: _i10.Future<_i5.FeralFileListResponse<_i6.Artwork>>.value( _FakeFeralFileListResponse_3<_i6.Artwork>( this, Invocation.method( @@ -290,28 +323,238 @@ class MockFeralFileService extends _i1.Mock implements _i7.FeralFileService { }, ), )), - ) as _i8.Future<_i5.FeralFileListResponse<_i6.Artwork>>); + ) as _i10.Future<_i5.FeralFileListResponse<_i6.Artwork>>); @override - _i8.Future<_i6.Artwork?> getFirstViewableArtwork(String? seriesId) => + _i10.Future<_i6.Artwork?> getFirstViewableArtwork(String? seriesId) => (super.noSuchMethod( Invocation.method( #getFirstViewableArtwork, [seriesId], ), - returnValue: _i8.Future<_i6.Artwork?>.value(), - ) as _i8.Future<_i6.Artwork?>); + returnValue: _i10.Future<_i6.Artwork?>.value(), + ) as _i10.Future<_i6.Artwork?>); @override - _i8.Future<_i6.Artwork> getArtwork(String? artworkId) => (super.noSuchMethod( + _i10.Future<_i6.Artwork> getArtwork(String? artworkId) => (super.noSuchMethod( Invocation.method( #getArtwork, [artworkId], ), - returnValue: _i8.Future<_i6.Artwork>.value(_FakeArtwork_4( + returnValue: _i10.Future<_i6.Artwork>.value(_FakeArtwork_4( this, Invocation.method( #getArtwork, [artworkId], ), )), - ) as _i8.Future<_i6.Artwork>); + ) as _i10.Future<_i6.Artwork>); + @override + _i10.Future<_i12.DailyToken?> getCurrentDailiesToken() => (super.noSuchMethod( + Invocation.method( + #getCurrentDailiesToken, + [], + ), + returnValue: _i10.Future<_i12.DailyToken?>.value(), + ) as _i10.Future<_i12.DailyToken?>); + @override + _i10.Future<_i12.DailyToken?> getNextDailiesToken() => (super.noSuchMethod( + Invocation.method( + #getNextDailiesToken, + [], + ), + returnValue: _i10.Future<_i12.DailyToken?>.value(), + ) as _i10.Future<_i12.DailyToken?>); + @override + _i10.Future<_i5.FeralFileListResponse<_i2.FFSeries>> exploreArtworks({ + String? sortBy, + String? sortOrder, + String? keyword = r'', + int? limit = 300, + int? offset = 0, + bool? includeArtist = true, + bool? includeExhibition = true, + bool? includeFirstArtwork = true, + bool? onlyViewable = true, + List? artistIds = const [], + bool? includeUniqeFilePath = true, + Map<_i11.FilterType, _i11.FilterValue>? filters = const {}, + }) => + (super.noSuchMethod( + Invocation.method( + #exploreArtworks, + [], + { + #sortBy: sortBy, + #sortOrder: sortOrder, + #keyword: keyword, + #limit: limit, + #offset: offset, + #includeArtist: includeArtist, + #includeExhibition: includeExhibition, + #includeFirstArtwork: includeFirstArtwork, + #onlyViewable: onlyViewable, + #artistIds: artistIds, + #includeUniqeFilePath: includeUniqeFilePath, + #filters: filters, + }, + ), + returnValue: _i10.Future<_i5.FeralFileListResponse<_i2.FFSeries>>.value( + _FakeFeralFileListResponse_3<_i2.FFSeries>( + this, + Invocation.method( + #exploreArtworks, + [], + { + #sortBy: sortBy, + #sortOrder: sortOrder, + #keyword: keyword, + #limit: limit, + #offset: offset, + #includeArtist: includeArtist, + #includeExhibition: includeExhibition, + #includeFirstArtwork: includeFirstArtwork, + #onlyViewable: onlyViewable, + #artistIds: artistIds, + #includeUniqeFilePath: includeUniqeFilePath, + #filters: filters, + }, + ), + )), + ) as _i10.Future<_i5.FeralFileListResponse<_i2.FFSeries>>); + @override + _i10.Future<_i5.FeralFileListResponse<_i7.FFArtist>> exploreArtists({ + int? limit = 20, + int? offset = 0, + String? keywork = r'', + String? orderBy = r'relevance', + String? sortOrder = r'DESC', + }) => + (super.noSuchMethod( + Invocation.method( + #exploreArtists, + [], + { + #limit: limit, + #offset: offset, + #keywork: keywork, + #orderBy: orderBy, + #sortOrder: sortOrder, + }, + ), + returnValue: _i10.Future<_i5.FeralFileListResponse<_i7.FFArtist>>.value( + _FakeFeralFileListResponse_3<_i7.FFArtist>( + this, + Invocation.method( + #exploreArtists, + [], + { + #limit: limit, + #offset: offset, + #keywork: keywork, + #orderBy: orderBy, + #sortOrder: sortOrder, + }, + ), + )), + ) as _i10.Future<_i5.FeralFileListResponse<_i7.FFArtist>>); + @override + _i10.Future<_i5.FeralFileListResponse<_i7.FFCurator>> exploreCurators({ + int? limit = 20, + int? offset = 0, + String? keywork = r'', + String? orderBy = r'relevance', + String? sortOrder = r'DESC', + }) => + (super.noSuchMethod( + Invocation.method( + #exploreCurators, + [], + { + #limit: limit, + #offset: offset, + #keywork: keywork, + #orderBy: orderBy, + #sortOrder: sortOrder, + }, + ), + returnValue: + _i10.Future<_i5.FeralFileListResponse<_i7.FFCurator>>.value( + _FakeFeralFileListResponse_3<_i7.FFCurator>( + this, + Invocation.method( + #exploreCurators, + [], + { + #limit: limit, + #offset: offset, + #keywork: keywork, + #orderBy: orderBy, + #sortOrder: sortOrder, + }, + ), + )), + ) as _i10.Future<_i5.FeralFileListResponse<_i7.FFCurator>>); + @override + _i10.Future<_i7.FFUserDetails> getUser(String? artistID) => + (super.noSuchMethod( + Invocation.method( + #getUser, + [artistID], + ), + returnValue: _i10.Future<_i7.FFUserDetails>.value(_FakeFFUserDetails_5( + this, + Invocation.method( + #getUser, + [artistID], + ), + )), + ) as _i10.Future<_i7.FFUserDetails>); + @override + _i10.Future> getPosts({ + String? sortBy = r'dateTime', + String? sortOrder = r'', + List? types = const [], + List? relatedAccountIds = const [], + bool? includeExhibition = true, + }) => + (super.noSuchMethod( + Invocation.method( + #getPosts, + [], + { + #sortBy: sortBy, + #sortOrder: sortOrder, + #types: types, + #relatedAccountIds: relatedAccountIds, + #includeExhibition: includeExhibition, + }, + ), + returnValue: _i10.Future>.value(<_i4.Post>[]), + ) as _i10.Future>); + @override + _i10.Future<_i8.ExploreStatisticsData> getExploreStatistics({ + bool? unique = true, + bool? excludedFF = true, + }) => + (super.noSuchMethod( + Invocation.method( + #getExploreStatistics, + [], + { + #unique: unique, + #excludedFF: excludedFF, + }, + ), + returnValue: _i10.Future<_i8.ExploreStatisticsData>.value( + _FakeExploreStatisticsData_6( + this, + Invocation.method( + #getExploreStatistics, + [], + { + #unique: unique, + #excludedFF: excludedFF, + }, + ), + )), + ) as _i10.Future<_i8.ExploreStatisticsData>); } diff --git a/test/generate_mock/service/mock_navigation_service.mocks.dart b/test/generate_mock/service/mock_navigation_service.mocks.dart index 4ca1b2511..ada1163c0 100644 --- a/test/generate_mock/service/mock_navigation_service.mocks.dart +++ b/test/generate_mock/service/mock_navigation_service.mocks.dart @@ -5,8 +5,10 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i4; -import 'package:autonomy_flutter/model/ff_exhibition.dart' as _i8; +import 'package:autonomy_flutter/model/ff_exhibition.dart' as _i9; import 'package:autonomy_flutter/screen/irl_screen/webview_irl_screen.dart' + as _i8; +import 'package:autonomy_flutter/screen/settings/subscription/upgrade_state.dart' as _i7; import 'package:autonomy_flutter/service/navigation_service.dart' as _i3; import 'package:autonomy_flutter/util/error_handler.dart' as _i6; @@ -96,7 +98,7 @@ class MockNavigationService extends _i2.Mock implements _i3.NavigationService { void setGlobalHomeTabController(_i1.PageController? controller) => super.noSuchMethod( Invocation.method( - #setPageController, + #setGlobalHomeTabController, [controller], ), returnValueForMissingStub: null, @@ -218,14 +220,6 @@ class MockNavigationService extends _i2.Mock implements _i3.NavigationService { returnValueForMissingStub: null, ); @override - void restorablePushHomePage() => super.noSuchMethod( - Invocation.method( - #restorablePushHomePage, - [], - ), - returnValueForMissingStub: null, - ); - @override void setIsWCConnectInShow(bool? appeared) => super.noSuchMethod( Invocation.method( #setIsWCConnectInShow, @@ -279,6 +273,24 @@ class MockNavigationService extends _i2.Mock implements _i3.NavigationService { returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); @override + _i4.Future showUnknownLink() => (super.noSuchMethod( + Invocation.method( + #showUnknownLink, + [], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future showCannotResolveBranchLink() => (super.noSuchMethod( + Invocation.method( + #showCannotResolveBranchLink, + [], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override _i4.Future showMembershipGiftCodeEmpty() => (super.noSuchMethod( Invocation.method( #showMembershipGiftCodeEmpty, @@ -333,6 +345,17 @@ class MockNavigationService extends _i2.Mock implements _i3.NavigationService { returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); @override + _i4.Future showSeeMoreArtNow( + _i7.SubscriptionDetails? subscriptionDetails) => + (super.noSuchMethod( + Invocation.method( + #showSeeMoreArtNow, + [subscriptionDetails], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override _i4.Future openPostcardReceivedPage({ required _i5.AssetToken? asset, required String? shareCode, @@ -379,7 +402,7 @@ class MockNavigationService extends _i2.Mock implements _i3.NavigationService { returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); @override - _i4.Future goToIRLWebview(_i7.IRLWebScreenPayload? payload) => + _i4.Future goToIRLWebview(_i8.IRLWebScreenPayload? payload) => (super.noSuchMethod( Invocation.method( #goToIRLWebview, @@ -506,8 +529,17 @@ class MockNavigationService extends _i2.Mock implements _i3.NavigationService { returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); @override + _i4.Future openCollection() => (super.noSuchMethod( + Invocation.method( + #openCollection, + [], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override _i4.Future openFeralFilePostPage( - _i8.Post? post, + _i9.Post? post, String? exhibitionID, ) => (super.noSuchMethod( From d27ceb2c516b0bbf9ae1b2703a3a77dc6a9a6c8c Mon Sep 17 00:00:00 2001 From: PuPha Date: Wed, 4 Sep 2024 15:30:06 +0700 Subject: [PATCH 06/12] Remove list identities in artwork details --- .../additional_data/view_new_message.dart | 5 +- lib/model/additional_data/view_postcard.dart | 3 +- .../collection_pro/collection_pro_screen.dart | 10 +- lib/screen/detail/artwork_detail_page.dart | 18 +-- .../detail/preview/artwork_preview_page.dart | 30 ++--- .../feralfile_home/featured_work_view.dart | 11 +- lib/screen/gallery/gallery_page.dart | 2 +- lib/screen/home/collection_home_page.dart | 6 +- lib/screen/home/organize_home_page.dart | 2 +- .../postcard_leaderboard_view.dart | 11 +- .../postcard_detail_page.dart | 14 +- .../interactive_postcard/stamp_preview.dart | 2 +- .../moma_postcard_page.dart | 4 +- .../add_new_playlist/add_new_playlist.dart | 7 +- .../add_to_playlist/add_to_playlist.dart | 9 +- .../view_playlist/view_playlist.dart | 6 +- lib/service/configuration_service.dart | 123 ------------------ lib/service/navigation_service.dart | 2 +- lib/service/notification_service.dart | 5 +- lib/util/route_ext.dart | 15 +-- 20 files changed, 55 insertions(+), 230 deletions(-) diff --git a/lib/model/additional_data/view_new_message.dart b/lib/model/additional_data/view_new_message.dart index 530fbd449..fce200abc 100644 --- a/lib/model/additional_data/view_new_message.dart +++ b/lib/model/additional_data/view_new_message.dart @@ -46,9 +46,8 @@ class ViewNewMessage extends AdditionalData { return; } final GlobalKey key = GlobalKey(); - final postcardDetailPayload = PostcardDetailPagePayload( - [ArtworkIdentity(groupId, owner)], 0, - key: key); + final postcardDetailPayload = + PostcardDetailPagePayload(ArtworkIdentity(groupId, owner), key: key); if (!context.mounted) { return; } diff --git a/lib/model/additional_data/view_postcard.dart b/lib/model/additional_data/view_postcard.dart index 87ca30fe0..19b2d4c87 100644 --- a/lib/model/additional_data/view_postcard.dart +++ b/lib/model/additional_data/view_postcard.dart @@ -34,8 +34,7 @@ class ViewPostcard extends AdditionalData { } final owner = tokens.first.owner; final postcardDetailPayload = PostcardDetailPagePayload( - [ArtworkIdentity(indexID, owner)], - 0, + ArtworkIdentity(indexID, owner), useIndexer: true, ); if (!context.mounted) { diff --git a/lib/screen/collection_pro/collection_pro_screen.dart b/lib/screen/collection_pro/collection_pro_screen.dart index a228e8212..1361f7b6e 100644 --- a/lib/screen/collection_pro/collection_pro_screen.dart +++ b/lib/screen/collection_pro/collection_pro_screen.dart @@ -531,10 +531,7 @@ class CollectionProState extends State context, AppRouter.artworkDetailsPage, arguments: ArtworkDetailPayload( - [ - ArtworkIdentity(token.id, token.owner), - ], - 0, + ArtworkIdentity(token.id, token.owner), ), ); }, @@ -549,10 +546,7 @@ class CollectionProState extends State context, AppRouter.artworkDetailsPage, arguments: ArtworkDetailPayload( - [ - ArtworkIdentity(token.id, token.owner), - ], - 0, + ArtworkIdentity(token.id, token.owner), ), ); }, diff --git a/lib/screen/detail/artwork_detail_page.dart b/lib/screen/detail/artwork_detail_page.dart index 85d92fc5f..43630504b 100644 --- a/lib/screen/detail/artwork_detail_page.dart +++ b/lib/screen/detail/artwork_detail_page.dart @@ -114,8 +114,7 @@ class _ArtworkDetailPageState extends State _infoShrink(); _bloc = context.read(); _canvasDeviceBloc = injector.get(); - _bloc.add(ArtworkDetailGetInfoEvent( - widget.payload.identities[widget.payload.currentIndex], + _bloc.add(ArtworkDetailGetInfoEvent(widget.payload.identity, useIndexer: widget.payload.useIndexer)); context.read().add(FetchAllAddressesEvent()); context.read().add(GetAccountsEvent()); @@ -379,8 +378,7 @@ class _ArtworkDetailPageState extends State Expanded( child: ArtworkPreviewWidget( useIndexer: widget.payload.useIndexer, - identity: widget - .payload.identities[widget.payload.currentIndex], + identity: widget.payload.identity, onLoaded: _onLoaded, ), ), @@ -864,8 +862,7 @@ class _ArtworkDetailPageState extends State class ArtworkDetailPayload { final Key? key; - final List identities; - final int currentIndex; + final ArtworkIdentity identity; final PlayListModel? playlist; final String? twitterCaption; final bool useIndexer; // set true when navigate from discover/gallery page @@ -873,8 +870,7 @@ class ArtworkDetailPayload { isLocalToken; // if local token, it can be hidden and refresh metadata ArtworkDetailPayload( - this.identities, - this.currentIndex, { + this.identity, { this.twitterCaption, this.playlist, this.useIndexer = false, @@ -883,16 +879,14 @@ class ArtworkDetailPayload { }); ArtworkDetailPayload copyWith({ - List? ids, - int? currentIndex, + ArtworkIdentity? identity, PlayListModel? playlist, String? twitterCaption, bool? useIndexer, bool? isLocalToken, }) => ArtworkDetailPayload( - ids ?? identities, - currentIndex ?? this.currentIndex, + identity ?? this.identity, twitterCaption: twitterCaption ?? this.twitterCaption, playlist: playlist ?? this.playlist, useIndexer: useIndexer ?? this.useIndexer, diff --git a/lib/screen/detail/preview/artwork_preview_page.dart b/lib/screen/detail/preview/artwork_preview_page.dart index ad837a512..2a0864650 100644 --- a/lib/screen/detail/preview/artwork_preview_page.dart +++ b/lib/screen/detail/preview/artwork_preview_page.dart @@ -44,7 +44,6 @@ class _ArtworkPreviewPageState extends State AfterLayoutMixin, RouteAware, WidgetsBindingObserver { - late PageController controller; late ArtworkPreviewBloc _bloc; ShakeDetector? _detector; @@ -52,7 +51,7 @@ class _ArtworkPreviewPageState extends State INFTRenderingWidget? _renderingWidget; - List _tokens = []; + late ArtworkIdentity _token; late int initialPage; final metricClient = injector.get(); @@ -60,14 +59,10 @@ class _ArtworkPreviewPageState extends State @override void initState() { super.initState(); - _tokens = List.from(widget.payload.identities); - final initialTokenID = _tokens[widget.payload.currentIndex]; - initialPage = _tokens.indexOf(initialTokenID); + _token = widget.payload.identity; - controller = PageController(initialPage: initialPage); _bloc = context.read(); - final currentIdentity = _tokens[initialPage]; - _bloc.add(ArtworkPreviewGetAssetTokenEvent(currentIdentity, + _bloc.add(ArtworkPreviewGetAssetTokenEvent(_token, useIndexer: widget.payload.useIndexer)); unawaited(_setFullScreen()); } @@ -168,24 +163,17 @@ class _ArtworkPreviewPageState extends State child: Column( children: [ Expanded( - child: PageView.builder( - physics: const NeverScrollableScrollPhysics(), - onPageChanged: (value) { - final currentId = _tokens[value]; - _bloc.add(ArtworkPreviewGetAssetTokenEvent(currentId, - useIndexer: widget.payload.useIndexer)); - }, - controller: controller, - itemCount: _tokens.length, - itemBuilder: (context, index) { - if (_tokens[index].id.isPostcardId) { + child: Builder( + builder: (context) { + final identity = _token; + if (identity.id.isPostcardId) { return PostcardPreviewWidget( - identity: _tokens[index], + identity: identity, useIndexer: widget.payload.useIndexer, ); } return ArtworkPreviewWidget( - identity: _tokens[index], + identity: identity, onLoaded: ( {InAppWebViewController? webViewController, int? time}) {}, diff --git a/lib/screen/feralfile_home/featured_work_view.dart b/lib/screen/feralfile_home/featured_work_view.dart index a80111205..ded1cddf0 100644 --- a/lib/screen/feralfile_home/featured_work_view.dart +++ b/lib/screen/feralfile_home/featured_work_view.dart @@ -386,13 +386,10 @@ class FeaturedWorkViewState extends State { unawaited(Navigator.of(context).pushNamed( AppRouter.artworkDetailsPage, arguments: ArtworkDetailPayload( - [ - ArtworkIdentity( - token.id, - token.owner, - ), - ], - 0, + ArtworkIdentity( + token.id, + token.owner, + ), isLocalToken: false, ), )); diff --git a/lib/screen/gallery/gallery_page.dart b/lib/screen/gallery/gallery_page.dart index c7ff6b79a..7aa176d3f 100644 --- a/lib/screen/gallery/gallery_page.dart +++ b/lib/screen/gallery/gallery_page.dart @@ -162,7 +162,7 @@ class _GalleryPageState extends State { return; } final payload = ArtworkDetailPayload( - [ArtworkIdentity(token.id, token.owner)], 0, + ArtworkIdentity(token.id, token.owner), useIndexer: true); unawaited(Navigator.of(context).pushNamed( AppRouter.artworkDetailsPage, diff --git a/lib/screen/home/collection_home_page.dart b/lib/screen/home/collection_home_page.dart index 240bba6bd..2a3041344 100644 --- a/lib/screen/home/collection_home_page.dart +++ b/lib/screen/home/collection_home_page.dart @@ -138,7 +138,7 @@ class CollectionHomePageState extends State .toList(); if (config.isAutoShowPostcard()) { log.info('Auto show minted postcard'); - final payload = PostcardDetailPagePayload(tokenMints, 0); + final payload = PostcardDetailPagePayload(tokenMints.first); unawaited(Navigator.of(context).pushNamed( AppRouter.claimedPostcardDetailsPage, arguments: payload, @@ -432,8 +432,8 @@ class CollectionHomePageState extends State .toList() .indexOf(asset); final payload = asset.isPostcard - ? PostcardDetailPagePayload(accountIdentities, index) - : ArtworkDetailPayload(accountIdentities, index); + ? PostcardDetailPagePayload(accountIdentities[index]) + : ArtworkDetailPayload(accountIdentities[index]); final pageName = asset.isPostcard ? AppRouter.claimedPostcardDetailsPage diff --git a/lib/screen/home/organize_home_page.dart b/lib/screen/home/organize_home_page.dart index 29453f9c7..527dc5cb1 100644 --- a/lib/screen/home/organize_home_page.dart +++ b/lib/screen/home/organize_home_page.dart @@ -110,7 +110,7 @@ class OrganizeHomePageState extends State .toList(); if (config.isAutoShowPostcard()) { log.info('Auto show minted postcard'); - final payload = PostcardDetailPagePayload(tokenMints, 0); + final payload = PostcardDetailPagePayload(tokenMints.first); unawaited(Navigator.of(context).pushNamed( AppRouter.claimedPostcardDetailsPage, arguments: payload, diff --git a/lib/screen/interactive_postcard/leaderboard/postcard_leaderboard_view.dart b/lib/screen/interactive_postcard/leaderboard/postcard_leaderboard_view.dart index 338962385..0e9ec8369 100644 --- a/lib/screen/interactive_postcard/leaderboard/postcard_leaderboard_view.dart +++ b/lib/screen/interactive_postcard/leaderboard/postcard_leaderboard_view.dart @@ -146,13 +146,10 @@ class _PostcardLeaderboardViewState extends State { final tokenId = postcardService.getTokenId(leaderBoardItem.id); final owner = leaderBoardItem.creators[0]; final payload = PostcardDetailPagePayload( - [ - ArtworkIdentity( - tokenId, - owner, - ) - ], - 0, + ArtworkIdentity( + tokenId, + owner, + ), isFromLeaderboard: true, useIndexer: true, ); diff --git a/lib/screen/interactive_postcard/postcard_detail_page.dart b/lib/screen/interactive_postcard/postcard_detail_page.dart index 5de186e65..f84888522 100644 --- a/lib/screen/interactive_postcard/postcard_detail_page.dart +++ b/lib/screen/interactive_postcard/postcard_detail_page.dart @@ -32,7 +32,6 @@ import 'package:autonomy_flutter/screen/interactive_postcard/travel_info/travel_ import 'package:autonomy_flutter/screen/interactive_postcard/travel_info/travel_info_state.dart'; import 'package:autonomy_flutter/screen/irl_screen/webview_irl_screen.dart'; import 'package:autonomy_flutter/screen/settings/crypto/send_artwork/send_artwork_page.dart'; -import 'package:autonomy_flutter/screen/settings/help_us/inapp_webview.dart'; import 'package:autonomy_flutter/service/auth_service.dart'; import 'package:autonomy_flutter/service/chat_service.dart'; import 'package:autonomy_flutter/service/configuration_service.dart'; @@ -77,8 +76,7 @@ class PostcardDetailPagePayload extends ArtworkDetailPayload { final bool isFromLeaderboard; PostcardDetailPagePayload( - super.identities, - super.currentIndex, { + super.identity, { super.key, super.playlist, super.twitterCaption, @@ -129,8 +127,7 @@ class ClaimedPostcardDetailPageState extends State isAutoStampIfNeed = true; super.initState(); context.read().add( - PostcardDetailGetInfoEvent( - widget.payload.identities[widget.payload.currentIndex], + PostcardDetailGetInfoEvent(widget.payload.identity, useIndexer: widget.payload.useIndexer || widget.payload.isFromLeaderboard), ); @@ -142,8 +139,7 @@ class ClaimedPostcardDetailPageState extends State @override void afterFirstLayout(BuildContext context) { _metricClientService.addEvent(MixpanelEvent.visitPage, data: { - MixpanelProp.tokenId: - widget.payload.identities[widget.payload.currentIndex], + MixpanelProp.tokenId: widget.payload.identity, }); } @@ -400,7 +396,7 @@ class ClaimedPostcardDetailPageState extends State isAutoStampIfNeed = false; unawaited( retryStampPostcardIfNeed(context, assetToken).then((final value) { - if (mounted && value == false) { + if (context.mounted && value == false) { UIHelper.showPostcardStampFailed(context); } })); @@ -648,7 +644,7 @@ class ClaimedPostcardDetailPageState extends State void _refreshPostcard() { log.info('Refresh postcard'); context.read().add(PostcardDetailGetInfoEvent( - widget.payload.identities[widget.payload.currentIndex], + widget.payload.identity, useIndexer: true, )); } diff --git a/lib/screen/interactive_postcard/stamp_preview.dart b/lib/screen/interactive_postcard/stamp_preview.dart index 477a7ceb0..cc8377752 100644 --- a/lib/screen/interactive_postcard/stamp_preview.dart +++ b/lib/screen/interactive_postcard/stamp_preview.dart @@ -122,7 +122,7 @@ class _StampPreviewState extends State with AfterLayoutMixin { } unawaited(Navigator.of(context).pushNamed( AppRouter.claimedPostcardDetailsPage, - arguments: PostcardDetailPagePayload([widget.payload.asset.identity], 0), + arguments: PostcardDetailPagePayload(widget.payload.asset.identity), )); unawaited(_configurationService.setAutoShowPostcard(true)); } diff --git a/lib/screen/moma_postcard_page/moma_postcard_page.dart b/lib/screen/moma_postcard_page/moma_postcard_page.dart index 687036b4c..6f5d4c726 100644 --- a/lib/screen/moma_postcard_page/moma_postcard_page.dart +++ b/lib/screen/moma_postcard_page/moma_postcard_page.dart @@ -171,8 +171,8 @@ class _MoMAPostcardPageState extends State { .toList() .indexOf(asset); final payload = asset.isPostcard - ? PostcardDetailPagePayload(accountIdentities, index) - : ArtworkDetailPayload(accountIdentities, index); + ? PostcardDetailPagePayload(accountIdentities[index]) + : ArtworkDetailPayload(accountIdentities[index]); final pageName = asset.isPostcard ? AppRouter.claimedPostcardDetailsPage diff --git a/lib/screen/playlists/add_new_playlist/add_new_playlist.dart b/lib/screen/playlists/add_new_playlist/add_new_playlist.dart index 2383f4886..acb89ee14 100644 --- a/lib/screen/playlists/add_new_playlist/add_new_playlist.dart +++ b/lib/screen/playlists/add_new_playlist/add_new_playlist.dart @@ -8,7 +8,6 @@ import 'package:autonomy_flutter/model/play_list_model.dart'; import 'package:autonomy_flutter/screen/playlists/add_new_playlist/add_new_playlist_bloc.dart'; import 'package:autonomy_flutter/screen/playlists/add_new_playlist/add_new_playlist_state.dart'; import 'package:autonomy_flutter/service/account_service.dart'; -import 'package:autonomy_flutter/service/configuration_service.dart'; import 'package:autonomy_flutter/util/constants.dart'; import 'package:autonomy_flutter/util/style.dart'; import 'package:autonomy_flutter/util/token_ext.dart'; @@ -71,11 +70,7 @@ class _AddNewPlaylistScreenState extends State } @override - void afterFirstLayout(BuildContext context) { - unawaited( - injector().setAlreadyShowCreatePlaylistTip(true)); - injector().showCreatePlaylistTip.value = false; - } + void afterFirstLayout(BuildContext context) {} void _focusCollectionName() { FocusScope.of(context).requestFocus(_focusNode); diff --git a/lib/screen/playlists/add_to_playlist/add_to_playlist.dart b/lib/screen/playlists/add_to_playlist/add_to_playlist.dart index be6f3fe54..2e980888e 100644 --- a/lib/screen/playlists/add_to_playlist/add_to_playlist.dart +++ b/lib/screen/playlists/add_to_playlist/add_to_playlist.dart @@ -8,7 +8,6 @@ import 'package:autonomy_flutter/model/play_list_model.dart'; import 'package:autonomy_flutter/screen/playlists/add_new_playlist/add_new_playlist_bloc.dart'; import 'package:autonomy_flutter/screen/playlists/add_new_playlist/add_new_playlist_state.dart'; import 'package:autonomy_flutter/service/account_service.dart'; -import 'package:autonomy_flutter/service/configuration_service.dart'; import 'package:autonomy_flutter/util/constants.dart'; import 'package:autonomy_flutter/util/string_ext.dart'; import 'package:autonomy_flutter/util/style.dart'; @@ -62,11 +61,7 @@ class _AddToCollectionScreenState extends State } @override - void afterFirstLayout(BuildContext context) { - unawaited( - injector().setAlreadyShowCreatePlaylistTip(true)); - injector().showCreatePlaylistTip.value = false; - } + void afterFirstLayout(BuildContext context) {} void _scrollListenerToLoadMore() { if (_controller.position.pixels + 100 >= @@ -174,7 +169,7 @@ class _AddToCollectionScreenState extends State (element) => state.selectedIDs?.contains(element.id) ?? false) .length; return Scaffold( - backgroundColor: theme.colorScheme.background, + backgroundColor: theme.colorScheme.surface, appBar: getPlaylistAppBar( context, title: Column( diff --git a/lib/screen/playlists/view_playlist/view_playlist.dart b/lib/screen/playlists/view_playlist/view_playlist.dart index 3df86f1d1..b4fc9681f 100644 --- a/lib/screen/playlists/view_playlist/view_playlist.dart +++ b/lib/screen/playlists/view_playlist/view_playlist.dart @@ -411,13 +411,11 @@ class _ViewPlaylistScreenState extends State { final payload = asset.isPostcard ? PostcardDetailPagePayload( - accountIdentities, - index, + accountIdentities[index], playlist: playlist, ) : ArtworkDetailPayload( - accountIdentities, - index, + accountIdentities[index], playlist: playlist, ); final pageName = asset.isPostcard diff --git a/lib/service/configuration_service.dart b/lib/service/configuration_service.dart index 37291af58..410a831e2 100644 --- a/lib/service/configuration_service.dart +++ b/lib/service/configuration_service.dart @@ -162,32 +162,8 @@ abstract class ConfigurationService { Future setDoneOnboardingTime(DateTime time); - DateTime? getDoneOnboardingTime(); - Future setSubscriptionTime(DateTime time); - DateTime? getSubscriptionTime(); - - Future setAlreadyShowProTip(bool show); - - Future setAlreadyShowTvAppTip(bool show); - - Future setAlreadyShowCreatePlaylistTip(bool show); - - Future setAlreadyShowLinkOrImportTip(bool show); - - bool getAlreadyShowProTip(); - - bool getAlreadyShowTvAppTip(); - - bool getAlreadyShowCreatePlaylistTip(); - - bool getAlreadyShowLinkOrImportTip(); - - DateTime? getShowBackupSettingTip(); - - Future setShowBackupSettingTip(DateTime time); - // Do at once /// to determine a hash value of the current addresses where @@ -203,8 +179,6 @@ abstract class ConfigurationService { ValueNotifier get showingNotification; - ValueNotifier get showCreatePlaylistTip; - List getSharedPostcard(); Future updateSharedPostcard(List sharedPostcards, @@ -321,19 +295,6 @@ class ConfigurationServiceImpl implements ConfigurationService { static const String KEY_SUBSCRIPTION_TIME = 'subscription_time'; - static const String KEY_CAN_SHOW_PRO_TIP = 'show_pro_tip'; - - static const String KEY_CAN_SHOW_TV_APP_TIP = 'show_tv_app_tip'; - - static const String KEY_CAN_SHOW_CREATE_PLAYLIST_TIP = - 'show_create_playlist_tip'; - - static const String KEY_CAN_SHOW_LINK_OR_IMPORT_TIP = - 'show_link_or_import_tip'; - - static const String KEY_SHOW_BACK_UP_SETTINGS_TIP = - 'show_back_up_settings_tip'; - static const String KEY_STAMPING_POSTCARD = 'stamping_postcard'; static const String KEY_AUTO_SHOW_POSTCARD = 'auto_show_postcard'; @@ -359,42 +320,6 @@ class ConfigurationServiceImpl implements ConfigurationService { static const String KEY_MERCHANDISE_ORDER_IDS = 'merchandise_order_ids'; - @override - Future setAlreadyShowProTip(bool show) async { - await _preferences.setBool(KEY_CAN_SHOW_PRO_TIP, show); - } - - @override - Future setAlreadyShowTvAppTip(bool show) async { - await _preferences.setBool(KEY_CAN_SHOW_TV_APP_TIP, show); - } - - @override - Future setAlreadyShowCreatePlaylistTip(bool show) async { - await _preferences.setBool(KEY_CAN_SHOW_CREATE_PLAYLIST_TIP, show); - } - - @override - Future setAlreadyShowLinkOrImportTip(bool show) async { - await _preferences.setBool(KEY_CAN_SHOW_LINK_OR_IMPORT_TIP, show); - } - - @override - bool getAlreadyShowProTip() => - _preferences.getBool(KEY_CAN_SHOW_PRO_TIP) ?? false; - - @override - bool getAlreadyShowTvAppTip() => - _preferences.getBool(KEY_CAN_SHOW_TV_APP_TIP) ?? false; - - @override - bool getAlreadyShowCreatePlaylistTip() => - _preferences.getBool(KEY_CAN_SHOW_CREATE_PLAYLIST_TIP) ?? false; - - @override - bool getAlreadyShowLinkOrImportTip() => - _preferences.getBool(KEY_CAN_SHOW_LINK_OR_IMPORT_TIP) ?? false; - // Do at once static const String KEY_SENT_TEZOS_ARTWORK_METRIC = 'sent_tezos_artwork_metric'; @@ -779,68 +704,20 @@ class ConfigurationServiceImpl implements ConfigurationService { await _preferences.setBool(READ_REMOVE_SUPPORT, value); } - @override - ValueNotifier showProTip = ValueNotifier(false); - - @override - ValueNotifier showCreatePlaylistTip = ValueNotifier(false); - - @override - ValueNotifier showLinkOrImportTip = ValueNotifier(false); - @override ValueNotifier showingNotification = ValueNotifier(false); - @override - ValueNotifier showTvAppTip = ValueNotifier(false); - - @override - DateTime? getDoneOnboardingTime() { - final timeString = _preferences.getString(KEY_DONE_ON_BOARDING_TIME); - if (timeString == null) { - return null; - } - return DateTime.parse(timeString); - } - @override Future setDoneOnboardingTime(DateTime time) async { await _preferences.setString( KEY_DONE_ON_BOARDING_TIME, time.toIso8601String()); } - @override - DateTime? getSubscriptionTime() { - final timeString = _preferences.getString(KEY_SUBSCRIPTION_TIME); - if (timeString == null) { - return null; - } - return DateTime.parse(timeString); - } - @override Future setSubscriptionTime(DateTime time) async { await _preferences.setString(KEY_SUBSCRIPTION_TIME, time.toIso8601String()); } - @override - DateTime? getShowBackupSettingTip() { - final timeString = _preferences.getString(KEY_SHOW_BACK_UP_SETTINGS_TIP); - if (timeString == null) { - return null; - } - return DateTime.parse(timeString); - } - - @override - Future setShowBackupSettingTip(DateTime time) async { - await _preferences.setString( - KEY_SHOW_BACK_UP_SETTINGS_TIP, time.toIso8601String()); - } - - @override - ValueNotifier showBackupSettingTip = ValueNotifier(false); - @override List getSharedPostcard() { final sharedPostcardString = diff --git a/lib/service/navigation_service.dart b/lib/service/navigation_service.dart index 74c0cd5cc..b11d8de0e 100644 --- a/lib/service/navigation_service.dart +++ b/lib/service/navigation_service.dart @@ -398,7 +398,7 @@ class NavigationService { .findAllAssetTokensByTokenIDs([indexID]); final owner = tokens.first.owner; final artworkDetailPayload = - ArtworkDetailPayload([ArtworkIdentity(indexID, owner)], 0); + ArtworkDetailPayload(ArtworkIdentity(indexID, owner)); if (context.mounted) { unawaited(Navigator.of(context).pushNamed(AppRouter.artworkDetailsPage, arguments: artworkDetailPayload)); diff --git a/lib/service/notification_service.dart b/lib/service/notification_service.dart index 98eb64eeb..8eaf1682d 100644 --- a/lib/service/notification_service.dart +++ b/lib/service/notification_service.dart @@ -114,9 +114,8 @@ class NotificationService { navigationService.popUntilHome(); await navigationService.navigateTo( AppRouter.claimedPostcardDetailsPage, - arguments: PostcardDetailPagePayload([ - ArtworkIdentity(postcardIdentity.id, postcardIdentity.owner) - ], 0)); + arguments: PostcardDetailPagePayload(ArtworkIdentity( + postcardIdentity.id, postcardIdentity.owner))); } } catch (e) { log.info('[NotificationService] onActionReceivedMethod error: $e]'); diff --git a/lib/util/route_ext.dart b/lib/util/route_ext.dart index ae6762aaf..1d15eedc4 100644 --- a/lib/util/route_ext.dart +++ b/lib/util/route_ext.dart @@ -73,23 +73,20 @@ extension RouteExt on Route { case AppRouter.artworkPreviewPage: final payload = settings.arguments! as ArtworkDetailPayload; data = { - MixpanelProp.tokenId: payload.identities[payload.currentIndex].id, - MixpanelProp.ownerAddress: - payload.identities[payload.currentIndex].owner, + MixpanelProp.tokenId: payload.identity.id, + MixpanelProp.ownerAddress: payload.identity.owner, }; case AppRouter.artworkDetailsPage: final payload = settings.arguments! as ArtworkDetailPayload; data = { - MixpanelProp.tokenId: payload.identities[payload.currentIndex].id, - MixpanelProp.ownerAddress: - payload.identities[payload.currentIndex].owner, + MixpanelProp.tokenId: payload.identity.id, + MixpanelProp.ownerAddress: payload.identity.owner, }; case AppRouter.claimedPostcardDetailsPage: final payload = settings.arguments! as PostcardDetailPagePayload; data = { - MixpanelProp.tokenId: payload.identities[payload.currentIndex].id, - MixpanelProp.ownerAddress: - payload.identities[payload.currentIndex].owner, + MixpanelProp.tokenId: payload.identity.id, + MixpanelProp.ownerAddress: payload.identity.owner, }; case AppRouter.galleryPage: final payload = settings.arguments! as GalleryPagePayload; From 7d8bd0b05bf60db7fcd55369d4c091ad1e669fde Mon Sep 17 00:00:00 2001 From: phuoc Date: Wed, 4 Sep 2024 15:56:30 +0700 Subject: [PATCH 07/12] unused class Signed-off-by: phuoc --- lib/common/environment.dart | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/common/environment.dart b/lib/common/environment.dart index 1a87ac097..951578a4d 100644 --- a/lib/common/environment.dart +++ b/lib/common/environment.dart @@ -189,8 +189,3 @@ class Environment { static String get tvKey => cachedSecretEnv['TV_API_KEY'] ?? ''; } - -class Secret { - static String get ffAuthorizationPrefix => - dotenv.env['FERAL_FILE_AUTHORIZATION_PREFIX'] ?? ''; -} From 58f03a6df8b91f840d43e2ee25498a7aecaa10da Mon Sep 17 00:00:00 2001 From: PuPha Date: Thu, 5 Sep 2024 10:27:22 +0700 Subject: [PATCH 08/12] Remove exhibitions page and global reveive page --- lib/common/injector.dart | 2 - lib/screen/app_router.dart | 13 - .../exhibition_detail_page.dart | 9 +- lib/screen/exhibitions/exhibitions_bloc.dart | 103 ----- lib/screen/exhibitions/exhibitions_page.dart | 387 ------------------ lib/screen/exhibitions/exhibitions_state.dart | 59 --- lib/screen/global_receive/receive_page.dart | 85 ---- lib/screen/scan_qr/scan_qr_page.dart | 68 +-- 8 files changed, 5 insertions(+), 721 deletions(-) delete mode 100644 lib/screen/exhibitions/exhibitions_bloc.dart delete mode 100644 lib/screen/exhibitions/exhibitions_page.dart delete mode 100644 lib/screen/exhibitions/exhibitions_state.dart delete mode 100644 lib/screen/global_receive/receive_page.dart diff --git a/lib/common/injector.dart b/lib/common/injector.dart index 7fa2012b8..51b231612 100644 --- a/lib/common/injector.dart +++ b/lib/common/injector.dart @@ -30,7 +30,6 @@ import 'package:autonomy_flutter/screen/chat/chat_bloc.dart'; import 'package:autonomy_flutter/screen/collection_pro/collection_pro_bloc.dart'; import 'package:autonomy_flutter/screen/dailies_work/dailies_work_bloc.dart'; import 'package:autonomy_flutter/screen/detail/preview/canvas_device_bloc.dart'; -import 'package:autonomy_flutter/screen/exhibitions/exhibitions_bloc.dart'; import 'package:autonomy_flutter/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart'; import 'package:autonomy_flutter/screen/playlists/add_new_playlist/add_new_playlist_bloc.dart'; import 'package:autonomy_flutter/screen/playlists/edit_playlist/edit_playlist_bloc.dart'; @@ -408,7 +407,6 @@ Future setup() async { )); injector.registerLazySingleton( () => CanvasDeviceBloc(injector())); - injector.registerFactory(() => ExhibitionBloc(injector())); injector.registerLazySingleton( () => SubscriptionBloc(injector())); injector.registerLazySingleton( diff --git a/lib/screen/app_router.dart b/lib/screen/app_router.dart index 47f6cd92d..fec27217d 100644 --- a/lib/screen/app_router.dart +++ b/lib/screen/app_router.dart @@ -65,7 +65,6 @@ import 'package:autonomy_flutter/screen/gallery/gallery_bloc.dart'; import 'package:autonomy_flutter/screen/gallery/gallery_page.dart'; import 'package:autonomy_flutter/screen/github_doc.dart'; import 'package:autonomy_flutter/screen/global_receive/receive_detail_page.dart'; -import 'package:autonomy_flutter/screen/global_receive/receive_page.dart'; import 'package:autonomy_flutter/screen/home/collection_home_page.dart'; import 'package:autonomy_flutter/screen/home/home_bloc.dart'; import 'package:autonomy_flutter/screen/home/home_navigation_page.dart'; @@ -805,18 +804,6 @@ class AppRouter { payload: settings.arguments! as CloudAndroidPagePayload, )); - case globalReceivePage: - return CupertinoPageRoute( - settings: settings, - builder: (context) => MultiBlocProvider(providers: [ - BlocProvider.value(value: accountsBloc), - BlocProvider( - create: (_) => personaBloc, - ), - BlocProvider.value(value: ethereumBloc), - BlocProvider.value(value: tezosBloc), - ], child: const GlobalReceivePage())); - case globalReceiveDetailPage: return CupertinoPageRoute( settings: settings, diff --git a/lib/screen/exhibition_details/exhibition_detail_page.dart b/lib/screen/exhibition_details/exhibition_detail_page.dart index d738108f2..befcfb8aa 100644 --- a/lib/screen/exhibition_details/exhibition_detail_page.dart +++ b/lib/screen/exhibition_details/exhibition_detail_page.dart @@ -7,7 +7,6 @@ import 'package:autonomy_flutter/model/pair.dart'; import 'package:autonomy_flutter/screen/detail/preview/canvas_device_bloc.dart'; import 'package:autonomy_flutter/screen/exhibition_details/exhibition_detail_bloc.dart'; import 'package:autonomy_flutter/screen/exhibition_details/exhibition_detail_state.dart'; -import 'package:autonomy_flutter/screen/exhibitions/exhibitions_bloc.dart'; import 'package:autonomy_flutter/service/metric_client_service.dart'; import 'package:autonomy_flutter/util/constants.dart'; import 'package:autonomy_flutter/util/exhibition_ext.dart'; @@ -41,7 +40,6 @@ class ExhibitionDetailPage extends StatefulWidget { class _ExhibitionDetailPageState extends State with AfterLayoutMixin { late final ExhibitionDetailBloc _exBloc; - late bool isUpcomingExhibition; final _metricClientService = injector(); final _canvasDeviceBloc = injector(); @@ -53,10 +51,6 @@ class _ExhibitionDetailPageState extends State @override void initState() { super.initState(); - final exhibitionBloc = injector(); - isUpcomingExhibition = exhibitionBloc.state.upcomingExhibition != null && - exhibitionBloc.state.upcomingExhibition!.id == - widget.payload.exhibitions[widget.payload.index].id; _exBloc = context.read(); _exBloc.add(GetExhibitionDetailEvent( widget.payload.exhibitions[widget.payload.index].id)); @@ -85,8 +79,9 @@ class _ExhibitionDetailPageState extends State return const LoadingWidget(); } + // if exhibition is not minted, show only preview page final itemCount = - isUpcomingExhibition ? 3 : ((exhibition.displayableSeries.length) + 3); + !exhibition.isMinted ? 3 : ((exhibition.displayableSeries.length) + 3); return Column( children: [ Expanded( diff --git a/lib/screen/exhibitions/exhibitions_bloc.dart b/lib/screen/exhibitions/exhibitions_bloc.dart deleted file mode 100644 index c7c6a6236..000000000 --- a/lib/screen/exhibitions/exhibitions_bloc.dart +++ /dev/null @@ -1,103 +0,0 @@ -import 'package:autonomy_flutter/au_bloc.dart'; -import 'package:autonomy_flutter/model/ff_exhibition.dart'; -import 'package:autonomy_flutter/screen/exhibitions/exhibitions_state.dart'; -import 'package:autonomy_flutter/service/feralfile_service.dart'; -import 'package:autonomy_flutter/util/exhibition_ext.dart'; -import 'package:autonomy_flutter/util/feral_file_helper.dart'; -import 'package:autonomy_flutter/util/log.dart'; - -class ExhibitionBloc extends AuBloc { - final FeralFileService _feralFileService; - - static const limit = 25; - Exhibition? _sourceExhibition; - - ExhibitionBloc(this._feralFileService) : super(ExhibitionsState()) { - on((event, emit) async { - if (state.allExhibitionIds.isNotEmpty) { - return; - } - final result = await Future.wait([ - _feralFileService.getUpcomingExhibition(), - _feralFileService.getFeaturedExhibition(), - _feralFileService.getAllExhibitions(limit: limit), - _feralFileService.getSourceExhibition(), - _feralFileService.getOngoingExhibitions(), - ]); - final upcomingExhibition = result[0] as Exhibition?; - final featuredExhibition = result[1]! as Exhibition; - final allExhibitions = result[2]! as List; - final sourceExhibition = result[3]! as Exhibition; - final ongoingExhibitions = result[4]! as List; - final ongoingExhibitionIDs = FeralFileHelper.ongoingExhibitionIDs; - - log.info('[ExhibitionBloc] getAllExhibitionsEvent:' - ' pro ${allExhibitions.length}'); - var pastExhibitions = allExhibitions - .where((exhibition) => - exhibition.id != featuredExhibition.id && - exhibition.id != upcomingExhibition?.id && - !ongoingExhibitionIDs.contains(exhibition.id)) - .toList(); - pastExhibitions = - _addSourceExhibitionIfNeeded(pastExhibitions, sourceExhibition); - _sourceExhibition = sourceExhibition; - emit(state.copyWith( - currentPage: 1, - upcomingExhibition: upcomingExhibition, - featuredExhibition: featuredExhibition, - ongoingExhibitions: ongoingExhibitions, - pastExhibitions: pastExhibitions, - )); - add(GetNextPageEvent(isLoop: true)); - }); - - on( - (event, emit) async { - log.info('[ExhibitionBloc] getNextPageEvent:' - 'offset ${state.currentPage * limit}'); - List exhibitions = - await _feralFileService.getAllExhibitions( - limit: limit, - offset: state.currentPage * limit, - ); - final resultLength = exhibitions.length; - log.info('[ExhibitionBloc] getNextPageEvent: $resultLength'); - - exhibitions.removeWhere( - (element) => state.allExhibitionIds.contains(element.id)); - if (_sourceExhibition != null && - (state.pastExhibitions ?? []).isNotEmpty && - !state.allExhibitionIds.contains(_sourceExhibition!.id)) { - exhibitions = - _addSourceExhibitionIfNeeded(exhibitions, _sourceExhibition!); - } - emit(state.copyWith( - pastExhibitions: [...?state.pastExhibitions, ...exhibitions], - currentPage: state.currentPage + 1, - )); - if (event.isLoop && resultLength == limit) { - add(GetNextPageEvent(isLoop: true)); - } - }, - ); - } - - List _addSourceExhibitionIfNeeded( - List exhibitions, Exhibition sourceExhibition) { - final isExistSourceExhibition = - exhibitions.any((exhibition) => exhibition.id == sourceExhibition.id); - if (isExistSourceExhibition) { - return exhibitions; - } - final lastExhibition = exhibitions.last; - if (lastExhibition.exhibitionViewAt - .isBefore(sourceExhibition.exhibitionViewAt)) { - log.info('[ExhibitionBloc] inserted Source Exhibition'); - exhibitions - ..add(sourceExhibition) - ..sort((a, b) => b.exhibitionViewAt.compareTo(a.exhibitionViewAt)); - } - return exhibitions; - } -} diff --git a/lib/screen/exhibitions/exhibitions_page.dart b/lib/screen/exhibitions/exhibitions_page.dart deleted file mode 100644 index 4049e344c..000000000 --- a/lib/screen/exhibitions/exhibitions_page.dart +++ /dev/null @@ -1,387 +0,0 @@ -import 'dart:async'; - -import 'package:auto_size_text/auto_size_text.dart'; -import 'package:autonomy_flutter/common/injector.dart'; -import 'package:autonomy_flutter/main.dart'; -import 'package:autonomy_flutter/model/ff_exhibition.dart'; -import 'package:autonomy_flutter/screen/app_router.dart'; -import 'package:autonomy_flutter/screen/bloc/subscription/subscription_bloc.dart'; -import 'package:autonomy_flutter/screen/bloc/subscription/subscription_state.dart'; -import 'package:autonomy_flutter/screen/exhibition_details/exhibition_detail_page.dart'; -import 'package:autonomy_flutter/screen/exhibitions/exhibitions_bloc.dart'; -import 'package:autonomy_flutter/screen/exhibitions/exhibitions_state.dart'; -import 'package:autonomy_flutter/service/navigation_service.dart'; -import 'package:autonomy_flutter/util/constants.dart'; -import 'package:autonomy_flutter/util/exhibition_ext.dart'; -import 'package:autonomy_flutter/util/feralfile_artist_ext.dart'; -import 'package:autonomy_flutter/util/style.dart'; -import 'package:autonomy_flutter/view/back_appbar.dart'; -import 'package:autonomy_flutter/view/header.dart'; -import 'package:autonomy_flutter/view/loading.dart'; -import 'package:cached_network_image/cached_network_image.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:feralfile_app_theme/feral_file_app_theme.dart'; -import 'package:flutter/gestures.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_cache_manager/flutter_cache_manager.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:sentry/sentry.dart'; - -class ExhibitionsPage extends StatefulWidget { - const ExhibitionsPage({super.key}); - - @override - State createState() => ExhibitionsPageState(); -} - -class ExhibitionsPageState extends State with RouteAware { - late ExhibitionBloc _exhibitionBloc; - late ScrollController _controller; - final _navigationService = injector(); - static const _padding = 14.0; - static const _exhibitionInfoDivideWidth = 20.0; - String? _autoOpenExhibitionId; - - // initState - @override - void initState() { - super.initState(); - _controller = ScrollController(); - _exhibitionBloc = injector(); - _exhibitionBloc.add(GetAllExhibitionsEvent()); - } - - void scrollToTop() { - unawaited(_controller.animateTo(0, - duration: const Duration(milliseconds: 500), - curve: Curves.fastOutSlowIn)); - } - - @override - void dispose() { - _controller.dispose(); - routeObserver.unsubscribe(this); - super.dispose(); - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - routeObserver.subscribe(this, ModalRoute.of(context)!); - } - - @override - void didPopNext() { - super.didPopNext(); - refreshExhibitions(); - } - - void refreshExhibitions() { - _exhibitionBloc.add(GetAllExhibitionsEvent()); - } - - void setAutoOpenExhibition(String exhibitionId) { - setState(() { - _autoOpenExhibitionId = exhibitionId; - }); - if (_exhibitionBloc.state.allExhibitions.isNotEmpty) { - _openExhibition(context, exhibitionId); - } - } - - void _openExhibition(BuildContext context, String exhibitionId) { - final listExhibitions = _exhibitionBloc.state.allExhibitions; - final index = - listExhibitions.indexWhere((element) => element.id == exhibitionId); - if (index < 0) { - unawaited(Sentry.captureMessage('Exhibition not found: $exhibitionId')); - } else { - unawaited( - _navigationService.navigateTo( - AppRouter.exhibitionDetailPage, - arguments: ExhibitionDetailPayload( - exhibitions: listExhibitions, - index: index, - ), - ), - ); - } - _autoOpenExhibitionId = null; - } - - @override - Widget build(BuildContext context) => Scaffold( - appBar: getDarkEmptyAppBar(Colors.transparent), - extendBody: true, - extendBodyBehindAppBar: true, - backgroundColor: AppColor.primaryBlack, - body: CustomScrollView( - controller: _controller, - slivers: [ - SliverToBoxAdapter( - child: SizedBox( - height: MediaQuery.of(context).padding.top, - ), - ), - SliverToBoxAdapter( - child: HeaderView( - title: 'exhibitions'.tr(), - ), - ), - _listExhibitions(context), - ], - ), - ); - - Widget _exhibitionItem({ - required BuildContext context, - required List viewableExhibitions, - required Exhibition exhibition, - required bool isFeaturedExhibition, - }) { - final theme = Theme.of(context); - final screenWidth = MediaQuery.sizeOf(context).width; - final estimatedHeight = (screenWidth - _padding * 2) / 16 * 9; - final estimatedWidth = screenWidth - _padding * 2; - final index = viewableExhibitions.indexOf(exhibition); - final titleStyle = theme.textTheme.ppMori400White16; - final subTitleStyle = theme.textTheme.ppMori400Grey12; - return GestureDetector( - onTap: () async => _onExhibitionTap(context, viewableExhibitions, index), - behavior: HitTestBehavior.deferToChild, - child: Container( - color: Colors.transparent, - child: Column( - children: [ - ClipRRect( - borderRadius: BorderRadius.circular(10), - child: exhibition.id == SOURCE_EXHIBITION_ID - ? SvgPicture.network( - exhibition.coverUrl, - height: estimatedHeight, - placeholderBuilder: (context) => Container( - height: estimatedHeight, - width: estimatedWidth, - color: Colors.transparent, - child: const LoadingWidget(), - ), - ) - : CachedNetworkImage( - imageUrl: exhibition.coverUrl, - height: estimatedHeight, - maxWidthDiskCache: estimatedWidth.toInt(), - memCacheWidth: estimatedWidth.toInt(), - memCacheHeight: estimatedHeight.toInt(), - maxHeightDiskCache: estimatedHeight.toInt(), - cacheManager: injector(), - placeholder: (context, url) => Container( - height: estimatedHeight, - width: estimatedWidth, - color: Colors.transparent, - child: const LoadingWidget(), - ), - fit: BoxFit.fitWidth, - ), - ), - const SizedBox(height: 20), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: (estimatedWidth - _exhibitionInfoDivideWidth) / 2, - child: AutoSizeText( - exhibition.title, - style: titleStyle, - maxLines: 2, - ), - ), - const SizedBox(width: _exhibitionInfoDivideWidth), - Expanded( - child: GestureDetector( - onTap: () {}, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (exhibition.isSoloExhibition && - exhibition.artists != null) ...[ - RichText( - text: TextSpan( - style: subTitleStyle.copyWith( - decorationColor: AppColor.disabledColor), - children: [ - TextSpan(text: 'works_by'.tr()), - TextSpan( - recognizer: TapGestureRecognizer() - ..onTap = () async { - await _navigationService - .openFeralFileArtistPage( - exhibition.artists![0].alias, - ); - }, - text: exhibition.artists![0].displayAlias, - style: const TextStyle( - decoration: TextDecoration.underline, - )), - ], - ), - ), - ], - if (exhibition.curator != null) - RichText( - text: TextSpan( - style: subTitleStyle.copyWith( - decorationColor: AppColor.disabledColor), - children: [ - TextSpan(text: 'curated_by'.tr()), - TextSpan( - recognizer: TapGestureRecognizer() - ..onTap = () async { - await _navigationService - .openFeralFileCuratorPage( - exhibition.curator!.alias); - }, - text: exhibition.curator!.displayAlias, - style: const TextStyle( - decoration: TextDecoration.underline, - ), - ), - ], - ), - ), - Text( - exhibition.isGroupExhibition - ? 'group_exhibition'.tr() - : 'solo_exhibition'.tr(), - style: subTitleStyle, - ), - ], - ), - ), - ) - ], - ), - ], - ), - ), - ); - } - - Widget _listExhibitions(BuildContext context) => - BlocConsumer( - listener: (context, exhibitionsState) { - if (exhibitionsState.allExhibitions.isNotEmpty && - _autoOpenExhibitionId != null) { - WidgetsBinding.instance.addPostFrameCallback((_) { - _openExhibition(context, _autoOpenExhibitionId!); - }); - } - }, - builder: (context, exhibitionsState) => - BlocBuilder( - builder: (context, subscriptionState) { - if (exhibitionsState.currentPage == 0) { - return SliverToBoxAdapter( - child: SizedBox( - height: MediaQuery.of(context).size.width / 16 * 9, - child: const LoadingWidget()), - ); - } else { - final featureExhibition = exhibitionsState.featuredExhibition; - final upcomingExhibition = exhibitionsState.upcomingExhibition; - final ongoingExhibitions = exhibitionsState.ongoingExhibitions; - final pastExhibitions = exhibitionsState.pastExhibitions; - - final allExhibition = exhibitionsState.allExhibitions; - - final divider = addDivider( - height: 40, color: AppColor.auQuickSilver, thickness: 0.5); - return SliverPadding( - padding: const EdgeInsets.symmetric(horizontal: _padding), - sliver: SliverList( - delegate: SliverChildBuilderDelegate( - (context, index) { - final exhibition = allExhibition[index]; - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (featureExhibition != null && index == 0) ...[ - _exhibitionGroupHeader( - context, - 'current_exhibition'.tr(), - ), - ], - if (upcomingExhibition != null && index == 1) ...[ - _exhibitionGroupHeader( - context, - 'upcoming_exhibition'.tr(), - ), - ], - if (exhibition.id == - ongoingExhibitions?.firstOrNull?.id) ...[ - _exhibitionGroupHeader( - context, - 'on_going_exhibition'.tr(), - ), - ], - if (exhibition.id == pastExhibitions?.first.id) - _exhibitionGroupHeader( - context, - 'past_exhibition'.tr(), - ), - _exhibitionItem( - context: context, - viewableExhibitions: allExhibition, - exhibition: exhibition, - isFeaturedExhibition: - exhibition.id == featureExhibition?.id, - ), - divider, - if (index == allExhibition.length - 1) - const SizedBox(height: 40), - ], - ); - }, - childCount: allExhibition.length, - ), - ), - ); - } - }, - ), - ); - - Widget _exhibitionGroupHeader(BuildContext context, String title) { - final theme = Theme.of(context); - return Padding( - padding: const EdgeInsets.only(bottom: 18), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - title, - style: theme.textTheme.ppMori700White14, - ), - ], - ), - ], - ), - ); - } - - Future _onExhibitionTap(BuildContext context, - List viewableExhibitions, int index) async { - if (index >= 0) { - await Navigator.of(context).pushNamed( - AppRouter.exhibitionDetailPage, - arguments: ExhibitionDetailPayload( - exhibitions: viewableExhibitions, - index: index, - ), - ); - } - } -} diff --git a/lib/screen/exhibitions/exhibitions_state.dart b/lib/screen/exhibitions/exhibitions_state.dart deleted file mode 100644 index a4532ac5e..000000000 --- a/lib/screen/exhibitions/exhibitions_state.dart +++ /dev/null @@ -1,59 +0,0 @@ -import 'package:autonomy_flutter/model/ff_exhibition.dart'; - -class ExhibitionsEvent {} - -class GetAllExhibitionsEvent extends ExhibitionsEvent {} - -class GetNextPageEvent extends ExhibitionsEvent { - final bool isLoop; - - GetNextPageEvent({this.isLoop = false}); -} - -class GetOpeningExhibitionsEvent extends ExhibitionsEvent {} - -class ExhibitionsState { - ExhibitionsState({ - this.currentPage = 0, - this.upcomingExhibition, - this.featuredExhibition, - this.ongoingExhibitions, - this.pastExhibitions, - }); - - final int currentPage; - final Exhibition? upcomingExhibition; - final Exhibition? featuredExhibition; - final List? ongoingExhibitions; - final List? pastExhibitions; - - ExhibitionsState copyWith({ - final Exhibition? upcomingExhibition, - final Exhibition? featuredExhibition, - final List? ongoingExhibitions, - final List? pastExhibitions, - bool? isSubscribed, - int? currentPage, - }) => - ExhibitionsState( - currentPage: currentPage ?? this.currentPage, - upcomingExhibition: upcomingExhibition ?? this.upcomingExhibition, - featuredExhibition: featuredExhibition ?? this.featuredExhibition, - ongoingExhibitions: ongoingExhibitions ?? this.ongoingExhibitions, - pastExhibitions: pastExhibitions ?? this.pastExhibitions, - ); - - List get allExhibitionIds => [ - if (featuredExhibition != null) featuredExhibition!.id, - if (upcomingExhibition != null) upcomingExhibition!.id, - ...ongoingExhibitions?.map((e) => e.id) ?? [], - ...pastExhibitions?.map((e) => e.id) ?? [], - ]; - - List get allExhibitions => [ - if (featuredExhibition != null) featuredExhibition!, - if (upcomingExhibition != null) upcomingExhibition!, - ...ongoingExhibitions ?? [], - ...pastExhibitions ?? [], - ]; -} diff --git a/lib/screen/global_receive/receive_page.dart b/lib/screen/global_receive/receive_page.dart deleted file mode 100644 index 4c2c8890d..000000000 --- a/lib/screen/global_receive/receive_page.dart +++ /dev/null @@ -1,85 +0,0 @@ -// -// SPDX-License-Identifier: BSD-2-Clause-Patent -// Copyright © 2022 Bitmark. All rights reserved. -// Use of this source code is governed by the BSD-2-Clause Plus Patent License -// that can be found in the LICENSE file. -// - -import 'package:autonomy_flutter/screen/bloc/accounts/accounts_bloc.dart'; -import 'package:autonomy_flutter/util/style.dart'; -import 'package:autonomy_flutter/view/account_view.dart'; -import 'package:autonomy_flutter/view/back_appbar.dart'; -import 'package:autonomy_flutter/view/responsive.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:feralfile_app_theme/feral_file_app_theme.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; - -class GlobalReceivePage extends StatefulWidget { - final Function()? onClose; - - const GlobalReceivePage({ - super.key, - this.onClose, - }); - - @override - State createState() => _GlobalReceivePageState(); -} - -class _GlobalReceivePageState extends State { - @override - void initState() { - super.initState(); - context.read().add(GetCategorizedAccountsEvent()); - } - - @override - Widget build(BuildContext context) { - final theme = Theme.of(context); - - return Scaffold( - appBar: getCloseAppBar( - context, - title: 'select_wallet_tt'.tr(), - onClose: widget.onClose, - ), - body: BlocBuilder(builder: (context, state) { - final categorizedAccounts = state.accounts; - if (categorizedAccounts == null) { - return Container( - alignment: Alignment.center, - child: loadingIndicator(), - ); - } - - return SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - addTitleSpace(), - Padding( - padding: ResponsiveLayout.pageEdgeInsets, - child: Text( - 'select_address'.tr(), - style: theme.textTheme.ppMori400Black14, - ), - ), - const SizedBox(height: 24), - ListView.builder( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - itemBuilder: (context, index) => Container( - padding: const EdgeInsets.only(top: 16), - child: accountWithConnectionItem( - context, categorizedAccounts[index]), - ), - itemCount: categorizedAccounts.length), - const SizedBox(height: 100), - ], - ), - ); - }), - ); - } -} diff --git a/lib/screen/scan_qr/scan_qr_page.dart b/lib/screen/scan_qr/scan_qr_page.dart index 0e0a083b7..443115391 100644 --- a/lib/screen/scan_qr/scan_qr_page.dart +++ b/lib/screen/scan_qr/scan_qr_page.dart @@ -9,15 +9,8 @@ import 'dart:async'; import 'dart:io'; import 'package:autonomy_flutter/common/injector.dart'; -import 'package:autonomy_flutter/database/cloud_database.dart'; import 'package:autonomy_flutter/main.dart'; import 'package:autonomy_flutter/screen/app_router.dart'; -import 'package:autonomy_flutter/screen/bloc/accounts/accounts_bloc.dart' - as accounts; -import 'package:autonomy_flutter/screen/bloc/ethereum/ethereum_bloc.dart'; -import 'package:autonomy_flutter/screen/bloc/persona/persona_bloc.dart'; -import 'package:autonomy_flutter/screen/bloc/tezos/tezos_bloc.dart'; -import 'package:autonomy_flutter/screen/global_receive/receive_page.dart'; import 'package:autonomy_flutter/service/deeplink_service.dart'; import 'package:autonomy_flutter/service/metric_client_service.dart'; import 'package:autonomy_flutter/service/navigation_service.dart'; @@ -38,7 +31,6 @@ import 'package:feralfile_app_theme/feral_file_app_theme.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:qr_code_scanner/qr_code_scanner.dart'; @@ -47,15 +39,12 @@ import 'package:qr_code_scanner/qr_code_scanner.dart'; enum QRScanTab { scan, - showMyCode, ; String get routerName { switch (this) { case scan: return AppRouter.scanQRPage; - case showMyCode: - return AppRouter.globalReceivePage; } } @@ -110,33 +99,6 @@ class ScanQRPageState extends State scannerItem: widget.payload.scannerItem, onHandleFinished: widget.payload.onHandleFinished, ), - MultiBlocProvider( - providers: [ - BlocProvider( - create: (_) => accounts.AccountsBloc(injector(), injector())), - BlocProvider( - create: (_) => PersonaBloc( - injector(), - injector(), - ), - ), - BlocProvider(create: (_) => EthereumBloc(injector(), injector())), - BlocProvider( - create: (_) => TezosBloc(injector(), injector()), - ), - ], - child: GlobalReceivePage( - onClose: () { - setState( - () { - _tabController.animateTo(QRScanTab.scan.index, - duration: const Duration(milliseconds: 300)); - unawaited(resumeCamera()); - }, - ); - }, - ), - ), ]; } @@ -202,7 +164,7 @@ class ScanQRPageState extends State ); Widget _header(BuildContext context) { - final theme = Theme.of(context); + Theme.of(context); return Column( mainAxisSize: MainAxisSize.min, children: [ @@ -212,31 +174,6 @@ class ScanQRPageState extends State title: 'scan'.tr(), action: Row( children: [ - if (_isGlobal) - GestureDetector( - onTap: () { - setState(() { - unawaited(pauseCamera()); - _tabController.animateTo(QRScanTab.showMyCode.index, - duration: const Duration(milliseconds: 300)); - }); - }, - child: Container( - padding: const EdgeInsets.symmetric( - vertical: 10, - ), - child: Text( - 'show_my_code'.tr(), - style: theme.textTheme.ppMori400White14.copyWith( - decoration: TextDecoration.underline, - decorationColor: AppColor.white, - ), - ), - ), - ) - else - const SizedBox(), - const SizedBox(width: 20), IconButton( onPressed: () { Navigator.pop(context); @@ -707,7 +644,8 @@ class QRScanViewState extends State } else { switch (widget.scannerItem) { case ScannerItem.CANVAS: - // dont need to do anything here, it has been processed in the branch deeplink + // dont need to do anything here, + // it has been processed in the branch deeplink /// handled with deeplink case ScannerItem.WALLET_CONNECT: if (code.startsWith('wc:')) { From f03ca6ab230aaaa7304bffbc259f87a2adc91930 Mon Sep 17 00:00:00 2001 From: PuPha Date: Thu, 5 Sep 2024 13:35:30 +0700 Subject: [PATCH 09/12] Update --- lib/screen/scan_qr/scan_qr_page.dart | 50 ++++------------------------ 1 file changed, 7 insertions(+), 43 deletions(-) diff --git a/lib/screen/scan_qr/scan_qr_page.dart b/lib/screen/scan_qr/scan_qr_page.dart index 443115391..be81e1207 100644 --- a/lib/screen/scan_qr/scan_qr_page.dart +++ b/lib/screen/scan_qr/scan_qr_page.dart @@ -72,46 +72,15 @@ class ScanQRPage extends StatefulWidget { class ScanQRPageState extends State with RouteAware, TickerProviderStateMixin { - late TabController _tabController; - late bool _isGlobal; final GlobalKey _qrScanViewKey = GlobalKey(); - final _metricClientService = injector(); - late List _pages; - - TabController get tabController => _tabController; @override void initState() { super.initState(); - _isGlobal = (widget.payload.scannerItem == ScannerItem.GLOBAL); //There is a conflict with lib qr_code_scanner on Android. if (Platform.isIOS) { unawaited(SystemChrome.setEnabledSystemUIMode(SystemUiMode.leanBack)); } - _tabController = TabController(length: _isGlobal ? 2 : 1, vsync: this); - _tabController.addListener(() { - setState(() {}); - _addMetricListener(_tabController); - }); - _pages = [ - QRScanView( - key: _qrScanViewKey, - scannerItem: widget.payload.scannerItem, - onHandleFinished: widget.payload.onHandleFinished, - ), - ]; - } - - void _addMetricListener(TabController controller) { - if (controller.indexIsChanging) { - return; - } - _metricClientService - ..addEvent(MixpanelEvent.visitPage, data: { - MixpanelProp.title: - QRScanTab.values[controller.previousIndex].screenName, - }) - ..timerEvent(MixpanelEvent.visitPage); } Future pauseCamera() async { @@ -120,9 +89,7 @@ class ScanQRPageState extends State } Future resumeCamera() async { - if (_tabController.index == QRScanTab.scan.index) { - await _qrScanViewKey.currentState?.resumeCamera(); - } + await _qrScanViewKey.currentState?.resumeCamera(); } @override @@ -138,14 +105,11 @@ class ScanQRPageState extends State child: Scaffold( extendBodyBehindAppBar: true, backgroundColor: AppColor.primaryBlack, - appBar: _tabController.index == QRScanTab.scan.index - ? getDarkEmptyAppBar(Colors.transparent) - : getLightEmptyAppBar(), + appBar: getDarkEmptyAppBar(Colors.transparent), body: Stack( children: [ _content(context), - if (_tabController.index == QRScanTab.scan.index) - _header(context), + _header(context), ], ), ), @@ -154,10 +118,10 @@ class ScanQRPageState extends State Widget _content(BuildContext context) => Column( children: [ Expanded( - child: TabBarView( - controller: _tabController, - physics: const NeverScrollableScrollPhysics(), - children: _pages.sublist(0, _tabController.length), + child: QRScanView( + key: _qrScanViewKey, + scannerItem: widget.payload.scannerItem, + onHandleFinished: widget.payload.onHandleFinished, ), ), ], From 4c48035f5da0657a9147f4439426e7d0ec071749 Mon Sep 17 00:00:00 2001 From: PuPha Date: Thu, 5 Sep 2024 13:58:59 +0700 Subject: [PATCH 10/12] remove unused view --- lib/screen/account/link_manually_page.dart | 6 +- lib/view/account_view.dart | 82 ------- lib/view/add_button.dart | 46 ---- lib/view/artwork_common_widget.dart | 130 ---------- lib/view/au_button_clipper.dart | 49 +--- lib/view/au_filled_button.dart | 81 ------ lib/view/au_radio_button.dart | 42 ++-- lib/view/carousel.dart | 78 ------ lib/view/confetti.dart | 10 +- lib/view/crypto_view.dart | 273 --------------------- lib/view/dot_loading_indicator.dart | 82 ------- lib/view/how_it_works_view.dart | 45 ---- lib/view/jumping_dot.dart | 125 ---------- lib/view/modal_widget.dart | 41 ---- lib/view/postcard_button.dart | 69 ------ lib/view/postcard_explain.dart | 127 ---------- lib/view/stream_common_widget.dart | 6 - lib/view/text_shuffler.dart | 128 ---------- lib/view/tip_card.dart | 82 ------- lib/view/transparent_router.dart | 4 +- 20 files changed, 30 insertions(+), 1476 deletions(-) delete mode 100644 lib/view/add_button.dart delete mode 100644 lib/view/au_filled_button.dart delete mode 100644 lib/view/carousel.dart delete mode 100644 lib/view/dot_loading_indicator.dart delete mode 100644 lib/view/how_it_works_view.dart delete mode 100644 lib/view/jumping_dot.dart delete mode 100644 lib/view/modal_widget.dart delete mode 100644 lib/view/postcard_explain.dart delete mode 100644 lib/view/text_shuffler.dart delete mode 100644 lib/view/tip_card.dart diff --git a/lib/screen/account/link_manually_page.dart b/lib/screen/account/link_manually_page.dart index 5ce84d723..15aa0155b 100644 --- a/lib/screen/account/link_manually_page.dart +++ b/lib/screen/account/link_manually_page.dart @@ -11,9 +11,9 @@ import 'package:autonomy_flutter/service/configuration_service.dart'; import 'package:autonomy_flutter/service/navigation_service.dart'; import 'package:autonomy_flutter/util/style.dart'; import 'package:autonomy_flutter/util/ui_helper.dart'; -import 'package:autonomy_flutter/view/au_filled_button.dart'; import 'package:autonomy_flutter/view/au_text_field.dart'; import 'package:autonomy_flutter/view/back_appbar.dart'; +import 'package:autonomy_flutter/view/primary_button.dart'; import 'package:autonomy_flutter/view/responsive.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; @@ -100,10 +100,10 @@ class _LinkManuallyPageState extends State { Row( children: [ Expanded( - child: AuFilledButton( + child: PrimaryButton( text: "link".tr(), enabled: _linkEnabled, - onPress: () => _link(), + onTap: () => _link(), ), ), ], diff --git a/lib/view/account_view.dart b/lib/view/account_view.dart index 3dfc68e31..980a6c8f2 100644 --- a/lib/view/account_view.dart +++ b/lib/view/account_view.dart @@ -9,55 +9,20 @@ import 'dart:async'; import 'package:autonomy_flutter/common/injector.dart'; import 'package:autonomy_flutter/model/pair.dart'; -import 'package:autonomy_flutter/screen/app_router.dart'; import 'package:autonomy_flutter/screen/bloc/accounts/accounts_bloc.dart'; -import 'package:autonomy_flutter/screen/global_receive/receive_detail_page.dart'; import 'package:autonomy_flutter/service/ethereum_service.dart'; import 'package:autonomy_flutter/service/tezos_service.dart'; import 'package:autonomy_flutter/util/account_ext.dart'; import 'package:autonomy_flutter/util/constants.dart'; import 'package:autonomy_flutter/util/ether_amount_ext.dart'; import 'package:autonomy_flutter/util/int_ext.dart'; -import 'package:autonomy_flutter/util/style.dart'; import 'package:autonomy_flutter/view/crypto_view.dart'; -import 'package:autonomy_flutter/view/responsive.dart'; -import 'package:autonomy_flutter/view/tappable_forward_row.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:feralfile_app_theme/feral_file_app_theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:nft_collection/database/dao/dao.dart'; -Widget accountWithConnectionItem( - BuildContext context, Account categorizedAccounts) { - final a = categorizedAccounts; - switch (categorizedAccounts.className) { - case 'Persona': - case 'Connection': - return Column( - children: [ - _blockchainAddressView( - context, - GlobalReceivePayload( - address: a.accountNumber, - blockchain: a.blockchain!, - account: a), - onTap: () => unawaited(Navigator.of(context).pushNamed( - AppRouter.globalReceiveDetailPage, - arguments: GlobalReceivePayload( - address: a.accountNumber, - blockchain: a.blockchain!, - account: a))), - ), - addOnlyDivider(color: AppColor.auLightGrey), - ], - ); - - default: - return const SizedBox(); - } -} - Widget accountItem(BuildContext context, Account account, {bool isPrimary = false, Function()? onPersonaTap, @@ -176,53 +141,6 @@ Future?> getAddressBalance( } } -Widget _blockchainAddressView( - BuildContext context, - GlobalReceivePayload receiver, { - Function()? onTap, -}) { - final theme = Theme.of(context); - return Container( - padding: ResponsiveLayout.pageHorizontalEdgeInsets, - child: TappableForwardRowWithContent( - leftWidget: Row( - children: [ - _blockchainLogo(receiver.blockchain), - const SizedBox(width: 10), - Text( - receiver.account.name, - style: theme.textTheme.ppMori700Black14, - ), - const SizedBox(width: 8), - ], - ), - onTap: onTap, - bottomWidget: Text( - receiver.address, - style: theme.textTheme.ibmBlackNormal14, - ), - ), - ); -} - -Widget _blockchainLogo(String? blockchain) { - switch (blockchain) { - case 'Bitmark': - return SvgPicture.asset('assets/images/iconBitmark.svg'); - case 'Ethereum': - case 'walletConnect': - case 'walletBrowserConnect': - return SvgPicture.asset( - 'assets/images/ether.svg', - ); - case 'Tezos': - case 'walletBeacon': - return SvgPicture.asset('assets/images/tez.svg'); - default: - return const SizedBox(); - } -} - Widget linkedBox(BuildContext context, {double fontSize = 12.0}) { final theme = Theme.of(context); return Container( diff --git a/lib/view/add_button.dart b/lib/view/add_button.dart deleted file mode 100644 index 40b95a6f5..000000000 --- a/lib/view/add_button.dart +++ /dev/null @@ -1,46 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'dart:ui' as ui; - -class AddButton extends StatelessWidget { - final Function() onTap; - final double size; - - const AddButton({Key? key, required this.onTap, this.size = 22}) - : super(key: key); - - @override - Widget build(BuildContext context) { - return GestureDetector( - onTap: onTap, - child: SvgPicture.asset( - "assets/images/add_icon.svg", - width: size, - height: size, - )); - } -} - -class RemoveButton extends StatelessWidget { - final Function() onTap; - final double size; - final Color? color; - - const RemoveButton( - {Key? key, required this.onTap, this.size = 22, this.color}) - : super(key: key); - - @override - Widget build(BuildContext context) { - return GestureDetector( - onTap: onTap, - child: SvgPicture.asset( - "assets/images/remove_icon.svg", - width: size, - height: size, - colorFilter: color == null - ? null - : ui.ColorFilter.mode(color!, BlendMode.srcIn), - )); - } -} diff --git a/lib/view/artwork_common_widget.dart b/lib/view/artwork_common_widget.dart index c2f6d149d..bc5acbd28 100644 --- a/lib/view/artwork_common_widget.dart +++ b/lib/view/artwork_common_widget.dart @@ -485,55 +485,6 @@ class RetryCubit extends Cubit { } } -class PreviewUnSupportedTokenWidget extends StatelessWidget { - final AssetToken token; - - const PreviewUnSupportedTokenWidget({required this.token, super.key}); - - @override - Widget build(BuildContext context) { - final theme = Theme.of(context); - final size = MediaQuery.of(context).size; - return Container( - width: size.width, - height: size.width, - padding: const EdgeInsets.all(10), - color: AppColor.auGreyBackground, - child: Stack( - children: [ - Center( - child: SvgPicture.asset( - 'assets/images/unsupported_token.svg', - width: 40, - ), - ), - Align( - alignment: AlignmentDirectional.bottomStart, - child: Row( - children: [ - Text( - 'unsupported_token'.tr(), - style: theme.textTheme.ppMori700QuickSilver8 - .copyWith(fontSize: 12), - ), - const Spacer(), - GestureDetector( - onTap: () {}, - child: Text( - 'hide_from_collection'.tr(), - style: theme.textTheme.ppMori400Black12 - .copyWith(color: AppColor.feralFileHighlight), - ), - ) - ], - ), - ), - ], - ), - ); - } -} - class BrokenTokenWidget extends StatefulWidget { final AssetToken token; @@ -596,50 +547,6 @@ class _BrokenTokenWidgetState extends State } } -class CurrentlyCastingArtwork extends StatefulWidget { - const CurrentlyCastingArtwork({super.key}); - - @override - State createState() => - _CurrentlyCastingArtworkState(); -} - -class _CurrentlyCastingArtworkState extends State { - @override - Widget build(BuildContext context) { - final theme = Theme.of(context); - final size = MediaQuery.of(context).size; - return Container( - width: size.width, - height: size.width, - padding: const EdgeInsets.all(10), - color: AppColor.auGreyBackground, - child: Stack( - children: [ - Center( - child: SvgPicture.asset( - 'assets/images/ipfs_error_icon.svg', - width: 40, - ), - ), - Align( - alignment: AlignmentDirectional.bottomStart, - child: Row( - children: [ - Text( - 'currently_casting'.tr(), - style: theme.textTheme.ppMori700QuickSilver8 - .copyWith(fontSize: 12), - ), - ], - ), - ), - ], - ), - ); - } -} - Widget previewPlaceholder() => const PreviewPlaceholder(); class PreviewPlaceholder extends StatefulWidget { @@ -1640,43 +1547,6 @@ class ProvenanceItem extends StatelessWidget { } } -class HeaderData extends StatelessWidget { - final String text; - - const HeaderData({required this.text, super.key}); - - @override - Widget build(BuildContext context) { - final theme = Theme.of(context); - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Divider( - color: theme.colorScheme.secondary, - thickness: 1, - ), - Row( - children: [ - Text( - text, - style: theme.textTheme.ppMori400White14, - ), - const Spacer(), - RotatedBox( - quarterTurns: 1, - child: Icon( - AuIcon.chevron_Sm, - size: 12, - color: theme.colorScheme.secondary, - ), - ) - ], - ), - ], - ); - } -} - Widget artworkDetailsProvenanceSectionNotEmpty( BuildContext context, List provenances, diff --git a/lib/view/au_button_clipper.dart b/lib/view/au_button_clipper.dart index ea65b0844..8c7f9a47c 100644 --- a/lib/view/au_button_clipper.dart +++ b/lib/view/au_button_clipper.dart @@ -7,28 +7,9 @@ import 'package:flutter/material.dart'; -class AutonomyButtonClipper extends CustomClipper { - @override - Path getClip(Size size) { - double radius = 14; - - Path path = Path() - ..lineTo(size.width, 0) - ..lineTo(size.width, size.height - radius) - ..lineTo(size.width - radius, size.height) - ..lineTo(0, size.height) - ..lineTo(0, 0) - ..close(); - - return path; - } - - @override - bool shouldReclip(CustomClipper oldClipper) => false; -} - class AutonomyTopRightRectangleClipper extends CustomClipper { final double? customRadius; + AutonomyTopRightRectangleClipper({this.customRadius}); @override @@ -50,31 +31,3 @@ class AutonomyTopRightRectangleClipper extends CustomClipper { @override bool shouldReclip(CustomClipper oldClipper) => false; } - -class AutonomyOutlineButtonClipper extends CustomClipper { - @override - Path getClip(Size size) { - double radius = 14; - double border = 2; - - Path path = Path() - ..lineTo(size.width, 0) - ..lineTo(size.width, size.height - radius) - ..lineTo(size.width - radius, size.height) - ..lineTo(0, size.height) - ..lineTo(0, border) - ..lineTo(border, border) - ..lineTo(border, size.height - border) - ..lineTo(size.width - radius - 1, size.height - border) - ..lineTo(size.width - border, size.height - radius - 1) - ..lineTo(size.width - border, border) - ..lineTo(0, border) - ..lineTo(0, 0) - ..close(); - - return path; - } - - @override - bool shouldReclip(CustomClipper oldClipper) => false; -} diff --git a/lib/view/au_filled_button.dart b/lib/view/au_filled_button.dart deleted file mode 100644 index 1e2cfbea7..000000000 --- a/lib/view/au_filled_button.dart +++ /dev/null @@ -1,81 +0,0 @@ -// -// SPDX-License-Identifier: BSD-2-Clause-Patent -// Copyright © 2022 Bitmark. All rights reserved. -// Use of this source code is governed by the BSD-2-Clause Plus Patent License -// that can be found in the LICENSE file. -// - -import 'package:autonomy_flutter/view/au_button_clipper.dart'; -import 'package:feralfile_app_theme/feral_file_app_theme.dart'; -import 'package:flutter/material.dart'; - -class AuFilledButton extends StatelessWidget { - final String text; - final Function()? onPress; - final Color color; - final bool enabled; - final Widget? icon; - final TextStyle? textStyle; - final TextAlign? textAlign; - final bool isProcessing; - - const AuFilledButton( - {required this.text, - required this.onPress, - super.key, - this.icon, - this.enabled = true, - this.color = AppColor.primaryBlack, - this.isProcessing = false, - this.textStyle, - this.textAlign}); - - @override - Widget build(BuildContext context) { - final theme = Theme.of(context); - - return ClipPath( - clipper: AutonomyButtonClipper(), - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: enabled ? color : color.withOpacity(0.6), - disabledForegroundColor: color.withOpacity(0.38), - disabledBackgroundColor: color.withOpacity(0.12), - surfaceTintColor: Colors.transparent, - shadowColor: Colors.transparent, - shape: const RoundedRectangleBorder(), - splashFactory: - enabled ? InkRipple.splashFactory : NoSplash.splashFactory, - padding: const EdgeInsets.symmetric(vertical: 14)), - onPressed: enabled ? onPress : () {}, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - if (isProcessing) - Container( - height: 14, - width: 14, - margin: const EdgeInsets.only(right: 8), - child: CircularProgressIndicator( - color: theme.colorScheme.primary, - backgroundColor: theme.colorScheme.surface, - strokeWidth: 2, - ), - ) - else - const SizedBox(), - if (icon != null) - Container(margin: const EdgeInsets.only(right: 8), child: icon) - else - const SizedBox(), - Text( - text, - style: textStyle ?? theme.primaryTextTheme.labelLarge, - textAlign: textAlign, - ), - ], - ), - ), - ); - } -} diff --git a/lib/view/au_radio_button.dart b/lib/view/au_radio_button.dart index c128f13d2..9bd3dfab7 100644 --- a/lib/view/au_radio_button.dart +++ b/lib/view/au_radio_button.dart @@ -15,32 +15,30 @@ class AuRadio extends StatelessWidget { final Color? color; const AuRadio({ - Key? key, required this.onTap, required this.value, required this.groupValue, + super.key, this.color, - }) : super(key: key); + }); @override - Widget build(BuildContext context) { - return GestureDetector( - onTap: () { - onTap(value); - }, - child: (value == groupValue) - ? SvgPicture.asset( - 'assets/images/radio_true.svg', - colorFilter: color != null - ? ColorFilter.mode(color!, BlendMode.srcIn) - : null, - ) - : SvgPicture.asset( - 'assets/images/radio_false.svg', - colorFilter: color != null - ? ColorFilter.mode(color!, BlendMode.srcIn) - : null, - ), - ); - } + Widget build(BuildContext context) => GestureDetector( + onTap: () { + onTap(value); + }, + child: (value == groupValue) + ? SvgPicture.asset( + 'assets/images/radio_true.svg', + colorFilter: color != null + ? ColorFilter.mode(color!, BlendMode.srcIn) + : null, + ) + : SvgPicture.asset( + 'assets/images/radio_false.svg', + colorFilter: color != null + ? ColorFilter.mode(color!, BlendMode.srcIn) + : null, + ), + ); } diff --git a/lib/view/carousel.dart b/lib/view/carousel.dart deleted file mode 100644 index 732de3321..000000000 --- a/lib/view/carousel.dart +++ /dev/null @@ -1,78 +0,0 @@ -// -// SPDX-License-Identifier: BSD-2-Clause-Patent -// Copyright © 2022 Bitmark. All rights reserved. -// Use of this source code is governed by the BSD-2-Clause Plus Patent License -// that can be found in the LICENSE file. -// - -import 'dart:async'; - -import 'package:carousel_slider/carousel_slider.dart'; -import 'package:flutter/material.dart'; - -class CarouselWithIndicator extends StatefulWidget { - final List items; - - const CarouselWithIndicator({required this.items, super.key}); - - @override - State createState() => _CarouselWithIndicatorState(); -} - -class _CarouselWithIndicatorState extends State { - int _current = 0; - final CarouselSliderController _controller = CarouselSliderController(); - - @override - Widget build(BuildContext context) { - if (widget.items.isEmpty) { - return Container(); - } - if (widget.items.length == 1) { - return Padding( - padding: const EdgeInsets.fromLTRB(16, 0, 16, 20), - child: widget.items[0], - ); - } - return Column(children: [ - CarouselSlider( - items: widget.items - .map((e) => Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), child: e)) - .toList(), - carouselController: _controller, - options: CarouselOptions( - aspectRatio: 345 / 173, - onPageChanged: (index, reason) { - setState(() { - _current = index; - }); - }, - viewportFraction: 1, - ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: widget.items - .asMap() - .entries - .map((entry) => GestureDetector( - onTap: () => unawaited(_controller.animateToPage(entry.key)), - child: Container( - width: 12, - height: 12, - margin: - const EdgeInsets.symmetric(vertical: 4, horizontal: 4), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: (Theme.of(context).brightness == Brightness.dark - ? Colors.white - : Colors.black) - .withOpacity(_current == entry.key ? 0.9 : 0.4)), - ), - )) - .toList(), - ), - ]); - } -} diff --git a/lib/view/confetti.dart b/lib/view/confetti.dart index a52cabec7..955b5fabc 100644 --- a/lib/view/confetti.dart +++ b/lib/view/confetti.dart @@ -8,9 +8,9 @@ class AllConfettiWidget extends StatefulWidget { final ConfettiController controller; const AllConfettiWidget({ - Key? key, required this.controller, - }) : super(key: key); + super.key, + }); @override State createState() => _AllConfettiWidgetState(); @@ -20,9 +20,7 @@ class _AllConfettiWidgetState extends State { final double blastDirection = -pi / 2; @override - Widget build(BuildContext context) { - return buildConfetti(); - } + Widget build(BuildContext context) => buildConfetti(); Widget buildConfetti() { List moMAColors = [ @@ -45,7 +43,7 @@ class _AllConfettiWidgetState extends State { confettiController: widget.controller, colors: moMAColors, blastDirectionality: BlastDirectionality.explosive, - emissionFrequency: 0.0, + emissionFrequency: 0, numberOfParticles: 50, ), ); diff --git a/lib/view/crypto_view.dart b/lib/view/crypto_view.dart index 5651c3038..f91126135 100644 --- a/lib/view/crypto_view.dart +++ b/lib/view/crypto_view.dart @@ -1,279 +1,6 @@ -import 'package:autonomy_flutter/screen/bloc/scan_wallet/scan_wallet_bloc.dart'; -import 'package:autonomy_flutter/screen/bloc/scan_wallet/scan_wallet_state.dart'; import 'package:autonomy_flutter/util/constants.dart'; -import 'package:autonomy_flutter/util/string_ext.dart'; -import 'package:autonomy_flutter/util/style.dart'; -import 'package:autonomy_flutter/util/wallet_utils.dart'; -import 'package:autonomy_flutter/view/primary_button.dart'; -import 'package:autonomy_flutter/view/radio_check_box.dart'; -import 'package:autonomy_flutter/view/responsive.dart'; -import 'package:collection/collection.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:feralfile_app_theme/feral_file_app_theme.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:libauk_dart/libauk_dart.dart'; - -class AddAddressToWallet extends StatefulWidget { - final List addresses; - final List importedAddress; - final bool scanNext; - final Function(List addesses)? onImport; - final WalletType walletType; - final WalletStorage wallet; - final Function? onSkip; - - const AddAddressToWallet( - {required this.addresses, - required this.importedAddress, - required this.walletType, - required this.wallet, - super.key, - this.scanNext = true, - this.onImport, - this.onSkip}); - - @override - State createState() => _AddAddressToWalletState(); -} - -class _AddAddressToWalletState extends State { - List addresses = []; - List selectedAddresses = []; - int index = 0; - - @override - void initState() { - super.initState(); - addresses = widget.addresses; - if (addresses.isEmpty) { - _callBloc(false); - } - } - - @override - void dispose() { - addresses = []; - super.dispose(); - } - - @override - Widget build(BuildContext context) { - final theme = Theme.of(context); - return BlocConsumer( - listener: (context, scanState) { - if (scanState.addresses.isNotEmpty && !scanState.isScanning) { - setState(() { - addresses = scanState.addresses; - }); - } - }, builder: (context, scanState) { - final scanningNext = addresses.isNotEmpty && scanState.isScanning; - return Padding( - padding: const EdgeInsets.symmetric(vertical: 32), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: ResponsiveLayout.pageHorizontalEdgeInsets, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('select_addresses'.tr(), - style: theme.primaryTextTheme.ppMori700White24), - const SizedBox(height: 40), - Text( - 'choose_addresses'.tr(), - style: theme.textTheme.ppMori400White14, - ), - ], - ), - ), - const SizedBox(height: 20), - Expanded( - child: addresses.isEmpty && scanState.isScanning - ? Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image.asset( - 'assets/images/loading_white_tran.gif', - height: 52, - ), - const SizedBox(height: 20), - Text( - 'h_loading...'.tr(), - style: theme.textTheme.ppMori400White14, - ) - ], - ), - ) - : SingleChildScrollView( - child: Column( - children: addresses - .map((address) => [ - _addressOption( - addressInfo: address, - isImported: widget.importedAddress - .contains(address.address)), - addDivider(height: 1, color: AppColor.white), - ]) - .flattened - .toList(), - ), - ), - ), - Padding( - padding: ResponsiveLayout.pageHorizontalEdgeInsets, - child: Column(children: [ - if (widget.scanNext && addresses.isNotEmpty) ...[ - OutlineButton( - enabled: !scanState.isScanning, - isProcessing: scanningNext, - text: scanningNext - ? 'scanning_addresses'.tr() - : 'scan_next'.tr(), - onTap: () { - _callBloc(true); - }, - ), - const SizedBox(height: 10), - ], - PrimaryButton( - text: 'select'.tr(), - onTap: selectedAddresses.isNotEmpty - ? () { - widget.onImport?.call(selectedAddresses); - Navigator.pop(context); - } - : null, - ), - if (widget.onSkip != null) ...[ - const SizedBox(height: 10), - OutlineButton( - text: 'skip'.tr(), - onTap: () { - widget.onSkip?.call(); - }, - ), - ] - ]), - ) - ], - ), - ); - }); - } - - void _callBloc(bool isAdd) { - switch (widget.walletType) { - case WalletType.Ethereum: - context.read().add(ScanEthereumWalletEvent( - wallet: widget.wallet, startIndex: index, isAdd: isAdd)); - break; - case WalletType.Tezos: - context.read().add(ScanTezosWalletEvent( - wallet: widget.wallet, startIndex: index, isAdd: isAdd)); - break; - default: - context.read().add(ScanEthereumWalletEvent( - wallet: widget.wallet, startIndex: index, isAdd: isAdd)); - - context.read().add(ScanTezosWalletEvent( - wallet: widget.wallet, startIndex: index, isAdd: isAdd)); - } - index += 5; - } - - Widget _addressOption( - {required AddressInfo addressInfo, bool isImported = false}) { - final theme = Theme.of(context); - final color = isImported ? AppColor.disabledColor : AppColor.white; - return Padding( - padding: const EdgeInsets.all(15), - child: GestureDetector( - onTap: isImported - ? null - : () { - setState(() { - if (selectedAddresses.contains(addressInfo)) { - selectedAddresses.remove(addressInfo); - } else { - selectedAddresses.add(addressInfo); - } - }); - }, - child: DecoratedBox( - decoration: const BoxDecoration(color: Colors.transparent), - child: Row( - children: [ - LogoCrypto( - cryptoType: addressInfo.getCryptoType(), - size: 24, - ), - const SizedBox(width: 34), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - addressInfo.getCryptoType().source, - style: theme.textTheme.ppMori400White14.copyWith( - color: color, - ), - ), - Text(addressInfo.address.maskOnly(5), - style: theme.textTheme.ppMori400White14.copyWith( - color: color, - ), - overflow: TextOverflow.ellipsis), - ], - ), - const Spacer(), - if (isImported) - ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.transparent, - shadowColor: Colors.transparent, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(25), - ), - side: const BorderSide( - color: AppColor.disabledColor, - ), - alignment: Alignment.center, - ), - onPressed: () {}, - child: Text( - 'imported_'.tr(), - style: theme.textTheme.ppMori400White14.copyWith( - color: AppColor.disabledColor, - ), - ), - ) - else - Row( - children: [ - Text( - addressInfo.getBalance(), - style: theme.textTheme.ppMori400White14 - .copyWith(color: color), - ), - const SizedBox(width: 20), - RadioSelectAddress( - isChecked: selectedAddresses.contains(addressInfo), - checkColor: AppColor.white, - borderColor: AppColor.white, - ), - ], - ) - ], - ), - ), - ), - ); - } -} class LogoCrypto extends StatelessWidget { final CryptoType? cryptoType; diff --git a/lib/view/dot_loading_indicator.dart b/lib/view/dot_loading_indicator.dart deleted file mode 100644 index ebbf76427..000000000 --- a/lib/view/dot_loading_indicator.dart +++ /dev/null @@ -1,82 +0,0 @@ -import 'dart:async'; - -import 'package:collection/collection.dart'; -import 'package:flutter/material.dart'; - -class DotsLoading extends StatefulWidget { - final int numberOfDots; - final Widget Function()? activeDotBuilder; - final Widget Function()? inactiveDotBuilder; - final double innerPadding; - - const DotsLoading( - {super.key, - this.numberOfDots = 3, - this.activeDotBuilder, - this.inactiveDotBuilder, - this.innerPadding = 2.0}); - - @override - State createState() => _DotsLoadingState(); -} - -class _DotsLoadingState extends State { - late Timer? _timer; - final _duration = const Duration(milliseconds: 500); - late int _selected; - - @override - void initState() { - _selected = 0; - _timer = Timer.periodic(_duration, (timer) { - setState(() { - _selected = (_selected + 1) % widget.numberOfDots; - }); - }); - super.initState(); - } - - @override - void dispose() { - _timer?.cancel(); - super.dispose(); - } - - Widget _selectedDefaultLoadingDot() { - return Container( - width: 3, - height: 3, - decoration: const BoxDecoration( - color: Colors.black, - ), - ); - } - - Widget _unselectedDefaultLoadingDot() { - return Container( - width: 3, - height: 3, - decoration: const BoxDecoration( - color: Colors.white, - ), - ); - } - - @override - Widget build(BuildContext context) { - return Row( - children: List.generate(widget.numberOfDots, (index) { - return [ - (index == _selected) - ? (widget.activeDotBuilder?.call() ?? - _selectedDefaultLoadingDot()) - : (widget.inactiveDotBuilder?.call() ?? - _unselectedDefaultLoadingDot()), - (index != widget.numberOfDots - 1) - ? SizedBox(width: widget.innerPadding) - : null - ]; - }).flattened.whereNotNull().toList(), - ); - } -} diff --git a/lib/view/how_it_works_view.dart b/lib/view/how_it_works_view.dart deleted file mode 100644 index 2ae665514..000000000 --- a/lib/view/how_it_works_view.dart +++ /dev/null @@ -1,45 +0,0 @@ -import 'package:autonomy_flutter/view/postcard_explain.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:feralfile_app_theme/feral_file_app_theme.dart'; -import 'package:flutter/material.dart'; - -class HowItWorksView extends StatelessWidget { - final int counter; - - const HowItWorksView({required this.counter, super.key}); - - @override - Widget build(BuildContext context) { - const textColor = AppColor.white; - const dividerColor = AppColor.primaryBlack; - const backgroundColor = AppColor.auGreyBackground; - final theme = Theme.of(context); - return DecoratedBox( - decoration: BoxDecoration( - color: backgroundColor, - borderRadius: BorderRadius.circular(10), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.fromLTRB(15, 15, 15, 15), - child: Text( - 'how_it_works'.tr(), - style: theme.textTheme.ppMori700Black14.copyWith( - color: textColor, - ), - ), - ), - PostcardExplainView( - textColor: textColor, - backgroundColor: backgroundColor, - dividerColor: dividerColor, - counter: counter, - ), - const SizedBox(height: 10), - ], - ), - ); - } -} diff --git a/lib/view/jumping_dot.dart b/lib/view/jumping_dot.dart deleted file mode 100644 index 41733f0e8..000000000 --- a/lib/view/jumping_dot.dart +++ /dev/null @@ -1,125 +0,0 @@ -/// -/// Clone from https://github.com/rezam92/jumping_dot -/// -import 'package:flutter/material.dart'; - -class DotWidget extends StatelessWidget { - final Color? color; - final double? radius; - - const DotWidget({ - Key? key, - @required this.color, - @required this.radius, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - return Container( - decoration: BoxDecoration(shape: BoxShape.circle, color: color), - height: radius, - width: radius, - ); - } -} - -/// Jumping Dot. -/// -/// [numberOfDots] number of dots, -/// [color] color of dots. -/// [radius] radius of dots. -/// [animationDuration] animation duration in milliseconds -class JumpingDots extends StatefulWidget { - final int numberOfDots; - final Color color; - final double radius; - final double innerPadding; - final Duration animationDuration; - - const JumpingDots({ - Key? key, - this.numberOfDots = 3, - this.radius = 10, - this.innerPadding = 1.2, - this.animationDuration = const Duration(milliseconds: 500), - this.color = const Color(0xfff2c300), - }) : super(key: key); - - @override - State createState() => _JumpingDotsState(); -} - -class _JumpingDotsState extends State - with TickerProviderStateMixin { - List? _animationControllers; - - final List> _animations = []; - - @override - void initState() { - super.initState(); - _initAnimation(); - } - - @override - void dispose() { - for (var controller in _animationControllers!) { - controller.dispose(); - } - super.dispose(); - } - - void _initAnimation() { - _animationControllers = List.generate( - widget.numberOfDots, - (index) { - return AnimationController( - vsync: this, duration: widget.animationDuration); - }, - ).toList(); - - for (int i = 0; i < widget.numberOfDots; i++) { - _animations.add( - Tween(begin: 0, end: -3).animate(_animationControllers![i])); - } - - for (int i = 0; i < widget.numberOfDots; i++) { - _animationControllers![i].addStatusListener((status) { - if (status == AnimationStatus.completed) { - _animationControllers![i].reverse(); - if (i != widget.numberOfDots - 1) { - _animationControllers![i + 1].forward(); - } - } - if (i == widget.numberOfDots - 1 && - status == AnimationStatus.dismissed) { - _animationControllers![0].forward(); - } - }); - } - _animationControllers!.first.forward(); - } - - @override - Widget build(BuildContext context) { - return Directionality( - textDirection: TextDirection.ltr, - child: Row( - children: List.generate(widget.numberOfDots, (index) { - return AnimatedBuilder( - animation: _animationControllers![index], - builder: (context, child) { - return Container( - padding: EdgeInsets.all(widget.innerPadding), - child: Transform.translate( - offset: Offset(0, _animations[index].value), - child: DotWidget(color: widget.color, radius: widget.radius), - ), - ); - }, - ); - }).toList(), - ), - ); - } -} diff --git a/lib/view/modal_widget.dart b/lib/view/modal_widget.dart deleted file mode 100644 index 88b1f99cd..000000000 --- a/lib/view/modal_widget.dart +++ /dev/null @@ -1,41 +0,0 @@ -// -// SPDX-License-Identifier: BSD-2-Clause-Patent -// Copyright © 2022 Bitmark. All rights reserved. -// Use of this source code is governed by the BSD-2-Clause Plus Patent License -// that can be found in the LICENSE file. -// - -import 'package:autonomy_flutter/util/au_icons.dart'; -import 'package:feralfile_app_theme/feral_file_app_theme.dart'; -import 'package:flutter/material.dart'; - -class ModalSheet extends StatelessWidget { - final Widget child; - - const ModalSheet({required this.child, super.key}); - - @override - Widget build(BuildContext context) => Container( - color: AppColor.feralFileHighlight, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Align( - alignment: Alignment.centerRight, - child: IconButton( - onPressed: () => Navigator.pop(context), - icon: const Icon( - AuIcon.close, - size: 18, - ), - ), - ), - const SizedBox(height: 32), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: child, - ), - ], - ), - ); -} diff --git a/lib/view/postcard_button.dart b/lib/view/postcard_button.dart index fb332b124..b87297e29 100644 --- a/lib/view/postcard_button.dart +++ b/lib/view/postcard_button.dart @@ -96,75 +96,6 @@ class PostcardButton extends StatelessWidget { } } -class PostcardCustomButton extends StatelessWidget { - final Function()? onTap; - final Color? color; - final double? width; - final bool isProcessing; - final bool enabled; - final Widget child; - final Color? disableColor; - - const PostcardCustomButton({ - required this.child, - super.key, - this.onTap, - this.color, - this.width, - this.enabled = true, - this.isProcessing = false, - this.disableColor, - }); - - @override - Widget build(BuildContext context) { - final theme = Theme.of(context); - const defaultActiveColor = Colors.amber; - const defaultDisabledColor = AppColor.disabledColor; - return SizedBox( - width: width, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: enabled - ? color ?? defaultActiveColor - : disableColor ?? defaultDisabledColor, - shadowColor: Colors.transparent, - disabledForegroundColor: disableColor ?? defaultDisabledColor, - disabledBackgroundColor: disableColor ?? defaultDisabledColor, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(0), - ), - ), - onPressed: enabled ? onTap : null, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 14), - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - if (isProcessing) - Container( - height: 14, - width: 14, - margin: const EdgeInsets.only(right: 8), - child: CircularProgressIndicator( - color: theme.colorScheme.primary, - backgroundColor: theme.colorScheme.surface, - strokeWidth: 2, - ), - ) - else - const SizedBox(), - child, - ], - ), - ), - ), - ), - ); - } -} - class PostcardOutlineButton extends StatelessWidget { final Function()? onTap; final Color? color; diff --git a/lib/view/postcard_explain.dart b/lib/view/postcard_explain.dart deleted file mode 100644 index d19c75728..000000000 --- a/lib/view/postcard_explain.dart +++ /dev/null @@ -1,127 +0,0 @@ -import 'package:autonomy_flutter/util/constants.dart'; -import 'package:autonomy_flutter/util/style.dart'; -import 'package:collection/collection.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:feralfile_app_theme/feral_file_app_theme.dart'; -import 'package:flutter/material.dart'; - -class PostcardExplainView extends StatelessWidget { - final Color? textColor; - final Color? dividerColor; - final Color? backgroundColor; - final int counter; - final String message; - - const PostcardExplainView( - {required this.counter, - super.key, - this.message = '', - this.textColor = AppColor.primaryBlack, - this.backgroundColor = AppColor.white, - this.dividerColor = AppColor.auGrey}); - - Widget _explainRow(BuildContext context, String title, String content) { - final theme = Theme.of(context); - return Padding( - padding: const EdgeInsets.symmetric(vertical: 13), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - title, - style: theme.textTheme.ppMori400Black14.copyWith(color: textColor), - ), - const SizedBox(width: 60), - Expanded( - child: Text( - content, - style: - theme.textTheme.ppMori400Black14.copyWith(color: textColor), - overflow: TextOverflow.visible, - maxLines: 4, - ), - ), - ], - ), - ); - } - - List postcardExplainTexts(int counter) { - if (counter == 0) { - return [ - 'mint_your_postcard'.tr(), - 'design_your_MoMA_stamp'.tr(), - 'sign_your_stamp'.tr(), - 'add_your_stamp'.tr(), - 'send_the_postcard'.tr(), - 'the_distance_traveled_between'.tr(), - 'each_receiver_adds_then_sends'.tr(), - 'your_postcard_journey_ends'.tr(), - 'the_postcard_win'.tr(), - ]; - } else if (counter == MAX_STAMP_IN_POSTCARD - 1) { - return [ - 'accept_your_postcard'.tr(), - 'design_your_MoMA_stamp'.tr(), - 'sign_your_stamp'.tr(), - 'add_your_stamp'.tr(), - 'complete_postcard_journey'.tr(), - 'the_distance_traveled_all'.tr(), - 'the_postcard_win'.tr(), - ]; - } else { - return [ - 'accept_your_postcard'.tr(), - 'design_your_MoMA_stamp'.tr(), - 'sign_your_stamp'.tr(), - 'add_your_stamp'.tr(), - 'send_the_postcard'.tr(), - 'the_distance_traveled_between'.tr(), - 'each_receiver_adds_then_sends'.tr(), - 'your_postcard_journey_ends'.tr(), - 'the_postcard_win'.tr(), - ]; - } - } - - @override - Widget build(BuildContext context) { - final theme = Theme.of(context); - final explainTexts = postcardExplainTexts(counter); - return Container( - padding: const EdgeInsets.symmetric(horizontal: 15), - color: backgroundColor, - child: Column( - children: [ - if (message.isNotEmpty) - Row( - children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.only(top: 15), - child: Text( - message, - style: theme.textTheme.ppMori400Black14, - maxLines: 4, - overflow: TextOverflow.ellipsis, - ), - ), - ), - ], - ), - ...explainTexts - .mapIndexed((index, text) => [ - _explainRow( - context, - '${index + 1}', - text.tr(), - ), - if (index != explainTexts.length - 1) - addOnlyDivider(color: dividerColor) - ]) - .flattened - ], - ), - ); - } -} diff --git a/lib/view/stream_common_widget.dart b/lib/view/stream_common_widget.dart index 036e7d655..23904dbf0 100644 --- a/lib/view/stream_common_widget.dart +++ b/lib/view/stream_common_widget.dart @@ -16,10 +16,6 @@ import 'package:flutter_svg/svg.dart'; import 'package:rxdart/rxdart.dart'; final speedValues = { - // '5sec': const Duration(seconds: 5), - // '10sec': const Duration(seconds: 10), - // '15sec': const Duration(seconds: 15), - // '30sec': const Duration(seconds: 30), '1min': const Duration(minutes: 1), '2min': const Duration(minutes: 2), '5min': const Duration(minutes: 5), @@ -191,7 +187,6 @@ class _PlaylistControlState extends State { ); Widget _buildPlayControls(BuildContext context, CanvasDeviceState state) { - final isCasting = _controllingDevice != null; final isPlaying = state.devices .firstWhereOrNull( (e) => e.device.deviceId == _controllingDevice?.deviceId) @@ -276,7 +271,6 @@ class _PlaylistControlState extends State { void onPauseOrResume(BuildContext context) { // final _canvasDeviceBloc = context.read(); - final isCasting = _controllingDevice != null; final isPlaying = _canvasDeviceBloc.state.devices .firstWhereOrNull( (e) => e.device.deviceId == _controllingDevice?.deviceId) diff --git a/lib/view/text_shuffler.dart b/lib/view/text_shuffler.dart deleted file mode 100644 index c8826c48c..000000000 --- a/lib/view/text_shuffler.dart +++ /dev/null @@ -1,128 +0,0 @@ -// -// SPDX-License-Identifier: BSD-2-Clause-Patent -// Copyright © 2022 Bitmark. All rights reserved. -// Use of this source code is governed by the BSD-2-Clause Plus Patent License -// that can be found in the LICENSE file. -// - -import 'dart:async'; -import 'dart:math'; - -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -class TextShuffler extends StatefulWidget { - final String text; - final TextStyle? style; - const TextShuffler({Key? key, required this.text, required this.style}) - : super(key: key); - - @override - State createState() => _TextShufflerState(); -} - -enum ShufflerStep { dashes, filling, finalizing, finished } - -class _TextShufflerState extends State { - String _targetText = ''; - int _targetTextLength = 0; - String _currentText = ''; - int _numberOfInitialDashes = 0; - ShufflerStep _step = ShufflerStep.dashes; - final characters = - "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890!@#\$%^&*-="; - final Random _rnd = Random(); - Timer? _timer; - - @override - void initState() { - _targetText = widget.text; - _targetTextLength = _targetText.length; - _numberOfInitialDashes = (_targetTextLength * 0.25).round(); - _shuffle(); - - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Text( - _currentText, - style: widget.style, - ); - } - - @override - void dispose() { - _timer?.cancel(); - super.dispose(); - } - - void _shuffle() { - _timer = Timer.periodic( - Duration(milliseconds: ((250) / _targetTextLength).round()), (timer) { - late String updatedText; - switch (_step) { - case ShufflerStep.dashes: - updatedText = _addDashes(); - break; - - case ShufflerStep.filling: - updatedText = _fillRandomPositions(); - break; - - case ShufflerStep.finalizing: - updatedText = _finalizeRandomPositions(); - break; - - case ShufflerStep.finished: - timer.cancel(); - return; - - default: - return; - } - setState(() { - _currentText = updatedText; - }); - }); - } - - String _addDashes() { - if (_currentText.length >= _numberOfInitialDashes) { - _step = ShufflerStep.filling; - return _currentText; - } - - return "$_currentText-"; - } - - String _fillRandomPositions() { - if (_currentText.length < _targetTextLength) { - final randChar = _randomCharacter(); - final randIndex = _rnd.nextInt(_currentText.length); - return _currentText.replaceRange(randIndex, randIndex + 1, - randChar + _currentText[randIndex]); // insert - } else { - _step = ShufflerStep.finalizing; - return _currentText; - } - } - - String _finalizeRandomPositions() { - if (_currentText == _targetText) { - _step = ShufflerStep.finished; - return _currentText; - } - - final randIndex = _rnd.nextInt(_currentText.length); - if (_currentText[randIndex] == _targetText[randIndex]) { - return _finalizeRandomPositions(); - } - - return _currentText.replaceRange( - randIndex, randIndex + 1, _targetText[randIndex]); // repace - } - - String _randomCharacter() => characters[_rnd.nextInt(characters.length)]; -} diff --git a/lib/view/tip_card.dart b/lib/view/tip_card.dart deleted file mode 100644 index 46e783518..000000000 --- a/lib/view/tip_card.dart +++ /dev/null @@ -1,82 +0,0 @@ -import 'package:autonomy_flutter/view/primary_button.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:feralfile_app_theme/feral_file_app_theme.dart'; -import 'package:flutter/material.dart'; - -class Tipcard extends StatelessWidget { - final String titleText; - final Function()? onPressed; - final Function()? onClosed; - final String? buttonText; - final Widget content; - final ValueNotifier listener; - - const Tipcard({ - required this.titleText, - required this.content, - required this.listener, - super.key, - this.onPressed, - this.buttonText, - this.onClosed, - }); - - @override - Widget build(BuildContext context) { - final theme = Theme.of(context); - - return ValueListenableBuilder( - valueListenable: listener, - builder: (context, value, Widget? child) => value - ? Container( - padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 15), - decoration: BoxDecoration( - color: AppColor.feralFileHighlight, - borderRadius: BorderRadius.circular(10), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text(titleText, style: theme.textTheme.ppMori700Black14), - const Spacer(), - IconButton( - padding: EdgeInsets.zero, - constraints: - const BoxConstraints(minWidth: 16, minHeight: 16), - icon: const Icon( - Icons.close, - ), - color: AppColor.primaryBlack, - onPressed: () { - if (onClosed != null) { - onClosed!(); - } - listener.value = false; - }, - ), - ], - ), - const SizedBox(height: 15), - content, - if (buttonText != null || onPressed != null) ...[ - const SizedBox(height: 15), - OutlineButton( - color: AppColor.feralFileHighlight, - textColor: AppColor.primaryBlack, - borderColor: AppColor.primaryBlack, - text: buttonText ?? 'close'.tr(), - onTap: () { - () {}; - listener.value = false; - }), - ] - ], - ), - ) - : const SizedBox(), - ); - } -} diff --git a/lib/view/transparent_router.dart b/lib/view/transparent_router.dart index 268c002c1..755349b2e 100644 --- a/lib/view/transparent_router.dart +++ b/lib/view/transparent_router.dart @@ -6,8 +6,8 @@ class TransparentRoute extends PageRoute { TransparentRoute({ required this.builder, this.color = Colors.transparent, - RouteSettings? settings, - }) : super(settings: settings, fullscreenDialog: false); + super.settings, + }) : super(fullscreenDialog: false); final WidgetBuilder builder; From f3ba33dd8a2624f22f7f509a77a936a287e7a3ed Mon Sep 17 00:00:00 2001 From: PuPha Date: Thu, 5 Sep 2024 14:23:52 +0700 Subject: [PATCH 11/12] Remove unused code --- lib/common/environment.dart | 2 -- lib/gateway/pubdoc_api.dart | 9 --------- lib/model/suggested_artist.dart | 26 -------------------------- 3 files changed, 37 deletions(-) delete mode 100644 lib/model/suggested_artist.dart diff --git a/lib/common/environment.dart b/lib/common/environment.dart index 951578a4d..6634bdf71 100644 --- a/lib/common/environment.dart +++ b/lib/common/environment.dart @@ -101,8 +101,6 @@ class Environment { static String get autonomyAuthURL => dotenv.env['AUTONOMY_AUTH_URL'] ?? ''; - static String get feedURL => dotenv.env['FEED_URL'] ?? ''; - static String get customerSupportURL => dotenv.env['CUSTOMER_SUPPORT_URL'] ?? ''; diff --git a/lib/gateway/pubdoc_api.dart b/lib/gateway/pubdoc_api.dart index 8a0e37b90..3d90c2723 100644 --- a/lib/gateway/pubdoc_api.dart +++ b/lib/gateway/pubdoc_api.dart @@ -8,7 +8,6 @@ import 'dart:convert'; import 'package:autonomy_flutter/model/play_list_model.dart'; -import 'package:autonomy_flutter/model/suggested_artist.dart'; import 'package:autonomy_flutter/model/version_info.dart'; import 'package:dio/dio.dart'; import 'package:retrofit/retrofit.dart'; @@ -48,12 +47,4 @@ extension PubdocAPIHelpers on PubdocAPI { .toList(); return list ?? []; } - - Future> getSuggestedArtistsFromGithub() async { - final value = await getSuggestedArtists(); - final list = (jsonDecode(value) as List?) - ?.map((element) => SuggestedArtist.fromJson(element)) - .toList(); - return list ?? []; - } } diff --git a/lib/model/suggested_artist.dart b/lib/model/suggested_artist.dart deleted file mode 100644 index 2312729ff..000000000 --- a/lib/model/suggested_artist.dart +++ /dev/null @@ -1,26 +0,0 @@ -class SuggestedArtist { - String address; - String name; - String blockchain; - String domain; - List tokenIDs; - - SuggestedArtist({ - required this.address, - required this.name, - required this.blockchain, - required this.domain, - required this.tokenIDs, - }); - - // fromJson - factory SuggestedArtist.fromJson(Map map) { - return SuggestedArtist( - address: map['address'] as String, - name: map['name'] as String, - blockchain: map['blockchain'] as String, - domain: map['domain'] as String, - tokenIDs: List.from((map['tokenIDs'] as List)), - ); - } -} From d792f994be69c1b1703ba96546aa09c8abd3080b Mon Sep 17 00:00:00 2001 From: PuPha Date: Mon, 9 Sep 2024 09:44:58 +0700 Subject: [PATCH 12/12] Lazy Restore --- lib/screen/onboarding_page.dart | 35 +++++++++++++++++++++++++++++++- lib/service/account_service.dart | 25 +++++++++++++++++++++-- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/lib/screen/onboarding_page.dart b/lib/screen/onboarding_page.dart index 6d4bb2173..5f7acdd78 100644 --- a/lib/screen/onboarding_page.dart +++ b/lib/screen/onboarding_page.dart @@ -10,10 +10,12 @@ import 'dart:async'; import 'package:autonomy_flutter/common/injector.dart'; import 'package:autonomy_flutter/screen/app_router.dart'; import 'package:autonomy_flutter/service/account_service.dart'; +import 'package:autonomy_flutter/service/address_service.dart'; import 'package:autonomy_flutter/service/configuration_service.dart'; import 'package:autonomy_flutter/service/deeplink_service.dart'; import 'package:autonomy_flutter/service/metric_client_service.dart'; import 'package:autonomy_flutter/util/log.dart'; +import 'package:autonomy_flutter/util/wallet_utils.dart'; import 'package:autonomy_flutter/view/back_appbar.dart'; import 'package:autonomy_flutter/view/primary_button.dart'; import 'package:autonomy_flutter/view/responsive.dart'; @@ -71,8 +73,39 @@ class _OnboardingPageState extends State } } + /* + - When user did onboarded: + Case 1: user kill app and reopen, we will have restore in background: + Restore mean that we need sync data from keychain and cloud database (that modified in other device) + In this case, we will restore from keychain and cloud in background. + We have to force update because we need to make sure that we have the latest data from cloud + + - When user did not onboarded: we will check if user has primary address in keychain + Case 2: Primary Address not found: new user, create default persona: + + Case 3: Primary address found: user has backup, we will wait until restore from cloud + */ Future _createAccountOrRestoreIfNeeded() async { - await injector().restoreIfNeeded(); + final isDoneOnboarding = + injector().isDoneNewOnboarding(); + if (isDoneOnboarding) { + // existing user + // do this in background, don't await restore + unawaited(injector().restore()); + } else { + final primaryAddress = + await injector().getPrimaryAddress(); + if (primaryAddress == null) { + // new user + final persona = await injector().createDefaultPersona(); + await persona.insertNextAddress(WalletType.Tezos); + await persona.insertNextAddress(WalletType.Ethereum); + } else { + // restore user + // in this case, we have to wait until restore is done + await injector().restoreIfNeeded(); + } + } if (!mounted) { return; } diff --git a/lib/service/account_service.dart b/lib/service/account_service.dart index 9e3890976..182546dce 100644 --- a/lib/service/account_service.dart +++ b/lib/service/account_service.dart @@ -5,6 +5,8 @@ // that can be found in the LICENSE file. // +// ignore_for_file: lines_longer_than_80_chars + import 'dart:async'; import 'dart:io'; @@ -113,6 +115,10 @@ abstract class AccountService { Future updateAddressPersona(WalletAddress walletAddress); + Future> restore(); + + Future createDefaultPersona(); + Future restoreIfNeeded(); Future> getAllViewOnlyAddresses(); @@ -724,13 +730,19 @@ class AccountServiceImpl extends AccountService { } @override - Future restoreIfNeeded() async { - final iapService = injector(); + Future> restore() async { final auditService = injector(); final migrationUtil = MigrationUtil(_cloudDB, auditService); await androidRestoreKeys(); await migrationUtil.migrationFromKeychain(); final personas = await _cloudDB.personaDao.getPersonas(); + return personas; + } + + @override + Future restoreIfNeeded() async { + await restore(); + final personas = await _cloudDB.personaDao.getPersonas(); final hasPersona = personas.isNotEmpty; if (!hasPersona) { @@ -793,9 +805,18 @@ class AccountServiceImpl extends AccountService { .initIfDefaultAccount()); } + final iapService = injector(); unawaited(iapService.restore()); } + @override + Future createDefaultPersona() async { + final persona = await createPersona(isDefault: true); + await persona.insertNextAddress(WalletType.Tezos); + await persona.insertNextAddress(WalletType.Ethereum); + return persona; + } + @override Future getAddressPersona(String address) async => await _cloudDB.addressDao.findByAddress(address);