Skip to content

Commit

Permalink
Merge branch 'develop' into animate-timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon committed Oct 19, 2023
2 parents 1b7edf6 + 81a4ae0 commit 7a98183
Show file tree
Hide file tree
Showing 30 changed files with 674 additions and 479 deletions.
8 changes: 6 additions & 2 deletions lib/model/account.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:miria/model/acct.dart';
import 'package:misskey_dart/misskey_dart.dart';

part 'account.freezed.dart';
Expand Down Expand Up @@ -29,8 +30,11 @@ class Account with _$Account {
@override
int get hashCode => Object.hash(runtimeType, host, userId);

String get acct {
return "@$userId@$host";
Acct get acct {
return Acct(
host: host,
username: userId,
);
}

factory Account.demoAccount(String host) => Account(
Expand Down
10 changes: 10 additions & 0 deletions lib/model/account_settings.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:miria/model/acct.dart';
import 'package:misskey_dart/misskey_dart.dart';

part 'account_settings.freezed.dart';
part 'account_settings.g.dart';

@freezed
class AccountSettings with _$AccountSettings {
const AccountSettings._();

const factory AccountSettings({
required String userId,
required String host,
Expand All @@ -17,4 +20,11 @@ class AccountSettings with _$AccountSettings {

factory AccountSettings.fromJson(Map<String, dynamic> json) =>
_$AccountSettingsFromJson(json);

Acct get acct {
return Acct(
host: host,
username: userId,
);
}
}
8 changes: 5 additions & 3 deletions lib/model/account_settings.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,16 @@ class __$$_AccountSettingsCopyWithImpl<$Res>

/// @nodoc
@JsonSerializable()
class _$_AccountSettings implements _AccountSettings {
class _$_AccountSettings extends _AccountSettings {
const _$_AccountSettings(
{required this.userId,
required this.host,
final List<String> reactions = const [],
this.defaultNoteVisibility = NoteVisibility.public,
this.defaultIsLocalOnly = false,
this.defaultReactionAcceptance = null})
: _reactions = reactions;
: _reactions = reactions,
super._();

factory _$_AccountSettings.fromJson(Map<String, dynamic> json) =>
_$$_AccountSettingsFromJson(json);
Expand Down Expand Up @@ -249,7 +250,7 @@ class _$_AccountSettings implements _AccountSettings {
}
}

abstract class _AccountSettings implements AccountSettings {
abstract class _AccountSettings extends AccountSettings {
const factory _AccountSettings(
{required final String userId,
required final String host,
Expand All @@ -258,6 +259,7 @@ abstract class _AccountSettings implements AccountSettings {
final bool defaultIsLocalOnly,
final ReactionAcceptance? defaultReactionAcceptance}) =
_$_AccountSettings;
const _AccountSettings._() : super._();

factory _AccountSettings.fromJson(Map<String, dynamic> json) =
_$_AccountSettings.fromJson;
Expand Down
20 changes: 20 additions & 0 deletions lib/model/acct.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:freezed_annotation/freezed_annotation.dart';

part 'acct.freezed.dart';
part 'acct.g.dart';

@freezed
class Acct with _$Acct {
const factory Acct({
required String host,
required String username,
}) = _Acct;
const Acct._();

factory Acct.fromJson(Map<String, Object?> json) => _$AcctFromJson(json);

@override
String toString() {
return "@$username@$host";
}
}
156 changes: 156 additions & 0 deletions lib/model/acct.freezed.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
// 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 'acct.dart';

// **************************************************************************
// FreezedGenerator
// **************************************************************************

T _$identity<T>(T value) => value;

final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');

Acct _$AcctFromJson(Map<String, dynamic> json) {
return _Acct.fromJson(json);
}

/// @nodoc
mixin _$Acct {
String get host => throw _privateConstructorUsedError;
String get username => throw _privateConstructorUsedError;

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$AcctCopyWith<Acct> get copyWith => throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $AcctCopyWith<$Res> {
factory $AcctCopyWith(Acct value, $Res Function(Acct) then) =
_$AcctCopyWithImpl<$Res, Acct>;
@useResult
$Res call({String host, String username});
}

/// @nodoc
class _$AcctCopyWithImpl<$Res, $Val extends Acct>
implements $AcctCopyWith<$Res> {
_$AcctCopyWithImpl(this._value, this._then);

// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;

@pragma('vm:prefer-inline')
@override
$Res call({
Object? host = null,
Object? username = null,
}) {
return _then(_value.copyWith(
host: null == host
? _value.host
: host // ignore: cast_nullable_to_non_nullable
as String,
username: null == username
? _value.username
: username // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
}
}

/// @nodoc
abstract class _$$_AcctCopyWith<$Res> implements $AcctCopyWith<$Res> {
factory _$$_AcctCopyWith(_$_Acct value, $Res Function(_$_Acct) then) =
__$$_AcctCopyWithImpl<$Res>;
@override
@useResult
$Res call({String host, String username});
}

/// @nodoc
class __$$_AcctCopyWithImpl<$Res> extends _$AcctCopyWithImpl<$Res, _$_Acct>
implements _$$_AcctCopyWith<$Res> {
__$$_AcctCopyWithImpl(_$_Acct _value, $Res Function(_$_Acct) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
@override
$Res call({
Object? host = null,
Object? username = null,
}) {
return _then(_$_Acct(
host: null == host
? _value.host
: host // ignore: cast_nullable_to_non_nullable
as String,
username: null == username
? _value.username
: username // ignore: cast_nullable_to_non_nullable
as String,
));
}
}

/// @nodoc
@JsonSerializable()
class _$_Acct extends _Acct {
const _$_Acct({required this.host, required this.username}) : super._();

factory _$_Acct.fromJson(Map<String, dynamic> json) => _$$_AcctFromJson(json);

@override
final String host;
@override
final String username;

@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_Acct &&
(identical(other.host, host) || other.host == host) &&
(identical(other.username, username) ||
other.username == username));
}

@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, host, username);

@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_AcctCopyWith<_$_Acct> get copyWith =>
__$$_AcctCopyWithImpl<_$_Acct>(this, _$identity);

@override
Map<String, dynamic> toJson() {
return _$$_AcctToJson(
this,
);
}
}

abstract class _Acct extends Acct {
const factory _Acct(
{required final String host, required final String username}) = _$_Acct;
const _Acct._() : super._();

factory _Acct.fromJson(Map<String, dynamic> json) = _$_Acct.fromJson;

@override
String get host;
@override
String get username;
@override
@JsonKey(ignore: true)
_$$_AcctCopyWith<_$_Acct> get copyWith => throw _privateConstructorUsedError;
}
17 changes: 17 additions & 0 deletions lib/model/acct.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions lib/model/tab_setting.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:miria/model/account.dart';
import 'package:miria/model/acct.dart';
import 'package:miria/model/converters/icon_converter.dart';
import 'package:miria/model/tab_icon.dart';
import 'package:miria/model/tab_type.dart';

part 'tab_setting.freezed.dart';
part 'tab_setting.g.dart';

Map<String, dynamic> _readAcct(Map<dynamic, dynamic> json, String name) {
final account = json["account"];
if (account != null) {
return {
"host": account["host"],
"username": account["userId"],
};
}
return json[name]! as Map<String, dynamic>;
}

@freezed
class TabSetting with _$TabSetting {
const TabSetting._();
Expand Down Expand Up @@ -42,7 +53,11 @@ class TabSetting with _$TabSetting {
required String name,

/// アカウント情報
required Account account,
// https://github.com/rrousselGit/freezed/issues/488
// ignore: invalid_annotation_target
@JsonKey(readValue: _readAcct) required Acct acct,

/// Renoteを表示するかどうか
@Default(true) bool renoteDisplay,
}) = _TabSetting;

Expand Down
Loading

0 comments on commit 7a98183

Please sign in to comment.