Programs, members

🐛 Fix web assets redirecting issue
This commit is contained in:
LittleSheep 2025-03-23 22:34:58 +08:00
parent dd196b7754
commit 9cc577adbe
10 changed files with 1195 additions and 5 deletions

View File

@ -904,5 +904,16 @@
"other": "{} Golden Points"
},
"walletTransactionTypeNormal": "Source Point",
"walletTransactionTypeGolden": "Golden Point"
"walletTransactionTypeGolden": "Golden Point",
"accountProgram": "Programs",
"accountProgramDescription": "Explore the available member programs.",
"accountProgramJoin": "Join Program",
"accountProgramJoinRequirements": "Requirements",
"accountProgramJoinPricing": "Pricing",
"accountProgramJoinPricingHint": "Billed every (30 days) month.",
"accountProgramLeaveHint": "After leaving the program, the source points will not be refunded.",
"accountProgramJoined": "Joined Program.",
"accountProgramAlreadyJoined": "Joined",
"accountProgramLeft": "Left Program.",
"leave": "Leave"
}

View File

@ -902,5 +902,16 @@
"other": "{} 金点"
},
"walletTransactionTypeNormal": "源点",
"walletTransactionTypeGolden": "金点"
"walletTransactionTypeGolden": "金点",
"accountProgram": "计划",
"accountProgramDescription": "了解可用的成员计划。",
"accountProgramJoin": "加入计划",
"accountProgramJoinRequirements": "要求",
"accountProgramJoinPricing": "价格",
"accountProgramJoinPricingHint": "按月30 天)收费",
"accountProgramLeaveHint": "离开计划后,之前花费的源点不会退款。",
"accountProgramJoined": "已加入计划。",
"accountProgramLeft": "已离开计划。",
"accountProgramAlreadyJoined": "已加入",
"leave": "离开"
}

View File

@ -13,6 +13,7 @@ import 'package:surface/screens/account/prefs/notify.dart';
import 'package:surface/screens/account/prefs/security.dart';
import 'package:surface/screens/account/profile_page.dart';
import 'package:surface/screens/account/profile_edit.dart';
import 'package:surface/screens/account/programs.dart';
import 'package:surface/screens/account/publishers/publisher_edit.dart';
import 'package:surface/screens/account/publishers/publisher_new.dart';
import 'package:surface/screens/account/publishers/publishers.dart';
@ -130,6 +131,11 @@ final _appRoutes = [
name: 'account',
builder: (context, state) => const AccountScreen(),
routes: [
GoRoute(
path: '/programs',
name: 'accountProgram',
builder: (context, state) => const AccountProgramScreen(),
),
GoRoute(
path: '/contacts',
name: 'accountContactMethods',

View File

@ -145,6 +145,16 @@ class _AuthorizedAccountScreen extends StatelessWidget {
GoRouter.of(context).pushNamed('accountPublishers');
},
),
ListTile(
title: Text('accountProgram').tr(),
subtitle: Text('accountProgramDescription').tr(),
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
leading: const Icon(Symbols.communities),
trailing: const Icon(Symbols.chevron_right),
onTap: () {
GoRouter.of(context).pushNamed('accountProgram');
},
),
ListTile(
title: Text('friends').tr(),
subtitle: Text('friendsDescription').tr(),

View File

@ -0,0 +1,284 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:provider/provider.dart';
import 'package:styled_widget/styled_widget.dart';
import 'package:surface/providers/experience.dart';
import 'package:surface/providers/sn_network.dart';
import 'package:surface/types/account.dart';
import 'package:surface/widgets/dialog.dart';
import 'package:surface/widgets/loading_indicator.dart';
import 'package:surface/widgets/navigation/app_scaffold.dart';
class AccountProgramScreen extends StatefulWidget {
const AccountProgramScreen({super.key});
@override
State<AccountProgramScreen> createState() => _AccountProgramScreenState();
}
class _AccountProgramScreenState extends State<AccountProgramScreen> {
bool _isBusy = false;
final List<SnProgram> _programs = List.empty(growable: true);
final List<SnProgramMember> _programMembers = List.empty(growable: true);
Future<void> _fetchPrograms() async {
_programs.clear();
setState(() => _isBusy = true);
try {
final sn = context.read<SnNetworkProvider>();
final resp = await sn.client.get('/cgi/id/programs');
_programs.addAll(
resp.data.map((ele) => SnProgram.fromJson(ele)).cast<SnProgram>(),
);
} catch (err) {
if (!mounted) return;
context.showErrorDialog(err);
} finally {
setState(() => _isBusy = false);
}
}
Future<void> _fetchProgramMembers() async {
_programMembers.clear();
setState(() => _isBusy = true);
try {
final sn = context.read<SnNetworkProvider>();
final resp = await sn.client.get('/cgi/id/programs/members');
_programMembers.addAll(
resp.data
.map((ele) => SnProgramMember.fromJson(ele))
.cast<SnProgramMember>(),
);
} catch (err) {
if (!mounted) return;
context.showErrorDialog(err);
} finally {
setState(() => _isBusy = false);
}
}
@override
void initState() {
super.initState();
_fetchPrograms();
_fetchProgramMembers();
}
@override
Widget build(BuildContext context) {
return AppScaffold(
appBar: AppBar(
title: Text('accountProgram').tr(),
),
body: Column(
children: [
LoadingIndicator(isActive: _isBusy),
Expanded(
child: ListView.builder(
padding: EdgeInsets.zero,
itemCount: _programs.length,
itemBuilder: (context, idx) {
final ele = _programs[idx];
return Card(
child: InkWell(
borderRadius: BorderRadius.all(Radius.circular(8)),
onTap: () {
showModalBottomSheet(
context: context,
builder: (context) => _ProgramJoinPopup(
program: ele,
isJoined: _programMembers
.any((ele) => ele.programId == ele.id),
),
).then((value) {
_fetchProgramMembers();
});
},
child: Column(
children: [
if (ele.appearance['banner'] != null)
AspectRatio(
aspectRatio: 16 / 5,
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Container(
color: Theme.of(context)
.colorScheme
.surfaceVariant,
child: Image.network(
ele.appearance['banner'],
color: Theme.of(context)
.colorScheme
.onSurfaceVariant,
),
),
),
),
Padding(
padding: const EdgeInsets.all(16),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
ele.name,
style: Theme.of(context)
.textTheme
.titleMedium,
).bold(),
Text(
ele.description,
maxLines: 3,
overflow: TextOverflow.ellipsis,
),
if (_programMembers
.any((ele) => ele.programId == ele.id))
Text('accountProgramAlreadyJoined'.tr())
.opacity(0.75),
],
),
),
],
),
),
],
),
),
).padding(horizontal: 8);
},
),
),
],
),
);
}
}
class _ProgramJoinPopup extends StatefulWidget {
final SnProgram program;
final bool isJoined;
const _ProgramJoinPopup({required this.program, required this.isJoined});
@override
State<_ProgramJoinPopup> createState() => _ProgramJoinPopupState();
}
class _ProgramJoinPopupState extends State<_ProgramJoinPopup> {
bool _isBusy = false;
Future<void> _joinProgram() async {
setState(() => _isBusy = true);
try {
final sn = context.read<SnNetworkProvider>();
await sn.client.post('/cgi/id/programs/${widget.program.id}');
if (!mounted) return;
Navigator.pop(context, true);
context.showSnackbar('accountProgramJoined'.tr());
} catch (err) {
if (!mounted) return;
context.showErrorDialog(err);
} finally {
setState(() => _isBusy = false);
}
}
Future<void> _leaveProgram() async {
setState(() => _isBusy = true);
try {
final sn = context.read<SnNetworkProvider>();
await sn.client.delete('/cgi/id/programs/${widget.program.id}');
if (!mounted) return;
Navigator.pop(context, true);
context.showSnackbar('accountProgramLeft'.tr());
} catch (err) {
if (!mounted) return;
context.showErrorDialog(err);
} finally {
setState(() => _isBusy = false);
}
}
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(Symbols.add, size: 24),
const Gap(16),
Text(
'accountProgramJoin',
style: Theme.of(context).textTheme.titleLarge,
).tr(),
],
).padding(horizontal: 20, top: 16, bottom: 12),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (widget.program.appearance['banner'] != null)
AspectRatio(
aspectRatio: 16 / 5,
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Container(
color: Theme.of(context).colorScheme.surfaceVariant,
child: Image.network(
widget.program.appearance['banner'],
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
),
).padding(bottom: 12),
Text(
widget.program.name,
style: Theme.of(context).textTheme.titleMedium,
).bold(),
Text(
widget.program.description,
maxLines: 3,
overflow: TextOverflow.ellipsis,
),
const Gap(8),
Text(
'accountProgramJoinRequirements',
style: Theme.of(context).textTheme.titleMedium,
).tr().bold(),
Text('≥EXP ${widget.program.expRequirement}'),
Text('≥Lv${getLevelFromExp(widget.program.expRequirement)}'),
const Gap(8),
Text(
'accountProgramJoinPricing',
style: Theme.of(context).textTheme.titleMedium,
).tr().bold(),
Text('walletCurrency${widget.program.price['currency'].toString().capitalize().replaceFirst('Normal', '')}')
.plural(widget.program.price['amount'].toDouble()),
Text('accountProgramJoinPricingHint').tr().opacity(0.75),
const Gap(8),
if (widget.isJoined)
Text('accountProgramLeaveHint')
.tr()
.opacity(0.75)
.padding(bottom: 8),
if (!widget.isJoined)
ElevatedButton(
onPressed: _isBusy ? null : _joinProgram,
child: Text('join').tr(),
)
else
ElevatedButton(
onPressed: _isBusy ? null : _leaveProgram,
child: Text('leave').tr(),
),
],
).padding(horizontal: 24),
],
);
}
}

View File

@ -28,7 +28,8 @@ class _PostShuffleScreenState extends State<PostShuffleScreen> {
setState(() => _isBusy = true);
try {
final pt = context.read<SnPostContentProvider>();
final result = await pt.listPosts(take: 10, offset: _posts.length, isShuffle: true);
final result =
await pt.listPosts(take: 10, offset: _posts.length, isShuffle: true);
_posts.addAll(result.$1);
} catch (err) {
if (!mounted) return;
@ -59,7 +60,8 @@ class _PostShuffleScreenState extends State<PostShuffleScreen> {
Column(
children: [
if (_isBusy || _posts.isEmpty)
const Expanded(child: Center(child: CircularProgressIndicator()))
const Expanded(
child: Center(child: CircularProgressIndicator()))
else
Expanded(
child: CardSwiper(
@ -72,6 +74,7 @@ class _PostShuffleScreenState extends State<PostShuffleScreen> {
return SingleChildScrollView(
child: Center(
child: Card(
color: Theme.of(context).colorScheme.surface,
child: OpenablePostItem(
key: ValueKey(ele),
data: ele,
@ -83,7 +86,11 @@ class _PostShuffleScreenState extends State<PostShuffleScreen> {
onDeleted: () {
_fetchPosts();
},
).padding(all: 24, bottom: MediaQuery.of(context).padding.bottom + 16 + 50),
).padding(all: 8),
).padding(
all: 24,
bottom:
MediaQuery.of(context).padding.bottom + 16 + 50,
),
),
);

View File

@ -184,3 +184,42 @@ abstract class SnActionEvent with _$SnActionEvent {
factory SnActionEvent.fromJson(Map<String, Object?> json) =>
_$SnActionEventFromJson(json);
}
@freezed
abstract class SnProgram with _$SnProgram {
const factory SnProgram({
required int id,
required DateTime createdAt,
required DateTime updatedAt,
required DateTime? deletedAt,
required String name,
required String description,
required String alias,
required int expRequirement,
required Map<String, dynamic> price,
required Map<String, dynamic> badge,
required Map<String, dynamic> group,
required Map<String, dynamic> appearance,
}) = _SnProgram;
factory SnProgram.fromJson(Map<String, Object?> json) =>
_$SnProgramFromJson(json);
}
@freezed
abstract class SnProgramMember with _$SnProgramMember {
const factory SnProgramMember({
required int id,
required DateTime createdAt,
required DateTime updatedAt,
required DateTime? deletedAt,
required DateTime lastPaid,
required SnAccount account,
required int accountId,
required SnProgram program,
required int programId,
}) = _SnProgramMember;
factory SnProgramMember.fromJson(Map<String, Object?> json) =>
_$SnProgramMemberFromJson(json);
}

View File

@ -3470,4 +3470,763 @@ class __$SnActionEventCopyWithImpl<$Res>
}
}
/// @nodoc
mixin _$SnProgram {
int get id;
DateTime get createdAt;
DateTime get updatedAt;
DateTime? get deletedAt;
String get name;
String get description;
String get alias;
int get expRequirement;
Map<String, dynamic> get price;
Map<String, dynamic> get badge;
Map<String, dynamic> get group;
Map<String, dynamic> get appearance;
/// Create a copy of SnProgram
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$SnProgramCopyWith<SnProgram> get copyWith =>
_$SnProgramCopyWithImpl<SnProgram>(this as SnProgram, _$identity);
/// Serializes this SnProgram to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is SnProgram &&
(identical(other.id, id) || other.id == id) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt) &&
(identical(other.deletedAt, deletedAt) ||
other.deletedAt == deletedAt) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.description, description) ||
other.description == description) &&
(identical(other.alias, alias) || other.alias == alias) &&
(identical(other.expRequirement, expRequirement) ||
other.expRequirement == expRequirement) &&
const DeepCollectionEquality().equals(other.price, price) &&
const DeepCollectionEquality().equals(other.badge, badge) &&
const DeepCollectionEquality().equals(other.group, group) &&
const DeepCollectionEquality()
.equals(other.appearance, appearance));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType,
id,
createdAt,
updatedAt,
deletedAt,
name,
description,
alias,
expRequirement,
const DeepCollectionEquality().hash(price),
const DeepCollectionEquality().hash(badge),
const DeepCollectionEquality().hash(group),
const DeepCollectionEquality().hash(appearance));
@override
String toString() {
return 'SnProgram(id: $id, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, name: $name, description: $description, alias: $alias, expRequirement: $expRequirement, price: $price, badge: $badge, group: $group, appearance: $appearance)';
}
}
/// @nodoc
abstract mixin class $SnProgramCopyWith<$Res> {
factory $SnProgramCopyWith(SnProgram value, $Res Function(SnProgram) _then) =
_$SnProgramCopyWithImpl;
@useResult
$Res call(
{int id,
DateTime createdAt,
DateTime updatedAt,
DateTime? deletedAt,
String name,
String description,
String alias,
int expRequirement,
Map<String, dynamic> price,
Map<String, dynamic> badge,
Map<String, dynamic> group,
Map<String, dynamic> appearance});
}
/// @nodoc
class _$SnProgramCopyWithImpl<$Res> implements $SnProgramCopyWith<$Res> {
_$SnProgramCopyWithImpl(this._self, this._then);
final SnProgram _self;
final $Res Function(SnProgram) _then;
/// Create a copy of SnProgram
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? createdAt = null,
Object? updatedAt = null,
Object? deletedAt = freezed,
Object? name = null,
Object? description = null,
Object? alias = null,
Object? expRequirement = null,
Object? price = null,
Object? badge = null,
Object? group = null,
Object? appearance = null,
}) {
return _then(_self.copyWith(
id: null == id
? _self.id
: id // ignore: cast_nullable_to_non_nullable
as int,
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?,
name: null == name
? _self.name
: name // ignore: cast_nullable_to_non_nullable
as String,
description: null == description
? _self.description
: description // ignore: cast_nullable_to_non_nullable
as String,
alias: null == alias
? _self.alias
: alias // ignore: cast_nullable_to_non_nullable
as String,
expRequirement: null == expRequirement
? _self.expRequirement
: expRequirement // ignore: cast_nullable_to_non_nullable
as int,
price: null == price
? _self.price
: price // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,
badge: null == badge
? _self.badge
: badge // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,
group: null == group
? _self.group
: group // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,
appearance: null == appearance
? _self.appearance
: appearance // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,
));
}
}
/// @nodoc
@JsonSerializable()
class _SnProgram implements SnProgram {
const _SnProgram(
{required this.id,
required this.createdAt,
required this.updatedAt,
required this.deletedAt,
required this.name,
required this.description,
required this.alias,
required this.expRequirement,
required final Map<String, dynamic> price,
required final Map<String, dynamic> badge,
required final Map<String, dynamic> group,
required final Map<String, dynamic> appearance})
: _price = price,
_badge = badge,
_group = group,
_appearance = appearance;
factory _SnProgram.fromJson(Map<String, dynamic> json) =>
_$SnProgramFromJson(json);
@override
final int id;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
@override
final DateTime? deletedAt;
@override
final String name;
@override
final String description;
@override
final String alias;
@override
final int expRequirement;
final Map<String, dynamic> _price;
@override
Map<String, dynamic> get price {
if (_price is EqualUnmodifiableMapView) return _price;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(_price);
}
final Map<String, dynamic> _badge;
@override
Map<String, dynamic> get badge {
if (_badge is EqualUnmodifiableMapView) return _badge;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(_badge);
}
final Map<String, dynamic> _group;
@override
Map<String, dynamic> get group {
if (_group is EqualUnmodifiableMapView) return _group;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(_group);
}
final Map<String, dynamic> _appearance;
@override
Map<String, dynamic> get appearance {
if (_appearance is EqualUnmodifiableMapView) return _appearance;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(_appearance);
}
/// Create a copy of SnProgram
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$SnProgramCopyWith<_SnProgram> get copyWith =>
__$SnProgramCopyWithImpl<_SnProgram>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$SnProgramToJson(
this,
);
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _SnProgram &&
(identical(other.id, id) || other.id == id) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt) &&
(identical(other.deletedAt, deletedAt) ||
other.deletedAt == deletedAt) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.description, description) ||
other.description == description) &&
(identical(other.alias, alias) || other.alias == alias) &&
(identical(other.expRequirement, expRequirement) ||
other.expRequirement == expRequirement) &&
const DeepCollectionEquality().equals(other._price, _price) &&
const DeepCollectionEquality().equals(other._badge, _badge) &&
const DeepCollectionEquality().equals(other._group, _group) &&
const DeepCollectionEquality()
.equals(other._appearance, _appearance));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType,
id,
createdAt,
updatedAt,
deletedAt,
name,
description,
alias,
expRequirement,
const DeepCollectionEquality().hash(_price),
const DeepCollectionEquality().hash(_badge),
const DeepCollectionEquality().hash(_group),
const DeepCollectionEquality().hash(_appearance));
@override
String toString() {
return 'SnProgram(id: $id, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, name: $name, description: $description, alias: $alias, expRequirement: $expRequirement, price: $price, badge: $badge, group: $group, appearance: $appearance)';
}
}
/// @nodoc
abstract mixin class _$SnProgramCopyWith<$Res>
implements $SnProgramCopyWith<$Res> {
factory _$SnProgramCopyWith(
_SnProgram value, $Res Function(_SnProgram) _then) =
__$SnProgramCopyWithImpl;
@override
@useResult
$Res call(
{int id,
DateTime createdAt,
DateTime updatedAt,
DateTime? deletedAt,
String name,
String description,
String alias,
int expRequirement,
Map<String, dynamic> price,
Map<String, dynamic> badge,
Map<String, dynamic> group,
Map<String, dynamic> appearance});
}
/// @nodoc
class __$SnProgramCopyWithImpl<$Res> implements _$SnProgramCopyWith<$Res> {
__$SnProgramCopyWithImpl(this._self, this._then);
final _SnProgram _self;
final $Res Function(_SnProgram) _then;
/// Create a copy of SnProgram
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$Res call({
Object? id = null,
Object? createdAt = null,
Object? updatedAt = null,
Object? deletedAt = freezed,
Object? name = null,
Object? description = null,
Object? alias = null,
Object? expRequirement = null,
Object? price = null,
Object? badge = null,
Object? group = null,
Object? appearance = null,
}) {
return _then(_SnProgram(
id: null == id
? _self.id
: id // ignore: cast_nullable_to_non_nullable
as int,
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?,
name: null == name
? _self.name
: name // ignore: cast_nullable_to_non_nullable
as String,
description: null == description
? _self.description
: description // ignore: cast_nullable_to_non_nullable
as String,
alias: null == alias
? _self.alias
: alias // ignore: cast_nullable_to_non_nullable
as String,
expRequirement: null == expRequirement
? _self.expRequirement
: expRequirement // ignore: cast_nullable_to_non_nullable
as int,
price: null == price
? _self._price
: price // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,
badge: null == badge
? _self._badge
: badge // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,
group: null == group
? _self._group
: group // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,
appearance: null == appearance
? _self._appearance
: appearance // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,
));
}
}
/// @nodoc
mixin _$SnProgramMember {
int get id;
DateTime get createdAt;
DateTime get updatedAt;
DateTime? get deletedAt;
DateTime get lastPaid;
SnAccount get account;
int get accountId;
SnProgram get program;
int get programId;
/// Create a copy of SnProgramMember
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$SnProgramMemberCopyWith<SnProgramMember> get copyWith =>
_$SnProgramMemberCopyWithImpl<SnProgramMember>(
this as SnProgramMember, _$identity);
/// Serializes this SnProgramMember to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is SnProgramMember &&
(identical(other.id, id) || other.id == id) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt) &&
(identical(other.deletedAt, deletedAt) ||
other.deletedAt == deletedAt) &&
(identical(other.lastPaid, lastPaid) ||
other.lastPaid == lastPaid) &&
(identical(other.account, account) || other.account == account) &&
(identical(other.accountId, accountId) ||
other.accountId == accountId) &&
(identical(other.program, program) || other.program == program) &&
(identical(other.programId, programId) ||
other.programId == programId));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, id, createdAt, updatedAt,
deletedAt, lastPaid, account, accountId, program, programId);
@override
String toString() {
return 'SnProgramMember(id: $id, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, lastPaid: $lastPaid, account: $account, accountId: $accountId, program: $program, programId: $programId)';
}
}
/// @nodoc
abstract mixin class $SnProgramMemberCopyWith<$Res> {
factory $SnProgramMemberCopyWith(
SnProgramMember value, $Res Function(SnProgramMember) _then) =
_$SnProgramMemberCopyWithImpl;
@useResult
$Res call(
{int id,
DateTime createdAt,
DateTime updatedAt,
DateTime? deletedAt,
DateTime lastPaid,
SnAccount account,
int accountId,
SnProgram program,
int programId});
$SnAccountCopyWith<$Res> get account;
$SnProgramCopyWith<$Res> get program;
}
/// @nodoc
class _$SnProgramMemberCopyWithImpl<$Res>
implements $SnProgramMemberCopyWith<$Res> {
_$SnProgramMemberCopyWithImpl(this._self, this._then);
final SnProgramMember _self;
final $Res Function(SnProgramMember) _then;
/// Create a copy of SnProgramMember
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? createdAt = null,
Object? updatedAt = null,
Object? deletedAt = freezed,
Object? lastPaid = null,
Object? account = null,
Object? accountId = null,
Object? program = null,
Object? programId = null,
}) {
return _then(_self.copyWith(
id: null == id
? _self.id
: id // ignore: cast_nullable_to_non_nullable
as int,
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?,
lastPaid: null == lastPaid
? _self.lastPaid
: lastPaid // ignore: cast_nullable_to_non_nullable
as DateTime,
account: null == account
? _self.account
: account // ignore: cast_nullable_to_non_nullable
as SnAccount,
accountId: null == accountId
? _self.accountId
: accountId // ignore: cast_nullable_to_non_nullable
as int,
program: null == program
? _self.program
: program // ignore: cast_nullable_to_non_nullable
as SnProgram,
programId: null == programId
? _self.programId
: programId // ignore: cast_nullable_to_non_nullable
as int,
));
}
/// Create a copy of SnProgramMember
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$SnAccountCopyWith<$Res> get account {
return $SnAccountCopyWith<$Res>(_self.account, (value) {
return _then(_self.copyWith(account: value));
});
}
/// Create a copy of SnProgramMember
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$SnProgramCopyWith<$Res> get program {
return $SnProgramCopyWith<$Res>(_self.program, (value) {
return _then(_self.copyWith(program: value));
});
}
}
/// @nodoc
@JsonSerializable()
class _SnProgramMember implements SnProgramMember {
const _SnProgramMember(
{required this.id,
required this.createdAt,
required this.updatedAt,
required this.deletedAt,
required this.lastPaid,
required this.account,
required this.accountId,
required this.program,
required this.programId});
factory _SnProgramMember.fromJson(Map<String, dynamic> json) =>
_$SnProgramMemberFromJson(json);
@override
final int id;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
@override
final DateTime? deletedAt;
@override
final DateTime lastPaid;
@override
final SnAccount account;
@override
final int accountId;
@override
final SnProgram program;
@override
final int programId;
/// Create a copy of SnProgramMember
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$SnProgramMemberCopyWith<_SnProgramMember> get copyWith =>
__$SnProgramMemberCopyWithImpl<_SnProgramMember>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$SnProgramMemberToJson(
this,
);
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _SnProgramMember &&
(identical(other.id, id) || other.id == id) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt) &&
(identical(other.deletedAt, deletedAt) ||
other.deletedAt == deletedAt) &&
(identical(other.lastPaid, lastPaid) ||
other.lastPaid == lastPaid) &&
(identical(other.account, account) || other.account == account) &&
(identical(other.accountId, accountId) ||
other.accountId == accountId) &&
(identical(other.program, program) || other.program == program) &&
(identical(other.programId, programId) ||
other.programId == programId));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, id, createdAt, updatedAt,
deletedAt, lastPaid, account, accountId, program, programId);
@override
String toString() {
return 'SnProgramMember(id: $id, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, lastPaid: $lastPaid, account: $account, accountId: $accountId, program: $program, programId: $programId)';
}
}
/// @nodoc
abstract mixin class _$SnProgramMemberCopyWith<$Res>
implements $SnProgramMemberCopyWith<$Res> {
factory _$SnProgramMemberCopyWith(
_SnProgramMember value, $Res Function(_SnProgramMember) _then) =
__$SnProgramMemberCopyWithImpl;
@override
@useResult
$Res call(
{int id,
DateTime createdAt,
DateTime updatedAt,
DateTime? deletedAt,
DateTime lastPaid,
SnAccount account,
int accountId,
SnProgram program,
int programId});
@override
$SnAccountCopyWith<$Res> get account;
@override
$SnProgramCopyWith<$Res> get program;
}
/// @nodoc
class __$SnProgramMemberCopyWithImpl<$Res>
implements _$SnProgramMemberCopyWith<$Res> {
__$SnProgramMemberCopyWithImpl(this._self, this._then);
final _SnProgramMember _self;
final $Res Function(_SnProgramMember) _then;
/// Create a copy of SnProgramMember
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$Res call({
Object? id = null,
Object? createdAt = null,
Object? updatedAt = null,
Object? deletedAt = freezed,
Object? lastPaid = null,
Object? account = null,
Object? accountId = null,
Object? program = null,
Object? programId = null,
}) {
return _then(_SnProgramMember(
id: null == id
? _self.id
: id // ignore: cast_nullable_to_non_nullable
as int,
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?,
lastPaid: null == lastPaid
? _self.lastPaid
: lastPaid // ignore: cast_nullable_to_non_nullable
as DateTime,
account: null == account
? _self.account
: account // ignore: cast_nullable_to_non_nullable
as SnAccount,
accountId: null == accountId
? _self.accountId
: accountId // ignore: cast_nullable_to_non_nullable
as int,
program: null == program
? _self.program
: program // ignore: cast_nullable_to_non_nullable
as SnProgram,
programId: null == programId
? _self.programId
: programId // ignore: cast_nullable_to_non_nullable
as int,
));
}
/// Create a copy of SnProgramMember
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$SnAccountCopyWith<$Res> get account {
return $SnAccountCopyWith<$Res>(_self.account, (value) {
return _then(_self.copyWith(account: value));
});
}
/// Create a copy of SnProgramMember
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$SnProgramCopyWith<$Res> get program {
return $SnProgramCopyWith<$Res>(_self.program, (value) {
return _then(_self.copyWith(program: value));
});
}
}
// dart format on

View File

@ -319,3 +319,64 @@ Map<String, dynamic> _$SnActionEventToJson(_SnActionEvent instance) =>
'account': instance.account.toJson(),
'account_id': instance.accountId,
};
_SnProgram _$SnProgramFromJson(Map<String, dynamic> json) => _SnProgram(
id: (json['id'] as num).toInt(),
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),
name: json['name'] as String,
description: json['description'] as String,
alias: json['alias'] as String,
expRequirement: (json['exp_requirement'] as num).toInt(),
price: json['price'] as Map<String, dynamic>,
badge: json['badge'] as Map<String, dynamic>,
group: json['group'] as Map<String, dynamic>,
appearance: json['appearance'] as Map<String, dynamic>,
);
Map<String, dynamic> _$SnProgramToJson(_SnProgram instance) =>
<String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'name': instance.name,
'description': instance.description,
'alias': instance.alias,
'exp_requirement': instance.expRequirement,
'price': instance.price,
'badge': instance.badge,
'group': instance.group,
'appearance': instance.appearance,
};
_SnProgramMember _$SnProgramMemberFromJson(Map<String, dynamic> json) =>
_SnProgramMember(
id: (json['id'] as num).toInt(),
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),
lastPaid: DateTime.parse(json['last_paid'] as String),
account: SnAccount.fromJson(json['account'] as Map<String, dynamic>),
accountId: (json['account_id'] as num).toInt(),
program: SnProgram.fromJson(json['program'] as Map<String, dynamic>),
programId: (json['program_id'] as num).toInt(),
);
Map<String, dynamic> _$SnProgramMemberToJson(_SnProgramMember instance) =>
<String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'last_paid': instance.lastPaid.toIso8601String(),
'account': instance.account.toJson(),
'account_id': instance.accountId,
'program': instance.program.toJson(),
'program_id': instance.programId,
};

2
web/_redirects Normal file
View File

@ -0,0 +1,2 @@
/assets/assets/translations/en.json /assets/assets/translations/en-US.json 301
/assets/assets/translations/zh.json /assets/assets/translations/zh-CN.json 301