diff --git a/assets/i18n/en-US.json b/assets/i18n/en-US.json index 8cc8880..c69f786 100644 --- a/assets/i18n/en-US.json +++ b/assets/i18n/en-US.json @@ -206,5 +206,11 @@ "developerBadgeName": "Developer", "developerBadgeDescription": "Contributing to Solar Network's development", "translatorBadgeName": "Translator", - "translatorBadgeDescription": "Helping translate Solar Network into different languages" + "translatorBadgeDescription": "Helping translate Solar Network into different languages", + "wallet": "Wallet", + "walletCurrencyPoints": "New Solar Points", + "walletCurrencyShortPoints": "NSP", + "walletCurrencyGolds": "The Solar Dollars", + "walletCurrencyShortGolds": "TSD", + "retry": "Retry" } diff --git a/lib/models/auth.dart b/lib/models/auth.dart index 84d35f9..5279447 100644 --- a/lib/models/auth.dart +++ b/lib/models/auth.dart @@ -21,7 +21,7 @@ abstract class SnAuthChallenge with _$SnAuthChallenge { required DateTime expiredAt, required int stepRemain, required int stepTotal, - required List blacklistFactors, + required List blacklistFactors, required List audiences, required List scopes, required String ipAddress, diff --git a/lib/models/auth.freezed.dart b/lib/models/auth.freezed.dart index d77304d..6346ce0 100644 --- a/lib/models/auth.freezed.dart +++ b/lib/models/auth.freezed.dart @@ -152,7 +152,7 @@ as String, /// @nodoc mixin _$SnAuthChallenge { - String get id; DateTime get expiredAt; int get stepRemain; int get stepTotal; List get blacklistFactors; List get audiences; List get scopes; String get ipAddress; String get userAgent; String? get deviceId; String? get nonce; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; + String get id; DateTime get expiredAt; int get stepRemain; int get stepTotal; List get blacklistFactors; List get audiences; List get scopes; String get ipAddress; String get userAgent; String? get deviceId; String? get nonce; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; /// Create a copy of SnAuthChallenge /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -185,7 +185,7 @@ abstract mixin class $SnAuthChallengeCopyWith<$Res> { factory $SnAuthChallengeCopyWith(SnAuthChallenge value, $Res Function(SnAuthChallenge) _then) = _$SnAuthChallengeCopyWithImpl; @useResult $Res call({ - String id, DateTime expiredAt, int stepRemain, int stepTotal, List blacklistFactors, List audiences, List scopes, String ipAddress, String userAgent, String? deviceId, String? nonce, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt + String id, DateTime expiredAt, int stepRemain, int stepTotal, List blacklistFactors, List audiences, List scopes, String ipAddress, String userAgent, String? deviceId, String? nonce, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt }); @@ -209,7 +209,7 @@ as String,expiredAt: null == expiredAt ? _self.expiredAt : expiredAt // ignore: as DateTime,stepRemain: null == stepRemain ? _self.stepRemain : stepRemain // ignore: cast_nullable_to_non_nullable as int,stepTotal: null == stepTotal ? _self.stepTotal : stepTotal // ignore: cast_nullable_to_non_nullable as int,blacklistFactors: null == blacklistFactors ? _self.blacklistFactors : blacklistFactors // ignore: cast_nullable_to_non_nullable -as List,audiences: null == audiences ? _self.audiences : audiences // ignore: cast_nullable_to_non_nullable +as List,audiences: null == audiences ? _self.audiences : audiences // ignore: cast_nullable_to_non_nullable as List,scopes: null == scopes ? _self.scopes : scopes // ignore: cast_nullable_to_non_nullable as List,ipAddress: null == ipAddress ? _self.ipAddress : ipAddress // ignore: cast_nullable_to_non_nullable as String,userAgent: null == userAgent ? _self.userAgent : userAgent // ignore: cast_nullable_to_non_nullable @@ -229,15 +229,15 @@ as DateTime?, @JsonSerializable() class _SnAuthChallenge implements SnAuthChallenge { - const _SnAuthChallenge({required this.id, required this.expiredAt, required this.stepRemain, required this.stepTotal, required final List blacklistFactors, required final List audiences, required final List scopes, required this.ipAddress, required this.userAgent, required this.deviceId, required this.nonce, required this.createdAt, required this.updatedAt, required this.deletedAt}): _blacklistFactors = blacklistFactors,_audiences = audiences,_scopes = scopes; + const _SnAuthChallenge({required this.id, required this.expiredAt, required this.stepRemain, required this.stepTotal, required final List blacklistFactors, required final List audiences, required final List scopes, required this.ipAddress, required this.userAgent, required this.deviceId, required this.nonce, required this.createdAt, required this.updatedAt, required this.deletedAt}): _blacklistFactors = blacklistFactors,_audiences = audiences,_scopes = scopes; factory _SnAuthChallenge.fromJson(Map json) => _$SnAuthChallengeFromJson(json); @override final String id; @override final DateTime expiredAt; @override final int stepRemain; @override final int stepTotal; - final List _blacklistFactors; -@override List get blacklistFactors { + final List _blacklistFactors; +@override List get blacklistFactors { if (_blacklistFactors is EqualUnmodifiableListView) return _blacklistFactors; // ignore: implicit_dynamic_type return EqualUnmodifiableListView(_blacklistFactors); @@ -298,7 +298,7 @@ abstract mixin class _$SnAuthChallengeCopyWith<$Res> implements $SnAuthChallenge factory _$SnAuthChallengeCopyWith(_SnAuthChallenge value, $Res Function(_SnAuthChallenge) _then) = __$SnAuthChallengeCopyWithImpl; @override @useResult $Res call({ - String id, DateTime expiredAt, int stepRemain, int stepTotal, List blacklistFactors, List audiences, List scopes, String ipAddress, String userAgent, String? deviceId, String? nonce, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt + String id, DateTime expiredAt, int stepRemain, int stepTotal, List blacklistFactors, List audiences, List scopes, String ipAddress, String userAgent, String? deviceId, String? nonce, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt }); @@ -322,7 +322,7 @@ as String,expiredAt: null == expiredAt ? _self.expiredAt : expiredAt // ignore: as DateTime,stepRemain: null == stepRemain ? _self.stepRemain : stepRemain // ignore: cast_nullable_to_non_nullable as int,stepTotal: null == stepTotal ? _self.stepTotal : stepTotal // ignore: cast_nullable_to_non_nullable as int,blacklistFactors: null == blacklistFactors ? _self._blacklistFactors : blacklistFactors // ignore: cast_nullable_to_non_nullable -as List,audiences: null == audiences ? _self._audiences : audiences // ignore: cast_nullable_to_non_nullable +as List,audiences: null == audiences ? _self._audiences : audiences // ignore: cast_nullable_to_non_nullable as List,scopes: null == scopes ? _self._scopes : scopes // ignore: cast_nullable_to_non_nullable as List,ipAddress: null == ipAddress ? _self.ipAddress : ipAddress // ignore: cast_nullable_to_non_nullable as String,userAgent: null == userAgent ? _self.userAgent : userAgent // ignore: cast_nullable_to_non_nullable diff --git a/lib/models/auth.g.dart b/lib/models/auth.g.dart index cdeeac8..e34d032 100644 --- a/lib/models/auth.g.dart +++ b/lib/models/auth.g.dart @@ -26,7 +26,7 @@ _SnAuthChallenge _$SnAuthChallengeFromJson(Map json) => stepTotal: (json['step_total'] as num).toInt(), blacklistFactors: (json['blacklist_factors'] as List) - .map((e) => (e as num).toInt()) + .map((e) => e as String) .toList(), audiences: (json['audiences'] as List).map((e) => e as String).toList(), diff --git a/lib/models/post.dart b/lib/models/post.dart index 16270a6..86dd64f 100644 --- a/lib/models/post.dart +++ b/lib/models/post.dart @@ -46,7 +46,7 @@ abstract class SnPost with _$SnPost { abstract class SnPublisher with _$SnPublisher { const factory SnPublisher({ required String id, - required int publisherType, + required int type, required String name, required String nick, required String bio, diff --git a/lib/models/post.freezed.dart b/lib/models/post.freezed.dart index 0f16088..9cae9e1 100644 --- a/lib/models/post.freezed.dart +++ b/lib/models/post.freezed.dart @@ -370,7 +370,7 @@ $SnPublisherCopyWith<$Res> get publisher { /// @nodoc mixin _$SnPublisher { - String get id; int get publisherType; String get name; String get nick; String get bio; String? get pictureId; SnCloudFile? get picture; String? get backgroundId; SnCloudFile? get background; String? get accountId; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; + String get id; int get type; String get name; String get nick; String get bio; String? get pictureId; SnCloudFile? get picture; String? get backgroundId; SnCloudFile? get background; String? get accountId; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; /// Create a copy of SnPublisher /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -383,16 +383,16 @@ $SnPublisherCopyWith get copyWith => _$SnPublisherCopyWithImpl Object.hash(runtimeType,id,publisherType,name,nick,bio,pictureId,picture,backgroundId,background,accountId,createdAt,updatedAt,deletedAt); +int get hashCode => Object.hash(runtimeType,id,type,name,nick,bio,pictureId,picture,backgroundId,background,accountId,createdAt,updatedAt,deletedAt); @override String toString() { - return 'SnPublisher(id: $id, publisherType: $publisherType, name: $name, nick: $nick, bio: $bio, pictureId: $pictureId, picture: $picture, backgroundId: $backgroundId, background: $background, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; + return 'SnPublisher(id: $id, type: $type, name: $name, nick: $nick, bio: $bio, pictureId: $pictureId, picture: $picture, backgroundId: $backgroundId, background: $background, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; } @@ -403,7 +403,7 @@ abstract mixin class $SnPublisherCopyWith<$Res> { factory $SnPublisherCopyWith(SnPublisher value, $Res Function(SnPublisher) _then) = _$SnPublisherCopyWithImpl; @useResult $Res call({ - String id, int publisherType, String name, String nick, String bio, String? pictureId, SnCloudFile? picture, String? backgroundId, SnCloudFile? background, String? accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt + String id, int type, String name, String nick, String bio, String? pictureId, SnCloudFile? picture, String? backgroundId, SnCloudFile? background, String? accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt }); @@ -420,10 +420,10 @@ class _$SnPublisherCopyWithImpl<$Res> /// Create a copy of SnPublisher /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? publisherType = null,Object? name = null,Object? nick = null,Object? bio = null,Object? pictureId = freezed,Object? picture = freezed,Object? backgroundId = freezed,Object? background = freezed,Object? accountId = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? type = null,Object? name = null,Object? nick = null,Object? bio = null,Object? pictureId = freezed,Object? picture = freezed,Object? backgroundId = freezed,Object? background = freezed,Object? accountId = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { return _then(_self.copyWith( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable -as String,publisherType: null == publisherType ? _self.publisherType : publisherType // ignore: cast_nullable_to_non_nullable +as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable as int,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable as String,nick: null == nick ? _self.nick : nick // ignore: cast_nullable_to_non_nullable as String,bio: null == bio ? _self.bio : bio // ignore: cast_nullable_to_non_nullable @@ -470,11 +470,11 @@ $SnCloudFileCopyWith<$Res>? get background { @JsonSerializable() class _SnPublisher implements SnPublisher { - const _SnPublisher({required this.id, required this.publisherType, required this.name, required this.nick, required this.bio, required this.pictureId, required this.picture, required this.backgroundId, required this.background, required this.accountId, required this.createdAt, required this.updatedAt, required this.deletedAt}); + const _SnPublisher({required this.id, required this.type, required this.name, required this.nick, required this.bio, required this.pictureId, required this.picture, required this.backgroundId, required this.background, required this.accountId, required this.createdAt, required this.updatedAt, required this.deletedAt}); factory _SnPublisher.fromJson(Map json) => _$SnPublisherFromJson(json); @override final String id; -@override final int publisherType; +@override final int type; @override final String name; @override final String nick; @override final String bio; @@ -500,16 +500,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnPublisher&&(identical(other.id, id) || other.id == id)&&(identical(other.publisherType, publisherType) || other.publisherType == publisherType)&&(identical(other.name, name) || other.name == name)&&(identical(other.nick, nick) || other.nick == nick)&&(identical(other.bio, bio) || other.bio == bio)&&(identical(other.pictureId, pictureId) || other.pictureId == pictureId)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.backgroundId, backgroundId) || other.backgroundId == backgroundId)&&(identical(other.background, background) || other.background == background)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnPublisher&&(identical(other.id, id) || other.id == id)&&(identical(other.type, type) || other.type == type)&&(identical(other.name, name) || other.name == name)&&(identical(other.nick, nick) || other.nick == nick)&&(identical(other.bio, bio) || other.bio == bio)&&(identical(other.pictureId, pictureId) || other.pictureId == pictureId)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.backgroundId, backgroundId) || other.backgroundId == backgroundId)&&(identical(other.background, background) || other.background == background)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,id,publisherType,name,nick,bio,pictureId,picture,backgroundId,background,accountId,createdAt,updatedAt,deletedAt); +int get hashCode => Object.hash(runtimeType,id,type,name,nick,bio,pictureId,picture,backgroundId,background,accountId,createdAt,updatedAt,deletedAt); @override String toString() { - return 'SnPublisher(id: $id, publisherType: $publisherType, name: $name, nick: $nick, bio: $bio, pictureId: $pictureId, picture: $picture, backgroundId: $backgroundId, background: $background, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; + return 'SnPublisher(id: $id, type: $type, name: $name, nick: $nick, bio: $bio, pictureId: $pictureId, picture: $picture, backgroundId: $backgroundId, background: $background, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; } @@ -520,7 +520,7 @@ abstract mixin class _$SnPublisherCopyWith<$Res> implements $SnPublisherCopyWith factory _$SnPublisherCopyWith(_SnPublisher value, $Res Function(_SnPublisher) _then) = __$SnPublisherCopyWithImpl; @override @useResult $Res call({ - String id, int publisherType, String name, String nick, String bio, String? pictureId, SnCloudFile? picture, String? backgroundId, SnCloudFile? background, String? accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt + String id, int type, String name, String nick, String bio, String? pictureId, SnCloudFile? picture, String? backgroundId, SnCloudFile? background, String? accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt }); @@ -537,10 +537,10 @@ class __$SnPublisherCopyWithImpl<$Res> /// Create a copy of SnPublisher /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? publisherType = null,Object? name = null,Object? nick = null,Object? bio = null,Object? pictureId = freezed,Object? picture = freezed,Object? backgroundId = freezed,Object? background = freezed,Object? accountId = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? type = null,Object? name = null,Object? nick = null,Object? bio = null,Object? pictureId = freezed,Object? picture = freezed,Object? backgroundId = freezed,Object? background = freezed,Object? accountId = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { return _then(_SnPublisher( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable -as String,publisherType: null == publisherType ? _self.publisherType : publisherType // ignore: cast_nullable_to_non_nullable +as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable as int,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable as String,nick: null == nick ? _self.nick : nick // ignore: cast_nullable_to_non_nullable as String,bio: null == bio ? _self.bio : bio // ignore: cast_nullable_to_non_nullable diff --git a/lib/models/post.g.dart b/lib/models/post.g.dart index b0f63ee..f8beba5 100644 --- a/lib/models/post.g.dart +++ b/lib/models/post.g.dart @@ -96,7 +96,7 @@ Map _$SnPostToJson(_SnPost instance) => { _SnPublisher _$SnPublisherFromJson(Map json) => _SnPublisher( id: json['id'] as String, - publisherType: (json['publisher_type'] as num).toInt(), + type: (json['type'] as num).toInt(), name: json['name'] as String, nick: json['nick'] as String, bio: json['bio'] as String, @@ -122,7 +122,7 @@ _SnPublisher _$SnPublisherFromJson(Map json) => _SnPublisher( Map _$SnPublisherToJson(_SnPublisher instance) => { 'id': instance.id, - 'publisher_type': instance.publisherType, + 'type': instance.type, 'name': instance.name, 'nick': instance.nick, 'bio': instance.bio, diff --git a/lib/models/wallet.dart b/lib/models/wallet.dart new file mode 100644 index 0000000..69b3dfc --- /dev/null +++ b/lib/models/wallet.dart @@ -0,0 +1,37 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:island/models/user.dart'; + +part 'wallet.freezed.dart'; +part 'wallet.g.dart'; + +@freezed +abstract class SnWallet with _$SnWallet { + const factory SnWallet({ + required String id, + required List pockets, + required String accountId, + required SnAccount? account, + required DateTime createdAt, + required DateTime updatedAt, + required DateTime? deletedAt, + }) = _SnWallet; + + factory SnWallet.fromJson(Map json) => + _$SnWalletFromJson(json); +} + +@freezed +abstract class SnWalletPocket with _$SnWalletPocket { + const factory SnWalletPocket({ + required String id, + required String currency, + required double amount, + required String walletId, + required DateTime createdAt, + required DateTime updatedAt, + required DateTime? deletedAt, + }) = _SnWalletPocket; + + factory SnWalletPocket.fromJson(Map json) => + _$SnWalletPocketFromJson(json); +} diff --git a/lib/models/wallet.freezed.dart b/lib/models/wallet.freezed.dart new file mode 100644 index 0000000..2d3f339 --- /dev/null +++ b/lib/models/wallet.freezed.dart @@ -0,0 +1,347 @@ +// dart format width=80 +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'wallet.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$SnWallet { + + String get id; List get pockets; String get accountId; SnAccount? get account; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; +/// Create a copy of SnWallet +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SnWalletCopyWith get copyWith => _$SnWalletCopyWithImpl(this as SnWallet, _$identity); + + /// Serializes this SnWallet to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SnWallet&&(identical(other.id, id) || other.id == id)&&const DeepCollectionEquality().equals(other.pockets, pockets)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.account, account) || other.account == account)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,const DeepCollectionEquality().hash(pockets),accountId,account,createdAt,updatedAt,deletedAt); + +@override +String toString() { + return 'SnWallet(id: $id, pockets: $pockets, accountId: $accountId, account: $account, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; +} + + +} + +/// @nodoc +abstract mixin class $SnWalletCopyWith<$Res> { + factory $SnWalletCopyWith(SnWallet value, $Res Function(SnWallet) _then) = _$SnWalletCopyWithImpl; +@useResult +$Res call({ + String id, List pockets, String accountId, SnAccount? account, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt +}); + + +$SnAccountCopyWith<$Res>? get account; + +} +/// @nodoc +class _$SnWalletCopyWithImpl<$Res> + implements $SnWalletCopyWith<$Res> { + _$SnWalletCopyWithImpl(this._self, this._then); + + final SnWallet _self; + final $Res Function(SnWallet) _then; + +/// Create a copy of SnWallet +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? pockets = null,Object? accountId = null,Object? account = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { + return _then(_self.copyWith( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,pockets: null == pockets ? _self.pockets : pockets // ignore: cast_nullable_to_non_nullable +as List,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable +as String,account: freezed == account ? _self.account : account // ignore: cast_nullable_to_non_nullable +as SnAccount?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} +/// Create a copy of SnWallet +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SnAccountCopyWith<$Res>? get account { + if (_self.account == null) { + return null; + } + + return $SnAccountCopyWith<$Res>(_self.account!, (value) { + return _then(_self.copyWith(account: value)); + }); +} +} + + +/// @nodoc +@JsonSerializable() + +class _SnWallet implements SnWallet { + const _SnWallet({required this.id, required final List pockets, required this.accountId, required this.account, required this.createdAt, required this.updatedAt, required this.deletedAt}): _pockets = pockets; + factory _SnWallet.fromJson(Map json) => _$SnWalletFromJson(json); + +@override final String id; + final List _pockets; +@override List get pockets { + if (_pockets is EqualUnmodifiableListView) return _pockets; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_pockets); +} + +@override final String accountId; +@override final SnAccount? account; +@override final DateTime createdAt; +@override final DateTime updatedAt; +@override final DateTime? deletedAt; + +/// Create a copy of SnWallet +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SnWalletCopyWith<_SnWallet> get copyWith => __$SnWalletCopyWithImpl<_SnWallet>(this, _$identity); + +@override +Map toJson() { + return _$SnWalletToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnWallet&&(identical(other.id, id) || other.id == id)&&const DeepCollectionEquality().equals(other._pockets, _pockets)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.account, account) || other.account == account)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,const DeepCollectionEquality().hash(_pockets),accountId,account,createdAt,updatedAt,deletedAt); + +@override +String toString() { + return 'SnWallet(id: $id, pockets: $pockets, accountId: $accountId, account: $account, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; +} + + +} + +/// @nodoc +abstract mixin class _$SnWalletCopyWith<$Res> implements $SnWalletCopyWith<$Res> { + factory _$SnWalletCopyWith(_SnWallet value, $Res Function(_SnWallet) _then) = __$SnWalletCopyWithImpl; +@override @useResult +$Res call({ + String id, List pockets, String accountId, SnAccount? account, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt +}); + + +@override $SnAccountCopyWith<$Res>? get account; + +} +/// @nodoc +class __$SnWalletCopyWithImpl<$Res> + implements _$SnWalletCopyWith<$Res> { + __$SnWalletCopyWithImpl(this._self, this._then); + + final _SnWallet _self; + final $Res Function(_SnWallet) _then; + +/// Create a copy of SnWallet +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? pockets = null,Object? accountId = null,Object? account = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { + return _then(_SnWallet( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,pockets: null == pockets ? _self._pockets : pockets // ignore: cast_nullable_to_non_nullable +as List,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable +as String,account: freezed == account ? _self.account : account // ignore: cast_nullable_to_non_nullable +as SnAccount?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + +/// Create a copy of SnWallet +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SnAccountCopyWith<$Res>? get account { + if (_self.account == null) { + return null; + } + + return $SnAccountCopyWith<$Res>(_self.account!, (value) { + return _then(_self.copyWith(account: value)); + }); +} +} + + +/// @nodoc +mixin _$SnWalletPocket { + + String get id; String get currency; double get amount; String get walletId; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; +/// Create a copy of SnWalletPocket +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SnWalletPocketCopyWith get copyWith => _$SnWalletPocketCopyWithImpl(this as SnWalletPocket, _$identity); + + /// Serializes this SnWalletPocket to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SnWalletPocket&&(identical(other.id, id) || other.id == id)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,currency,amount,walletId,createdAt,updatedAt,deletedAt); + +@override +String toString() { + return 'SnWalletPocket(id: $id, currency: $currency, amount: $amount, walletId: $walletId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; +} + + +} + +/// @nodoc +abstract mixin class $SnWalletPocketCopyWith<$Res> { + factory $SnWalletPocketCopyWith(SnWalletPocket value, $Res Function(SnWalletPocket) _then) = _$SnWalletPocketCopyWithImpl; +@useResult +$Res call({ + String id, String currency, double amount, String walletId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt +}); + + + + +} +/// @nodoc +class _$SnWalletPocketCopyWithImpl<$Res> + implements $SnWalletPocketCopyWith<$Res> { + _$SnWalletPocketCopyWithImpl(this._self, this._then); + + final SnWalletPocket _self; + final $Res Function(SnWalletPocket) _then; + +/// Create a copy of SnWalletPocket +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? currency = null,Object? amount = null,Object? walletId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { + return _then(_self.copyWith( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as String,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as double,walletId: null == walletId ? _self.walletId : walletId // ignore: cast_nullable_to_non_nullable +as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + +} + + +/// @nodoc +@JsonSerializable() + +class _SnWalletPocket implements SnWalletPocket { + const _SnWalletPocket({required this.id, required this.currency, required this.amount, required this.walletId, required this.createdAt, required this.updatedAt, required this.deletedAt}); + factory _SnWalletPocket.fromJson(Map json) => _$SnWalletPocketFromJson(json); + +@override final String id; +@override final String currency; +@override final double amount; +@override final String walletId; +@override final DateTime createdAt; +@override final DateTime updatedAt; +@override final DateTime? deletedAt; + +/// Create a copy of SnWalletPocket +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SnWalletPocketCopyWith<_SnWalletPocket> get copyWith => __$SnWalletPocketCopyWithImpl<_SnWalletPocket>(this, _$identity); + +@override +Map toJson() { + return _$SnWalletPocketToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnWalletPocket&&(identical(other.id, id) || other.id == id)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,currency,amount,walletId,createdAt,updatedAt,deletedAt); + +@override +String toString() { + return 'SnWalletPocket(id: $id, currency: $currency, amount: $amount, walletId: $walletId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; +} + + +} + +/// @nodoc +abstract mixin class _$SnWalletPocketCopyWith<$Res> implements $SnWalletPocketCopyWith<$Res> { + factory _$SnWalletPocketCopyWith(_SnWalletPocket value, $Res Function(_SnWalletPocket) _then) = __$SnWalletPocketCopyWithImpl; +@override @useResult +$Res call({ + String id, String currency, double amount, String walletId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt +}); + + + + +} +/// @nodoc +class __$SnWalletPocketCopyWithImpl<$Res> + implements _$SnWalletPocketCopyWith<$Res> { + __$SnWalletPocketCopyWithImpl(this._self, this._then); + + final _SnWalletPocket _self; + final $Res Function(_SnWalletPocket) _then; + +/// Create a copy of SnWalletPocket +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? currency = null,Object? amount = null,Object? walletId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { + return _then(_SnWalletPocket( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as String,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as double,walletId: null == walletId ? _self.walletId : walletId // ignore: cast_nullable_to_non_nullable +as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + + +} + +// dart format on diff --git a/lib/models/wallet.g.dart b/lib/models/wallet.g.dart new file mode 100644 index 0000000..882e14f --- /dev/null +++ b/lib/models/wallet.g.dart @@ -0,0 +1,61 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'wallet.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_SnWallet _$SnWalletFromJson(Map json) => _SnWallet( + id: json['id'] as String, + pockets: + (json['pockets'] as List) + .map((e) => SnWalletPocket.fromJson(e as Map)) + .toList(), + accountId: json['account_id'] as String, + account: + json['account'] == null + ? null + : SnAccount.fromJson(json['account'] as Map), + createdAt: DateTime.parse(json['created_at'] as String), + updatedAt: DateTime.parse(json['updated_at'] as String), + deletedAt: + json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), +); + +Map _$SnWalletToJson(_SnWallet instance) => { + 'id': instance.id, + 'pockets': instance.pockets.map((e) => e.toJson()).toList(), + 'account_id': instance.accountId, + 'account': instance.account?.toJson(), + 'created_at': instance.createdAt.toIso8601String(), + 'updated_at': instance.updatedAt.toIso8601String(), + 'deleted_at': instance.deletedAt?.toIso8601String(), +}; + +_SnWalletPocket _$SnWalletPocketFromJson(Map json) => + _SnWalletPocket( + id: json['id'] as String, + currency: json['currency'] as String, + amount: (json['amount'] as num).toDouble(), + walletId: json['wallet_id'] as String, + createdAt: DateTime.parse(json['created_at'] as String), + updatedAt: DateTime.parse(json['updated_at'] as String), + deletedAt: + json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), + ); + +Map _$SnWalletPocketToJson(_SnWalletPocket instance) => + { + 'id': instance.id, + 'currency': instance.currency, + 'amount': instance.amount, + 'wallet_id': instance.walletId, + 'created_at': instance.createdAt.toIso8601String(), + 'updated_at': instance.updatedAt.toIso8601String(), + 'deleted_at': instance.deletedAt?.toIso8601String(), + }; diff --git a/lib/route.dart b/lib/route.dart index ae272dd..8cb1df7 100644 --- a/lib/route.dart +++ b/lib/route.dart @@ -19,6 +19,7 @@ class AppRouter extends RootStackRouter { AutoRoute(page: ChatListRoute.page, path: 'chat'), ], ), + AutoRoute(page: WalletRoute.page, path: '/wallet'), AutoRoute(page: SettingsRoute.page, path: '/settings'), AutoRoute(page: LoginRoute.page, path: '/auth/login'), AutoRoute(page: CreateAccountRoute.page, path: '/auth/create-account'), diff --git a/lib/route.gr.dart b/lib/route.gr.dart index 7a73320..e15903d 100644 --- a/lib/route.gr.dart +++ b/lib/route.gr.dart @@ -9,9 +9,9 @@ // coverage:ignore-file // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'package:auto_route/auto_route.dart' as _i23; -import 'package:flutter/material.dart' as _i24; -import 'package:island/models/post.dart' as _i25; +import 'package:auto_route/auto_route.dart' as _i24; +import 'package:flutter/material.dart' as _i25; +import 'package:island/models/post.dart' as _i26; import 'package:island/screens/account.dart' as _i2; import 'package:island/screens/account/me.dart' as _i15; import 'package:island/screens/account/me/event_calendar.dart' as _i14; @@ -34,14 +34,15 @@ import 'package:island/screens/posts/pub_profile.dart' as _i18; import 'package:island/screens/realm/detail.dart' as _i19; import 'package:island/screens/realm/realms.dart' as _i9; import 'package:island/screens/settings.dart' as _i20; +import 'package:island/screens/wallet.dart' as _i23; /// generated route for /// [_i1.AccountProfileScreen] -class AccountProfileRoute extends _i23.PageRouteInfo { +class AccountProfileRoute extends _i24.PageRouteInfo { AccountProfileRoute({ - _i24.Key? key, + _i25.Key? key, required String name, - List<_i23.PageRouteInfo>? children, + List<_i24.PageRouteInfo>? children, }) : super( AccountProfileRoute.name, args: AccountProfileRouteArgs(key: key, name: name), @@ -51,7 +52,7 @@ class AccountProfileRoute extends _i23.PageRouteInfo { static const String name = 'AccountProfileRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -67,7 +68,7 @@ class AccountProfileRoute extends _i23.PageRouteInfo { class AccountProfileRouteArgs { const AccountProfileRouteArgs({this.key, required this.name}); - final _i24.Key? key; + final _i25.Key? key; final String name; @@ -79,13 +80,13 @@ class AccountProfileRouteArgs { /// generated route for /// [_i2.AccountScreen] -class AccountRoute extends _i23.PageRouteInfo { - const AccountRoute({List<_i23.PageRouteInfo>? children}) +class AccountRoute extends _i24.PageRouteInfo { + const AccountRoute({List<_i24.PageRouteInfo>? children}) : super(AccountRoute.name, initialChildren: children); static const String name = 'AccountRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { return const _i2.AccountScreen(); @@ -95,11 +96,11 @@ class AccountRoute extends _i23.PageRouteInfo { /// generated route for /// [_i3.ChatDetailScreen] -class ChatDetailRoute extends _i23.PageRouteInfo { +class ChatDetailRoute extends _i24.PageRouteInfo { ChatDetailRoute({ - _i24.Key? key, + _i25.Key? key, required String id, - List<_i23.PageRouteInfo>? children, + List<_i24.PageRouteInfo>? children, }) : super( ChatDetailRoute.name, args: ChatDetailRouteArgs(key: key, id: id), @@ -109,7 +110,7 @@ class ChatDetailRoute extends _i23.PageRouteInfo { static const String name = 'ChatDetailRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -124,7 +125,7 @@ class ChatDetailRoute extends _i23.PageRouteInfo { class ChatDetailRouteArgs { const ChatDetailRouteArgs({this.key, required this.id}); - final _i24.Key? key; + final _i25.Key? key; final String id; @@ -136,13 +137,13 @@ class ChatDetailRouteArgs { /// generated route for /// [_i4.ChatListScreen] -class ChatListRoute extends _i23.PageRouteInfo { - const ChatListRoute({List<_i23.PageRouteInfo>? children}) +class ChatListRoute extends _i24.PageRouteInfo { + const ChatListRoute({List<_i24.PageRouteInfo>? children}) : super(ChatListRoute.name, initialChildren: children); static const String name = 'ChatListRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { return const _i4.ChatListScreen(); @@ -152,11 +153,11 @@ class ChatListRoute extends _i23.PageRouteInfo { /// generated route for /// [_i5.ChatRoomScreen] -class ChatRoomRoute extends _i23.PageRouteInfo { +class ChatRoomRoute extends _i24.PageRouteInfo { ChatRoomRoute({ - _i24.Key? key, + _i25.Key? key, required String id, - List<_i23.PageRouteInfo>? children, + List<_i24.PageRouteInfo>? children, }) : super( ChatRoomRoute.name, args: ChatRoomRouteArgs(key: key, id: id), @@ -166,7 +167,7 @@ class ChatRoomRoute extends _i23.PageRouteInfo { static const String name = 'ChatRoomRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -181,7 +182,7 @@ class ChatRoomRoute extends _i23.PageRouteInfo { class ChatRoomRouteArgs { const ChatRoomRouteArgs({this.key, required this.id}); - final _i24.Key? key; + final _i25.Key? key; final String id; @@ -193,13 +194,13 @@ class ChatRoomRouteArgs { /// generated route for /// [_i6.CreateAccountScreen] -class CreateAccountRoute extends _i23.PageRouteInfo { - const CreateAccountRoute({List<_i23.PageRouteInfo>? children}) +class CreateAccountRoute extends _i24.PageRouteInfo { + const CreateAccountRoute({List<_i24.PageRouteInfo>? children}) : super(CreateAccountRoute.name, initialChildren: children); static const String name = 'CreateAccountRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { return const _i6.CreateAccountScreen(); @@ -209,13 +210,13 @@ class CreateAccountRoute extends _i23.PageRouteInfo { /// generated route for /// [_i7.CreatorHubScreen] -class CreatorHubRoute extends _i23.PageRouteInfo { - const CreatorHubRoute({List<_i23.PageRouteInfo>? children}) +class CreatorHubRoute extends _i24.PageRouteInfo { + const CreatorHubRoute({List<_i24.PageRouteInfo>? children}) : super(CreatorHubRoute.name, initialChildren: children); static const String name = 'CreatorHubRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { return const _i7.CreatorHubScreen(); @@ -225,8 +226,8 @@ class CreatorHubRoute extends _i23.PageRouteInfo { /// generated route for /// [_i4.EditChatScreen] -class EditChatRoute extends _i23.PageRouteInfo { - EditChatRoute({_i24.Key? key, String? id, List<_i23.PageRouteInfo>? children}) +class EditChatRoute extends _i24.PageRouteInfo { + EditChatRoute({_i25.Key? key, String? id, List<_i24.PageRouteInfo>? children}) : super( EditChatRoute.name, args: EditChatRouteArgs(key: key, id: id), @@ -236,7 +237,7 @@ class EditChatRoute extends _i23.PageRouteInfo { static const String name = 'EditChatRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -251,7 +252,7 @@ class EditChatRoute extends _i23.PageRouteInfo { class EditChatRouteArgs { const EditChatRouteArgs({this.key, this.id}); - final _i24.Key? key; + final _i25.Key? key; final String? id; @@ -263,11 +264,11 @@ class EditChatRouteArgs { /// generated route for /// [_i8.EditPublisherScreen] -class EditPublisherRoute extends _i23.PageRouteInfo { +class EditPublisherRoute extends _i24.PageRouteInfo { EditPublisherRoute({ - _i24.Key? key, + _i25.Key? key, String? name, - List<_i23.PageRouteInfo>? children, + List<_i24.PageRouteInfo>? children, }) : super( EditPublisherRoute.name, args: EditPublisherRouteArgs(key: key, name: name), @@ -277,7 +278,7 @@ class EditPublisherRoute extends _i23.PageRouteInfo { static const String name = 'EditPublisherRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -292,7 +293,7 @@ class EditPublisherRoute extends _i23.PageRouteInfo { class EditPublisherRouteArgs { const EditPublisherRouteArgs({this.key, this.name}); - final _i24.Key? key; + final _i25.Key? key; final String? name; @@ -304,11 +305,11 @@ class EditPublisherRouteArgs { /// generated route for /// [_i9.EditRealmScreen] -class EditRealmRoute extends _i23.PageRouteInfo { +class EditRealmRoute extends _i24.PageRouteInfo { EditRealmRoute({ - _i24.Key? key, + _i25.Key? key, String? slug, - List<_i23.PageRouteInfo>? children, + List<_i24.PageRouteInfo>? children, }) : super( EditRealmRoute.name, args: EditRealmRouteArgs(key: key, slug: slug), @@ -318,7 +319,7 @@ class EditRealmRoute extends _i23.PageRouteInfo { static const String name = 'EditRealmRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -333,7 +334,7 @@ class EditRealmRoute extends _i23.PageRouteInfo { class EditRealmRouteArgs { const EditRealmRouteArgs({this.key, this.slug}); - final _i24.Key? key; + final _i25.Key? key; final String? slug; @@ -346,12 +347,12 @@ class EditRealmRouteArgs { /// generated route for /// [_i10.EditStickerPacksScreen] class EditStickerPacksRoute - extends _i23.PageRouteInfo { + extends _i24.PageRouteInfo { EditStickerPacksRoute({ - _i24.Key? key, + _i25.Key? key, required String pubName, String? packId, - List<_i23.PageRouteInfo>? children, + List<_i24.PageRouteInfo>? children, }) : super( EditStickerPacksRoute.name, args: EditStickerPacksRouteArgs( @@ -365,7 +366,7 @@ class EditStickerPacksRoute static const String name = 'EditStickerPacksRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -392,7 +393,7 @@ class EditStickerPacksRouteArgs { this.packId, }); - final _i24.Key? key; + final _i25.Key? key; final String pubName; @@ -406,12 +407,12 @@ class EditStickerPacksRouteArgs { /// generated route for /// [_i11.EditStickersScreen] -class EditStickersRoute extends _i23.PageRouteInfo { +class EditStickersRoute extends _i24.PageRouteInfo { EditStickersRoute({ - _i24.Key? key, + _i25.Key? key, required String packId, required String? id, - List<_i23.PageRouteInfo>? children, + List<_i24.PageRouteInfo>? children, }) : super( EditStickersRoute.name, args: EditStickersRouteArgs(key: key, packId: packId, id: id), @@ -421,7 +422,7 @@ class EditStickersRoute extends _i23.PageRouteInfo { static const String name = 'EditStickersRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -448,7 +449,7 @@ class EditStickersRouteArgs { required this.id, }); - final _i24.Key? key; + final _i25.Key? key; final String packId; @@ -462,13 +463,13 @@ class EditStickersRouteArgs { /// generated route for /// [_i12.ExploreScreen] -class ExploreRoute extends _i23.PageRouteInfo { - const ExploreRoute({List<_i23.PageRouteInfo>? children}) +class ExploreRoute extends _i24.PageRouteInfo { + const ExploreRoute({List<_i24.PageRouteInfo>? children}) : super(ExploreRoute.name, initialChildren: children); static const String name = 'ExploreRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { return const _i12.ExploreScreen(); @@ -478,13 +479,13 @@ class ExploreRoute extends _i23.PageRouteInfo { /// generated route for /// [_i13.LoginScreen] -class LoginRoute extends _i23.PageRouteInfo { - const LoginRoute({List<_i23.PageRouteInfo>? children}) +class LoginRoute extends _i24.PageRouteInfo { + const LoginRoute({List<_i24.PageRouteInfo>? children}) : super(LoginRoute.name, initialChildren: children); static const String name = 'LoginRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { return const _i13.LoginScreen(); @@ -494,13 +495,13 @@ class LoginRoute extends _i23.PageRouteInfo { /// generated route for /// [_i8.ManagedPublisherScreen] -class ManagedPublisherRoute extends _i23.PageRouteInfo { - const ManagedPublisherRoute({List<_i23.PageRouteInfo>? children}) +class ManagedPublisherRoute extends _i24.PageRouteInfo { + const ManagedPublisherRoute({List<_i24.PageRouteInfo>? children}) : super(ManagedPublisherRoute.name, initialChildren: children); static const String name = 'ManagedPublisherRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { return const _i8.ManagedPublisherScreen(); @@ -510,13 +511,13 @@ class ManagedPublisherRoute extends _i23.PageRouteInfo { /// generated route for /// [_i14.MyselfEventCalendarScreen] -class MyselfEventCalendarRoute extends _i23.PageRouteInfo { - const MyselfEventCalendarRoute({List<_i23.PageRouteInfo>? children}) +class MyselfEventCalendarRoute extends _i24.PageRouteInfo { + const MyselfEventCalendarRoute({List<_i24.PageRouteInfo>? children}) : super(MyselfEventCalendarRoute.name, initialChildren: children); static const String name = 'MyselfEventCalendarRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { return const _i14.MyselfEventCalendarScreen(); @@ -526,13 +527,13 @@ class MyselfEventCalendarRoute extends _i23.PageRouteInfo { /// generated route for /// [_i15.MyselfProfileScreen] -class MyselfProfileRoute extends _i23.PageRouteInfo { - const MyselfProfileRoute({List<_i23.PageRouteInfo>? children}) +class MyselfProfileRoute extends _i24.PageRouteInfo { + const MyselfProfileRoute({List<_i24.PageRouteInfo>? children}) : super(MyselfProfileRoute.name, initialChildren: children); static const String name = 'MyselfProfileRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { return const _i15.MyselfProfileScreen(); @@ -542,13 +543,13 @@ class MyselfProfileRoute extends _i23.PageRouteInfo { /// generated route for /// [_i4.NewChatScreen] -class NewChatRoute extends _i23.PageRouteInfo { - const NewChatRoute({List<_i23.PageRouteInfo>? children}) +class NewChatRoute extends _i24.PageRouteInfo { + const NewChatRoute({List<_i24.PageRouteInfo>? children}) : super(NewChatRoute.name, initialChildren: children); static const String name = 'NewChatRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { return const _i4.NewChatScreen(); @@ -558,13 +559,13 @@ class NewChatRoute extends _i23.PageRouteInfo { /// generated route for /// [_i8.NewPublisherScreen] -class NewPublisherRoute extends _i23.PageRouteInfo { - const NewPublisherRoute({List<_i23.PageRouteInfo>? children}) +class NewPublisherRoute extends _i24.PageRouteInfo { + const NewPublisherRoute({List<_i24.PageRouteInfo>? children}) : super(NewPublisherRoute.name, initialChildren: children); static const String name = 'NewPublisherRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { return const _i8.NewPublisherScreen(); @@ -574,13 +575,13 @@ class NewPublisherRoute extends _i23.PageRouteInfo { /// generated route for /// [_i9.NewRealmScreen] -class NewRealmRoute extends _i23.PageRouteInfo { - const NewRealmRoute({List<_i23.PageRouteInfo>? children}) +class NewRealmRoute extends _i24.PageRouteInfo { + const NewRealmRoute({List<_i24.PageRouteInfo>? children}) : super(NewRealmRoute.name, initialChildren: children); static const String name = 'NewRealmRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { return const _i9.NewRealmScreen(); @@ -591,11 +592,11 @@ class NewRealmRoute extends _i23.PageRouteInfo { /// generated route for /// [_i10.NewStickerPacksScreen] class NewStickerPacksRoute - extends _i23.PageRouteInfo { + extends _i24.PageRouteInfo { NewStickerPacksRoute({ - _i24.Key? key, + _i25.Key? key, required String pubName, - List<_i23.PageRouteInfo>? children, + List<_i24.PageRouteInfo>? children, }) : super( NewStickerPacksRoute.name, args: NewStickerPacksRouteArgs(key: key, pubName: pubName), @@ -605,7 +606,7 @@ class NewStickerPacksRoute static const String name = 'NewStickerPacksRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -622,7 +623,7 @@ class NewStickerPacksRoute class NewStickerPacksRouteArgs { const NewStickerPacksRouteArgs({this.key, required this.pubName}); - final _i24.Key? key; + final _i25.Key? key; final String pubName; @@ -634,11 +635,11 @@ class NewStickerPacksRouteArgs { /// generated route for /// [_i11.NewStickersScreen] -class NewStickersRoute extends _i23.PageRouteInfo { +class NewStickersRoute extends _i24.PageRouteInfo { NewStickersRoute({ - _i24.Key? key, + _i25.Key? key, required String packId, - List<_i23.PageRouteInfo>? children, + List<_i24.PageRouteInfo>? children, }) : super( NewStickersRoute.name, args: NewStickersRouteArgs(key: key, packId: packId), @@ -648,7 +649,7 @@ class NewStickersRoute extends _i23.PageRouteInfo { static const String name = 'NewStickersRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -664,7 +665,7 @@ class NewStickersRoute extends _i23.PageRouteInfo { class NewStickersRouteArgs { const NewStickersRouteArgs({this.key, required this.packId}); - final _i24.Key? key; + final _i25.Key? key; final String packId; @@ -676,11 +677,11 @@ class NewStickersRouteArgs { /// generated route for /// [_i16.PostComposeScreen] -class PostComposeRoute extends _i23.PageRouteInfo { +class PostComposeRoute extends _i24.PageRouteInfo { PostComposeRoute({ - _i24.Key? key, - _i25.SnPost? originalPost, - List<_i23.PageRouteInfo>? children, + _i25.Key? key, + _i26.SnPost? originalPost, + List<_i24.PageRouteInfo>? children, }) : super( PostComposeRoute.name, args: PostComposeRouteArgs(key: key, originalPost: originalPost), @@ -689,7 +690,7 @@ class PostComposeRoute extends _i23.PageRouteInfo { static const String name = 'PostComposeRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { final args = data.argsAs( @@ -706,9 +707,9 @@ class PostComposeRoute extends _i23.PageRouteInfo { class PostComposeRouteArgs { const PostComposeRouteArgs({this.key, this.originalPost}); - final _i24.Key? key; + final _i25.Key? key; - final _i25.SnPost? originalPost; + final _i26.SnPost? originalPost; @override String toString() { @@ -718,11 +719,11 @@ class PostComposeRouteArgs { /// generated route for /// [_i17.PostDetailScreen] -class PostDetailRoute extends _i23.PageRouteInfo { +class PostDetailRoute extends _i24.PageRouteInfo { PostDetailRoute({ - _i24.Key? key, + _i25.Key? key, required String id, - List<_i23.PageRouteInfo>? children, + List<_i24.PageRouteInfo>? children, }) : super( PostDetailRoute.name, args: PostDetailRouteArgs(key: key, id: id), @@ -732,7 +733,7 @@ class PostDetailRoute extends _i23.PageRouteInfo { static const String name = 'PostDetailRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -747,7 +748,7 @@ class PostDetailRoute extends _i23.PageRouteInfo { class PostDetailRouteArgs { const PostDetailRouteArgs({this.key, required this.id}); - final _i24.Key? key; + final _i25.Key? key; final String id; @@ -759,11 +760,11 @@ class PostDetailRouteArgs { /// generated route for /// [_i16.PostEditScreen] -class PostEditRoute extends _i23.PageRouteInfo { +class PostEditRoute extends _i24.PageRouteInfo { PostEditRoute({ - _i24.Key? key, + _i25.Key? key, required String id, - List<_i23.PageRouteInfo>? children, + List<_i24.PageRouteInfo>? children, }) : super( PostEditRoute.name, args: PostEditRouteArgs(key: key, id: id), @@ -773,7 +774,7 @@ class PostEditRoute extends _i23.PageRouteInfo { static const String name = 'PostEditRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -788,7 +789,7 @@ class PostEditRoute extends _i23.PageRouteInfo { class PostEditRouteArgs { const PostEditRouteArgs({this.key, required this.id}); - final _i24.Key? key; + final _i25.Key? key; final String id; @@ -801,11 +802,11 @@ class PostEditRouteArgs { /// generated route for /// [_i18.PublisherProfileScreen] class PublisherProfileRoute - extends _i23.PageRouteInfo { + extends _i24.PageRouteInfo { PublisherProfileRoute({ - _i24.Key? key, + _i25.Key? key, required String name, - List<_i23.PageRouteInfo>? children, + List<_i24.PageRouteInfo>? children, }) : super( PublisherProfileRoute.name, args: PublisherProfileRouteArgs(key: key, name: name), @@ -815,7 +816,7 @@ class PublisherProfileRoute static const String name = 'PublisherProfileRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -831,7 +832,7 @@ class PublisherProfileRoute class PublisherProfileRouteArgs { const PublisherProfileRouteArgs({this.key, required this.name}); - final _i24.Key? key; + final _i25.Key? key; final String name; @@ -843,11 +844,11 @@ class PublisherProfileRouteArgs { /// generated route for /// [_i19.RealmDetailScreen] -class RealmDetailRoute extends _i23.PageRouteInfo { +class RealmDetailRoute extends _i24.PageRouteInfo { RealmDetailRoute({ - _i24.Key? key, + _i25.Key? key, required String slug, - List<_i23.PageRouteInfo>? children, + List<_i24.PageRouteInfo>? children, }) : super( RealmDetailRoute.name, args: RealmDetailRouteArgs(key: key, slug: slug), @@ -857,7 +858,7 @@ class RealmDetailRoute extends _i23.PageRouteInfo { static const String name = 'RealmDetailRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -872,7 +873,7 @@ class RealmDetailRoute extends _i23.PageRouteInfo { class RealmDetailRouteArgs { const RealmDetailRouteArgs({this.key, required this.slug}); - final _i24.Key? key; + final _i25.Key? key; final String slug; @@ -884,13 +885,13 @@ class RealmDetailRouteArgs { /// generated route for /// [_i9.RealmListScreen] -class RealmListRoute extends _i23.PageRouteInfo { - const RealmListRoute({List<_i23.PageRouteInfo>? children}) +class RealmListRoute extends _i24.PageRouteInfo { + const RealmListRoute({List<_i24.PageRouteInfo>? children}) : super(RealmListRoute.name, initialChildren: children); static const String name = 'RealmListRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { return const _i9.RealmListScreen(); @@ -900,13 +901,13 @@ class RealmListRoute extends _i23.PageRouteInfo { /// generated route for /// [_i20.SettingsScreen] -class SettingsRoute extends _i23.PageRouteInfo { - const SettingsRoute({List<_i23.PageRouteInfo>? children}) +class SettingsRoute extends _i24.PageRouteInfo { + const SettingsRoute({List<_i24.PageRouteInfo>? children}) : super(SettingsRoute.name, initialChildren: children); static const String name = 'SettingsRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { return const _i20.SettingsScreen(); @@ -917,12 +918,12 @@ class SettingsRoute extends _i23.PageRouteInfo { /// generated route for /// [_i11.StickerPackDetailScreen] class StickerPackDetailRoute - extends _i23.PageRouteInfo { + extends _i24.PageRouteInfo { StickerPackDetailRoute({ - _i24.Key? key, + _i25.Key? key, required String pubName, required String id, - List<_i23.PageRouteInfo>? children, + List<_i24.PageRouteInfo>? children, }) : super( StickerPackDetailRoute.name, args: StickerPackDetailRouteArgs(key: key, pubName: pubName, id: id), @@ -932,7 +933,7 @@ class StickerPackDetailRoute static const String name = 'StickerPackDetailRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -959,7 +960,7 @@ class StickerPackDetailRouteArgs { required this.id, }); - final _i24.Key? key; + final _i25.Key? key; final String pubName; @@ -973,11 +974,11 @@ class StickerPackDetailRouteArgs { /// generated route for /// [_i10.StickersScreen] -class StickersRoute extends _i23.PageRouteInfo { +class StickersRoute extends _i24.PageRouteInfo { StickersRoute({ - _i24.Key? key, + _i25.Key? key, required String pubName, - List<_i23.PageRouteInfo>? children, + List<_i24.PageRouteInfo>? children, }) : super( StickersRoute.name, args: StickersRouteArgs(key: key, pubName: pubName), @@ -987,7 +988,7 @@ class StickersRoute extends _i23.PageRouteInfo { static const String name = 'StickersRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { final pathParams = data.inheritedPathParams; @@ -1002,7 +1003,7 @@ class StickersRoute extends _i23.PageRouteInfo { class StickersRouteArgs { const StickersRouteArgs({this.key, required this.pubName}); - final _i24.Key? key; + final _i25.Key? key; final String pubName; @@ -1014,13 +1015,13 @@ class StickersRouteArgs { /// generated route for /// [_i21.TabsScreen] -class TabsRoute extends _i23.PageRouteInfo { - const TabsRoute({List<_i23.PageRouteInfo>? children}) +class TabsRoute extends _i24.PageRouteInfo { + const TabsRoute({List<_i24.PageRouteInfo>? children}) : super(TabsRoute.name, initialChildren: children); static const String name = 'TabsRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { return const _i21.TabsScreen(); @@ -1030,16 +1031,32 @@ class TabsRoute extends _i23.PageRouteInfo { /// generated route for /// [_i22.UpdateProfileScreen] -class UpdateProfileRoute extends _i23.PageRouteInfo { - const UpdateProfileRoute({List<_i23.PageRouteInfo>? children}) +class UpdateProfileRoute extends _i24.PageRouteInfo { + const UpdateProfileRoute({List<_i24.PageRouteInfo>? children}) : super(UpdateProfileRoute.name, initialChildren: children); static const String name = 'UpdateProfileRoute'; - static _i23.PageInfo page = _i23.PageInfo( + static _i24.PageInfo page = _i24.PageInfo( name, builder: (data) { return const _i22.UpdateProfileScreen(); }, ); } + +/// generated route for +/// [_i23.WalletScreen] +class WalletRoute extends _i24.PageRouteInfo { + const WalletRoute({List<_i24.PageRouteInfo>? children}) + : super(WalletRoute.name, initialChildren: children); + + static const String name = 'WalletRoute'; + + static _i24.PageInfo page = _i24.PageInfo( + name, + builder: (data) { + return const _i23.WalletScreen(); + }, + ); +} diff --git a/lib/screens/account.dart b/lib/screens/account.dart index 77488d2..a16f9e9 100644 --- a/lib/screens/account.dart +++ b/lib/screens/account.dart @@ -141,6 +141,16 @@ class AccountScreen extends HookConsumerWidget { context.router.push(ManagedPublisherRoute()); }, ), + ListTile( + minTileHeight: 48, + leading: const Icon(Symbols.wallet), + trailing: const Icon(Symbols.chevron_right), + contentPadding: EdgeInsets.symmetric(horizontal: 24), + title: Text('wallet').tr(), + onTap: () { + context.router.push(WalletRoute()); + }, + ), ListTile( minTileHeight: 48, leading: const Icon(Symbols.edit), diff --git a/lib/screens/account/me/publishers.dart b/lib/screens/account/me/publishers.dart index 3d1ee07..1fbb846 100644 --- a/lib/screens/account/me/publishers.dart +++ b/lib/screens/account/me/publishers.dart @@ -199,7 +199,10 @@ class EditPublisherScreen extends HookConsumerWidget { CropAspectRatio(height: 1, width: 1), ], ); - if (result == null) return; + if (result == null) { + if (context.mounted) hideLoadingModal(context); + return; + } if (!context.mounted) return; showLoadingModal(context); diff --git a/lib/screens/account/me/update.dart b/lib/screens/account/me/update.dart index 9722d5c..ca02a25 100644 --- a/lib/screens/account/me/update.dart +++ b/lib/screens/account/me/update.dart @@ -30,7 +30,10 @@ class UpdateProfileScreen extends HookConsumerWidget { var result = await ref .read(imagePickerProvider) .pickImage(source: ImageSource.gallery); - if (result == null) return; + if (result == null) { + if (context.mounted) hideLoadingModal(context); + return; + } if (!context.mounted) return; hideLoadingModal(context); result = await cropImage( diff --git a/lib/screens/chat/chat.dart b/lib/screens/chat/chat.dart index 5f4cbe4..69ed800 100644 --- a/lib/screens/chat/chat.dart +++ b/lib/screens/chat/chat.dart @@ -265,7 +265,10 @@ class EditChatScreen extends HookConsumerWidget { CropAspectRatio(height: 1, width: 1), ], ); - if (result == null) return; + if (result == null) { + if (context.mounted) hideLoadingModal(context); + return; + } if (!context.mounted) return; showLoadingModal(context); diff --git a/lib/screens/explore.dart b/lib/screens/explore.dart index 759af57..f41091b 100644 --- a/lib/screens/explore.dart +++ b/lib/screens/explore.dart @@ -12,10 +12,12 @@ import 'package:island/models/post.dart'; import 'package:island/widgets/check_in.dart'; import 'package:island/widgets/post/post_item.dart'; import 'package:material_symbols_icons/symbols.dart'; -import 'package:very_good_infinite_list/very_good_infinite_list.dart'; -import 'package:dio/dio.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; +import 'package:riverpod_paging_utils/riverpod_paging_utils.dart'; import 'package:island/pods/network.dart'; +part 'explore.g.dart'; + @RoutePage() class ExploreScreen extends ConsumerWidget { const ExploreScreen({super.key}); @@ -23,8 +25,7 @@ class ExploreScreen extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final user = ref.watch(userInfoProvider); - final posts = ref.watch(activityListProvider); - final postsNotifier = ref.watch(activityListProvider.notifier); + final activitiesNotifier = ref.watch(activityListNotifierProvider.notifier); return AppScaffold( appBar: AppBar(title: const Text('explore').tr()), @@ -33,7 +34,7 @@ class ExploreScreen extends ConsumerWidget { onPressed: () { context.router.push(PostComposeRoute()).then((value) { if (value != null) { - ref.invalidate(activityListProvider); + activitiesNotifier.forceRefresh(); } }); }, @@ -41,108 +42,110 @@ class ExploreScreen extends ConsumerWidget { ), floatingActionButtonLocation: FloatingActionButtonLocation.endFloat, body: RefreshIndicator( - onRefresh: () => postsNotifier.refresh(), - child: CustomScrollView( - slivers: [ - if (user.hasValue) SliverToBoxAdapter(child: CheckInWidget()), - SliverInfiniteList( - itemCount: posts.length, - isLoading: postsNotifier.isLoading, - hasReachedMax: postsNotifier.hasReachedMax, - onFetchData: postsNotifier.fetchMore, - itemBuilder: (context, index) { - final item = posts[index]; - switch (item.type) { - case 'posts.new': - return PostItem( - item: SnPost.fromJson(item.data), - onRefresh: (_) { - ref.invalidate(activityListProvider); - }, - onUpdate: (post) { - postsNotifier.updateOne( - index, - item.copyWith(data: post.toJson()), - ); - }, - ); - case 'accounts.check-in': - return CheckInActivityWidget(item: item); - case 'accounts.status': - return StatusActivityWidget(item: item); - default: - return Placeholder(); - } - }, - separatorBuilder: (_, __) => const Divider(height: 1), - ), - SliverGap(MediaQuery.of(context).padding.bottom + 16), - ], + onRefresh: () => Future.sync(activitiesNotifier.forceRefresh), + child: PagingHelperView( + provider: activityListNotifierProvider, + futureRefreshable: activityListNotifierProvider.future, + notifierRefreshable: activityListNotifierProvider.notifier, + contentBuilder: + (data, widgetCount, endItemView) => CustomScrollView( + slivers: [ + if (user.hasValue) SliverToBoxAdapter(child: CheckInWidget()), + SliverList.builder( + itemCount: widgetCount, + itemBuilder: (context, index) { + if (index == widgetCount - 1) { + return endItemView; + } + + final item = data.items[index]; + Widget itemWidget; + + switch (item.type) { + case 'posts.new': + itemWidget = PostItem( + item: SnPost.fromJson(item.data), + onRefresh: (_) { + activitiesNotifier.forceRefresh(); + }, + onUpdate: (post) { + activitiesNotifier.updateOne( + index, + item.copyWith(data: post.toJson()), + ); + }, + ); + break; + case 'accounts.check-in': + itemWidget = CheckInActivityWidget(item: item); + break; + case 'accounts.status': + itemWidget = StatusActivityWidget(item: item); + break; + default: + itemWidget = const Placeholder(); + } + + return Column( + children: [itemWidget, const Divider(height: 1)], + ); + }, + ), + SliverGap(MediaQuery.of(context).padding.bottom + 16), + ], + ), ), ), ); } } -final activityListProvider = - StateNotifierProvider<_ActivityListController, List>((ref) { - final client = ref.watch(apiClientProvider); - return _ActivityListController(client); - }); +@riverpod +class ActivityListNotifier extends _$ActivityListNotifier + with CursorPagingNotifierMixin { + @override + Future> build() => fetch(cursor: null); -class _ActivityListController extends StateNotifier> { - _ActivityListController(this._dio) : super([]); + @override + Future> fetch({required String? cursor}) async { + final client = ref.read(apiClientProvider); + final offset = cursor == null ? 0 : int.parse(cursor); + final take = 20; - final Dio _dio; - bool isLoading = false; - bool hasReachedMax = false; - int offset = 0; - final int take = 20; - int total = 0; + final response = await client.get( + '/activities', + queryParameters: {'offset': offset, 'take': take}, + ); - Future fetchMore() async { - if (isLoading || hasReachedMax) return; - isLoading = true; + final List items = + (response.data as List) + .map((e) => SnActivity.fromJson(e as Map)) + .toList(); - try { - final response = await _dio.get( - '/activities', - queryParameters: {'offset': offset, 'take': take}, - ); + final total = int.tryParse(response.headers['x-total']?.first ?? '') ?? 0; + final hasMore = offset + items.length < total; + final nextCursor = hasMore ? (offset + items.length).toString() : null; - final List fetched = - (response.data as List) - .map((e) => SnActivity.fromJson(e as Map)) - .toList(); - - final headerTotal = int.tryParse( - response.headers['x-total']?.first ?? '', - ); - if (headerTotal != null) total = headerTotal; - - if (!mounted) return; // Check if the notifier is still mounted - - state = [...state, ...fetched]; - offset += fetched.length; - if (state.length >= total) hasReachedMax = true; - } finally { - if (mounted) { - isLoading = false; - } - } + return CursorPagingData( + items: items, + hasMore: hasMore, + nextCursor: nextCursor, + ); } - Future refresh() async { - offset = 0; - state = []; - hasReachedMax = false; - await fetchMore(); - } + void updateOne(int index, SnActivity activity) { + final currentState = state.valueOrNull; + if (currentState == null) return; - void updateOne(int index, SnActivity post) { - if (!mounted) return; // Check if the notifier is still mounted - final updatedPosts = [...state]; - updatedPosts[index] = post; - state = updatedPosts; + final updatedItems = [...currentState.items]; + updatedItems[index] = activity; + + state = AsyncData( + CursorPagingData( + items: updatedItems, + hasMore: currentState.hasMore, + nextCursor: currentState.nextCursor, + ), + ); } } diff --git a/lib/screens/explore.g.dart b/lib/screens/explore.g.dart new file mode 100644 index 0000000..2f4d224 --- /dev/null +++ b/lib/screens/explore.g.dart @@ -0,0 +1,31 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'explore.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +String _$activityListNotifierHash() => + r'8a67d302e828408c7c4cf724d84c2c5958f2dc7e'; + +/// See also [ActivityListNotifier]. +@ProviderFor(ActivityListNotifier) +final activityListNotifierProvider = AutoDisposeAsyncNotifierProvider< + ActivityListNotifier, + CursorPagingData +>.internal( + ActivityListNotifier.new, + name: r'activityListNotifierProvider', + debugGetCreateSourceHash: + const bool.fromEnvironment('dart.vm.product') + ? null + : _$activityListNotifierHash, + dependencies: null, + allTransitiveDependencies: null, +); + +typedef _$ActivityListNotifier = + AutoDisposeAsyncNotifier>; +// ignore_for_file: type=lint +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/screens/posts/pub_profile.dart b/lib/screens/posts/pub_profile.dart index 8786dae..bef2db0 100644 --- a/lib/screens/posts/pub_profile.dart +++ b/lib/screens/posts/pub_profile.dart @@ -29,7 +29,7 @@ Future publisher(Ref ref, String uname) async { @riverpod Future> publisherBadges(Ref ref, String pubName) async { final pub = await ref.watch(publisherProvider(pubName).future); - if (pub.publisherType != 0) return []; + if (pub.type != 0) return []; final apiClient = ref.watch(apiClientProvider); final resp = await apiClient.get("/accounts/${pub.name}/badges"); return List.from( @@ -177,7 +177,7 @@ class PublisherProfileScreen extends HookConsumerWidget { ).fontSize(14).opacity(0.85), ], ), - if (data.publisherType == 0) + if (data.type == 0) AccountStatusWidget( uname: name, padding: EdgeInsets.zero, diff --git a/lib/screens/posts/pub_profile.g.dart b/lib/screens/posts/pub_profile.g.dart index 595e9a8..565d7a9 100644 --- a/lib/screens/posts/pub_profile.g.dart +++ b/lib/screens/posts/pub_profile.g.dart @@ -145,7 +145,7 @@ class _PublisherProviderElement String get uname => (origin as PublisherProvider).uname; } -String _$publisherBadgesHash() => r'69a5bbc9e1528da65ae8b1e5e6c4f57c3dcf4071'; +String _$publisherBadgesHash() => r'b26d8804ddc9734c453bdf76af0a9336f166542c'; /// See also [publisherBadges]. @ProviderFor(publisherBadges) diff --git a/lib/screens/realm/realms.dart b/lib/screens/realm/realms.dart index eb7fc00..5ebebd5 100644 --- a/lib/screens/realm/realms.dart +++ b/lib/screens/realm/realms.dart @@ -163,7 +163,10 @@ class EditRealmScreen extends HookConsumerWidget { var result = await ref .read(imagePickerProvider) .pickImage(source: ImageSource.gallery); - if (result == null) return; + if (result == null) { + if (context.mounted) hideLoadingModal(context); + return; + } if (!context.mounted) return; hideLoadingModal(context); result = await cropImage( diff --git a/lib/screens/wallet.dart b/lib/screens/wallet.dart new file mode 100644 index 0000000..66cd55e --- /dev/null +++ b/lib/screens/wallet.dart @@ -0,0 +1,69 @@ +import 'package:auto_route/annotations.dart'; +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:island/models/wallet.dart'; +import 'package:island/pods/network.dart'; +import 'package:island/widgets/app_scaffold.dart'; +import 'package:material_symbols_icons/symbols.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; +import 'package:styled_widget/styled_widget.dart'; + +part 'wallet.g.dart'; + +@riverpod +Future walletCurrent(Ref ref) async { + final apiClient = ref.watch(apiClientProvider); + final resp = await apiClient.get('/wallets'); + return SnWallet.fromJson(resp.data); +} + +const Map kCurrencyIconData = { + 'points': Symbols.toll, + 'golds': Symbols.attach_money, +}; + +@RoutePage() +class WalletScreen extends HookConsumerWidget { + const WalletScreen({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final wallet = ref.watch(walletCurrentProvider); + + String getCurrencyTranslationKey(String currency, {bool isShort = false}) { + return 'walletCurrency${isShort ? 'Short' : ''}${currency[0].toUpperCase()}${currency.substring(1).toLowerCase()}'; + } + + return AppScaffold( + appBar: AppBar(title: Text('wallet').tr()), + body: wallet.when( + data: (data) { + return Column( + spacing: 8, + children: [ + ...data.pockets.map( + (pocket) => Card( + margin: EdgeInsets.zero, + child: ListTile( + leading: Icon( + kCurrencyIconData[pocket.currency] ?? + Symbols.universal_currency_alt, + ), + title: + Text(getCurrencyTranslationKey(pocket.currency)).tr(), + subtitle: Text( + '${pocket.amount.toStringAsFixed(2)} ${getCurrencyTranslationKey(pocket.currency, isShort: true).tr()}', + ), + ), + ), + ), + ], + ).padding(horizontal: 16, vertical: 16); + }, + error: (error, stackTrace) => Center(child: Text('Error: $error')), + loading: () => const Center(child: CircularProgressIndicator()), + ), + ); + } +} diff --git a/lib/screens/wallet.g.dart b/lib/screens/wallet.g.dart new file mode 100644 index 0000000..d6f0f4f --- /dev/null +++ b/lib/screens/wallet.g.dart @@ -0,0 +1,28 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'wallet.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +String _$walletCurrentHash() => r'9123af148c4a27e079bbe90c7d4e41d08e408a39'; + +/// See also [walletCurrent]. +@ProviderFor(walletCurrent) +final walletCurrentProvider = AutoDisposeFutureProvider.internal( + walletCurrent, + name: r'walletCurrentProvider', + debugGetCreateSourceHash: + const bool.fromEnvironment('dart.vm.product') + ? null + : _$walletCurrentHash, + dependencies: null, + allTransitiveDependencies: null, +); + +@Deprecated('Will be removed in 3.0. Use Ref instead') +// ignore: unused_element +typedef WalletCurrentRef = AutoDisposeFutureProviderRef; +// ignore_for_file: type=lint +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/widgets/post/post_list.dart b/lib/widgets/post/post_list.dart index 6f66ad9..f8f6a35 100644 --- a/lib/widgets/post/post_list.dart +++ b/lib/widgets/post/post_list.dart @@ -1,108 +1,49 @@ import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:dio/dio.dart'; import 'package:island/models/post.dart'; import 'package:island/pods/network.dart'; import 'package:island/widgets/post/post_item.dart'; -import 'package:very_good_infinite_list/very_good_infinite_list.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; +import 'package:riverpod_paging_utils/riverpod_paging_utils.dart'; -// State class to hold posts and pagination info -class PostListState { - final List posts; - final bool isLoading; - final String? error; - final int total; - final bool hasMore; +part 'post_list.g.dart'; - const PostListState({ - this.posts = const [], - this.isLoading = false, - this.error, - this.total = 0, - this.hasMore = true, - }); - - PostListState copyWith({ - List? posts, - bool? isLoading, - String? error, - int? total, - bool? hasMore, - }) { - return PostListState( - posts: posts ?? this.posts, - isLoading: isLoading ?? this.isLoading, - error: error, - total: total ?? this.total, - hasMore: hasMore ?? this.hasMore, - ); - } -} - -// Provider for managing post list state -final postListProvider = - StateNotifierProvider.family(( - ref, - pubName, - ) { - final dio = ref.watch(apiClientProvider); - return PostListNotifier(dio, pubName); - }); - -class PostListNotifier extends StateNotifier { - final Dio _dio; - final String? pubName; +@riverpod +class PostListNotifier extends _$PostListNotifier + with CursorPagingNotifierMixin { static const int _pageSize = 20; - PostListNotifier(this._dio, this.pubName) : super(const PostListState()) { - loadInitialPosts(); - } + PostListNotifier({this.pubName}); - Future loadInitialPosts() async { - state = state.copyWith(isLoading: true, error: null); - try { - final result = await _fetchPosts(0); - state = PostListState( - posts: result.posts, - total: result.total, - hasMore: result.posts.length < result.total, - isLoading: false, - ); - } catch (e) { - state = state.copyWith(isLoading: false, error: e.toString()); - } - } + final String? pubName; - Future loadMorePosts() async { - if (state.isLoading || !state.hasMore) return; + @override + Future> build() => fetch(cursor: null); - state = state.copyWith(isLoading: true, error: null); - try { - final result = await _fetchPosts(state.posts.length); - state = state.copyWith( - posts: [...state.posts, ...result.posts], - total: result.total, - hasMore: state.posts.length + result.posts.length < result.total, - isLoading: false, - ); - } catch (e) { - state = state.copyWith(isLoading: false, error: e.toString()); - } - } + @override + Future> fetch({required String? cursor}) async { + final client = ref.read(apiClientProvider); + final offset = cursor == null ? 0 : int.parse(cursor); - Future<({List posts, int total})> _fetchPosts(int offset) async { final queryParams = { 'offset': offset, 'take': _pageSize, if (pubName != null) 'pub': pubName, }; - final response = await _dio.get('/posts', queryParameters: queryParams); + final response = await client.get('/posts', queryParameters: queryParams); final total = int.parse(response.headers.value('X-Total') ?? '0'); final List data = response.data; final posts = data.map((json) => SnPost.fromJson(json)).toList(); - return (posts: posts, total: total); + final hasMore = offset + posts.length < total; + final nextCursor = hasMore ? (offset + posts.length).toString() : null; + + return CursorPagingData( + items: posts, + hasMore: hasMore, + nextCursor: nextCursor, + ); } } @@ -112,18 +53,26 @@ class SliverPostList extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(postListProvider(pubName)); - final notifier = ref.read(postListProvider(pubName).notifier); + return PagingHelperView( + provider: postListNotifierProvider, + futureRefreshable: postListNotifierProvider.future, + notifierRefreshable: postListNotifierProvider.notifier, + contentBuilder: + (data, widgetCount, endItemView) => SliverList.builder( + itemCount: widgetCount, + itemBuilder: (context, index) { + if (index == widgetCount - 1) { + return endItemView; + } - return SliverInfiniteList( - onFetchData: notifier.loadMorePosts, - itemCount: state.posts.length, - hasReachedMax: !state.hasMore, - isLoading: state.isLoading, - itemBuilder: (context, index) { - return PostItem(item: state.posts[index]); - }, - separatorBuilder: (_, __) => const Divider(height: 1), + return Column( + children: [ + PostItem(item: data.items[index]), + const Divider(height: 1), + ], + ); + }, + ), ); } } diff --git a/lib/widgets/post/post_list.g.dart b/lib/widgets/post/post_list.g.dart new file mode 100644 index 0000000..245921d --- /dev/null +++ b/lib/widgets/post/post_list.g.dart @@ -0,0 +1,29 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'post_list.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +String _$postListNotifierHash() => r'88aab109f36c7489c336fea522bffafa10869253'; + +/// See also [PostListNotifier]. +@ProviderFor(PostListNotifier) +final postListNotifierProvider = AutoDisposeAsyncNotifierProvider< + PostListNotifier, + CursorPagingData +>.internal( + PostListNotifier.new, + name: r'postListNotifierProvider', + debugGetCreateSourceHash: + const bool.fromEnvironment('dart.vm.product') + ? null + : _$postListNotifierHash, + dependencies: null, + allTransitiveDependencies: null, +); + +typedef _$PostListNotifier = AutoDisposeAsyncNotifier>; +// ignore_for_file: type=lint +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/widgets/response.dart b/lib/widgets/response.dart new file mode 100644 index 0000000..ac74d60 --- /dev/null +++ b/lib/widgets/response.dart @@ -0,0 +1,41 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:gap/gap.dart'; +import 'package:material_symbols_icons/symbols.dart'; + +class ResponseErrorWidget extends StatelessWidget { + final Error error; + final VoidCallback onRetry; + const ResponseErrorWidget({ + super.key, + required this.error, + required this.onRetry, + }); + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon(Symbols.error_outline, size: 48), + const Gap(16), + Text( + error.toString(), + textAlign: TextAlign.center, + style: const TextStyle(color: Color(0xFF757575)), + ), + const SizedBox(height: 16), + TextButton(onPressed: onRetry, child: const Text('retry').tr()), + ], + ); + } +} + +class ResponseLoadingWidget extends StatelessWidget { + const ResponseLoadingWidget({super.key}); + + @override + Widget build(BuildContext context) { + return const Center(child: CircularProgressIndicator()); + } +} diff --git a/pubspec.lock b/pubspec.lock index 312bc0a..cc7a57e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1461,6 +1461,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.6.5" + riverpod_paging_utils: + dependency: "direct main" + description: + name: riverpod_paging_utils + sha256: "18f59960807835b1d3cb993e825442d7b09928d0f55ad50bda65c002b5893bdc" + url: "https://pub.dev" + source: hosted + version: "0.8.0" rxdart: dependency: transitive description: @@ -1947,6 +1955,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.9.0" + visibility_detector: + dependency: transitive + description: + name: visibility_detector + sha256: dd5cc11e13494f432d15939c3aa8ae76844c42b723398643ce9addb88a5ed420 + url: "https://pub.dev" + source: hosted + version: "0.4.0+2" vm_service: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 60aeda6..22cc9aa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -94,6 +94,7 @@ dependencies: table_calendar: ^3.1.3 relative_time: ^5.0.0 dropdown_button2: ^2.3.9 + riverpod_paging_utils: ^0.8.0 dev_dependencies: flutter_test: