Direct messages

This commit is contained in:
LittleSheep 2025-05-04 16:05:18 +08:00
parent 45fe3d191d
commit 4b6a5c28de
12 changed files with 278 additions and 114 deletions

View File

@ -92,5 +92,6 @@
"forward": "Forward", "forward": "Forward",
"edited": "Edited", "edited": "Edited",
"addVideo": "Add video", "addVideo": "Add video",
"addPhoto": "Add photo" "addPhoto": "Add photo",
"createDirectMessage": "New direct message"
} }

View File

@ -8,7 +8,7 @@ import 'package:island/widgets/alert.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
class MessageRepository { class MessageRepository {
final SnChat room; final SnChatRoom room;
final SnChatMember identity; final SnChatMember identity;
final Dio _apiClient; final Dio _apiClient;
final AppDatabase _database; final AppDatabase _database;

View File

@ -7,8 +7,8 @@ part 'chat.freezed.dart';
part 'chat.g.dart'; part 'chat.g.dart';
@freezed @freezed
abstract class SnChat with _$SnChat { abstract class SnChatRoom with _$SnChatRoom {
const factory SnChat({ const factory SnChatRoom({
required int id, required int id,
required String name, required String name,
required String description, required String description,
@ -23,9 +23,11 @@ abstract class SnChat with _$SnChat {
required DateTime createdAt, required DateTime createdAt,
required DateTime updatedAt, required DateTime updatedAt,
required DateTime? deletedAt, required DateTime? deletedAt,
}) = _SnChat; required List<SnChatMember>? members,
}) = _SnChatRoom;
factory SnChat.fromJson(Map<String, dynamic> json) => _$SnChatFromJson(json); factory SnChatRoom.fromJson(Map<String, dynamic> json) =>
_$SnChatRoomFromJson(json);
} }
@freezed @freezed
@ -79,7 +81,7 @@ abstract class SnChatMember with _$SnChatMember {
required DateTime? deletedAt, required DateTime? deletedAt,
required String id, required String id,
required int chatRoomId, required int chatRoomId,
required SnChat? chatRoom, required SnChatRoom? chatRoom,
required int accountId, required int accountId,
required SnAccount account, required SnAccount account,
required String? nick, required String? nick,

View File

@ -14,42 +14,42 @@ part of 'chat.dart';
T _$identity<T>(T value) => value; T _$identity<T>(T value) => value;
/// @nodoc /// @nodoc
mixin _$SnChat { mixin _$SnChatRoom {
int get id; String get name; String get description; int get type; bool get isPublic; String? get pictureId; SnCloudFile? get picture; String? get backgroundId; SnCloudFile? get background; int? get realmId; SnRealm? get realm; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; int get id; String get name; String get description; int get type; bool get isPublic; String? get pictureId; SnCloudFile? get picture; String? get backgroundId; SnCloudFile? get background; int? get realmId; SnRealm? get realm; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; List<SnChatMember>? get members;
/// Create a copy of SnChat /// Create a copy of SnChatRoom
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$SnChatCopyWith<SnChat> get copyWith => _$SnChatCopyWithImpl<SnChat>(this as SnChat, _$identity); $SnChatRoomCopyWith<SnChatRoom> get copyWith => _$SnChatRoomCopyWithImpl<SnChatRoom>(this as SnChatRoom, _$identity);
/// Serializes this SnChat to a JSON map. /// Serializes this SnChatRoom to a JSON map.
Map<String, dynamic> toJson(); Map<String, dynamic> toJson();
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is SnChat&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.type, type) || other.type == type)&&(identical(other.isPublic, isPublic) || other.isPublic == isPublic)&&(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.realmId, realmId) || other.realmId == realmId)&&(identical(other.realm, realm) || other.realm == realm)&&(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 SnChatRoom&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.type, type) || other.type == type)&&(identical(other.isPublic, isPublic) || other.isPublic == isPublic)&&(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.realmId, realmId) || other.realmId == realmId)&&(identical(other.realm, realm) || other.realm == realm)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)&&const DeepCollectionEquality().equals(other.members, members));
} }
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash(runtimeType,id,name,description,type,isPublic,pictureId,picture,backgroundId,background,realmId,realm,createdAt,updatedAt,deletedAt); int get hashCode => Object.hash(runtimeType,id,name,description,type,isPublic,pictureId,picture,backgroundId,background,realmId,realm,createdAt,updatedAt,deletedAt,const DeepCollectionEquality().hash(members));
@override @override
String toString() { String toString() {
return 'SnChat(id: $id, name: $name, description: $description, type: $type, isPublic: $isPublic, pictureId: $pictureId, picture: $picture, backgroundId: $backgroundId, background: $background, realmId: $realmId, realm: $realm, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; return 'SnChatRoom(id: $id, name: $name, description: $description, type: $type, isPublic: $isPublic, pictureId: $pictureId, picture: $picture, backgroundId: $backgroundId, background: $background, realmId: $realmId, realm: $realm, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, members: $members)';
} }
} }
/// @nodoc /// @nodoc
abstract mixin class $SnChatCopyWith<$Res> { abstract mixin class $SnChatRoomCopyWith<$Res> {
factory $SnChatCopyWith(SnChat value, $Res Function(SnChat) _then) = _$SnChatCopyWithImpl; factory $SnChatRoomCopyWith(SnChatRoom value, $Res Function(SnChatRoom) _then) = _$SnChatRoomCopyWithImpl;
@useResult @useResult
$Res call({ $Res call({
int id, String name, String description, int type, bool isPublic, String? pictureId, SnCloudFile? picture, String? backgroundId, SnCloudFile? background, int? realmId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt int id, String name, String description, int type, bool isPublic, String? pictureId, SnCloudFile? picture, String? backgroundId, SnCloudFile? background, int? realmId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, List<SnChatMember>? members
}); });
@ -57,16 +57,16 @@ $SnCloudFileCopyWith<$Res>? get picture;$SnCloudFileCopyWith<$Res>? get backgrou
} }
/// @nodoc /// @nodoc
class _$SnChatCopyWithImpl<$Res> class _$SnChatRoomCopyWithImpl<$Res>
implements $SnChatCopyWith<$Res> { implements $SnChatRoomCopyWith<$Res> {
_$SnChatCopyWithImpl(this._self, this._then); _$SnChatRoomCopyWithImpl(this._self, this._then);
final SnChat _self; final SnChatRoom _self;
final $Res Function(SnChat) _then; final $Res Function(SnChatRoom) _then;
/// Create a copy of SnChat /// Create a copy of SnChatRoom
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? name = null,Object? description = null,Object? type = null,Object? isPublic = null,Object? pictureId = freezed,Object? picture = freezed,Object? backgroundId = freezed,Object? background = freezed,Object? realmId = freezed,Object? realm = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { @pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? name = null,Object? description = null,Object? type = null,Object? isPublic = null,Object? pictureId = freezed,Object? picture = freezed,Object? backgroundId = freezed,Object? background = freezed,Object? realmId = freezed,Object? realm = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,Object? members = freezed,}) {
return _then(_self.copyWith( return _then(_self.copyWith(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as int,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable as int,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
@ -82,10 +82,11 @@ as int?,realm: freezed == realm ? _self.realm : realm // ignore: cast_nullable_t
as SnRealm?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as SnRealm?,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,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,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable
as DateTime?, as DateTime?,members: freezed == members ? _self.members : members // ignore: cast_nullable_to_non_nullable
as List<SnChatMember>?,
)); ));
} }
/// Create a copy of SnChat /// Create a copy of SnChatRoom
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@ -97,7 +98,7 @@ $SnCloudFileCopyWith<$Res>? get picture {
return $SnCloudFileCopyWith<$Res>(_self.picture!, (value) { return $SnCloudFileCopyWith<$Res>(_self.picture!, (value) {
return _then(_self.copyWith(picture: value)); return _then(_self.copyWith(picture: value));
}); });
}/// Create a copy of SnChat }/// Create a copy of SnChatRoom
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@ -109,7 +110,7 @@ $SnCloudFileCopyWith<$Res>? get background {
return $SnCloudFileCopyWith<$Res>(_self.background!, (value) { return $SnCloudFileCopyWith<$Res>(_self.background!, (value) {
return _then(_self.copyWith(background: value)); return _then(_self.copyWith(background: value));
}); });
}/// Create a copy of SnChat }/// Create a copy of SnChatRoom
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@ -128,9 +129,9 @@ $SnRealmCopyWith<$Res>? get realm {
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _SnChat implements SnChat { class _SnChatRoom implements SnChatRoom {
const _SnChat({required this.id, required this.name, required this.description, required this.type, required this.isPublic, required this.pictureId, required this.picture, required this.backgroundId, required this.background, required this.realmId, required this.realm, required this.createdAt, required this.updatedAt, required this.deletedAt}); const _SnChatRoom({required this.id, required this.name, required this.description, required this.type, required this.isPublic, required this.pictureId, required this.picture, required this.backgroundId, required this.background, required this.realmId, required this.realm, required this.createdAt, required this.updatedAt, required this.deletedAt, required final List<SnChatMember>? members}): _members = members;
factory _SnChat.fromJson(Map<String, dynamic> json) => _$SnChatFromJson(json); factory _SnChatRoom.fromJson(Map<String, dynamic> json) => _$SnChatRoomFromJson(json);
@override final int id; @override final int id;
@override final String name; @override final String name;
@ -146,41 +147,50 @@ class _SnChat implements SnChat {
@override final DateTime createdAt; @override final DateTime createdAt;
@override final DateTime updatedAt; @override final DateTime updatedAt;
@override final DateTime? deletedAt; @override final DateTime? deletedAt;
final List<SnChatMember>? _members;
@override List<SnChatMember>? get members {
final value = _members;
if (value == null) return null;
if (_members is EqualUnmodifiableListView) return _members;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(value);
}
/// Create a copy of SnChat
/// Create a copy of SnChatRoom
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false) @override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$SnChatCopyWith<_SnChat> get copyWith => __$SnChatCopyWithImpl<_SnChat>(this, _$identity); _$SnChatRoomCopyWith<_SnChatRoom> get copyWith => __$SnChatRoomCopyWithImpl<_SnChatRoom>(this, _$identity);
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$SnChatToJson(this, ); return _$SnChatRoomToJson(this, );
} }
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnChat&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.type, type) || other.type == type)&&(identical(other.isPublic, isPublic) || other.isPublic == isPublic)&&(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.realmId, realmId) || other.realmId == realmId)&&(identical(other.realm, realm) || other.realm == realm)&&(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 _SnChatRoom&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.type, type) || other.type == type)&&(identical(other.isPublic, isPublic) || other.isPublic == isPublic)&&(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.realmId, realmId) || other.realmId == realmId)&&(identical(other.realm, realm) || other.realm == realm)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)&&const DeepCollectionEquality().equals(other._members, _members));
} }
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash(runtimeType,id,name,description,type,isPublic,pictureId,picture,backgroundId,background,realmId,realm,createdAt,updatedAt,deletedAt); int get hashCode => Object.hash(runtimeType,id,name,description,type,isPublic,pictureId,picture,backgroundId,background,realmId,realm,createdAt,updatedAt,deletedAt,const DeepCollectionEquality().hash(_members));
@override @override
String toString() { String toString() {
return 'SnChat(id: $id, name: $name, description: $description, type: $type, isPublic: $isPublic, pictureId: $pictureId, picture: $picture, backgroundId: $backgroundId, background: $background, realmId: $realmId, realm: $realm, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; return 'SnChatRoom(id: $id, name: $name, description: $description, type: $type, isPublic: $isPublic, pictureId: $pictureId, picture: $picture, backgroundId: $backgroundId, background: $background, realmId: $realmId, realm: $realm, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, members: $members)';
} }
} }
/// @nodoc /// @nodoc
abstract mixin class _$SnChatCopyWith<$Res> implements $SnChatCopyWith<$Res> { abstract mixin class _$SnChatRoomCopyWith<$Res> implements $SnChatRoomCopyWith<$Res> {
factory _$SnChatCopyWith(_SnChat value, $Res Function(_SnChat) _then) = __$SnChatCopyWithImpl; factory _$SnChatRoomCopyWith(_SnChatRoom value, $Res Function(_SnChatRoom) _then) = __$SnChatRoomCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $Res call({
int id, String name, String description, int type, bool isPublic, String? pictureId, SnCloudFile? picture, String? backgroundId, SnCloudFile? background, int? realmId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt int id, String name, String description, int type, bool isPublic, String? pictureId, SnCloudFile? picture, String? backgroundId, SnCloudFile? background, int? realmId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, List<SnChatMember>? members
}); });
@ -188,17 +198,17 @@ $Res call({
} }
/// @nodoc /// @nodoc
class __$SnChatCopyWithImpl<$Res> class __$SnChatRoomCopyWithImpl<$Res>
implements _$SnChatCopyWith<$Res> { implements _$SnChatRoomCopyWith<$Res> {
__$SnChatCopyWithImpl(this._self, this._then); __$SnChatRoomCopyWithImpl(this._self, this._then);
final _SnChat _self; final _SnChatRoom _self;
final $Res Function(_SnChat) _then; final $Res Function(_SnChatRoom) _then;
/// Create a copy of SnChat /// Create a copy of SnChatRoom
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? name = null,Object? description = null,Object? type = null,Object? isPublic = null,Object? pictureId = freezed,Object? picture = freezed,Object? backgroundId = freezed,Object? background = freezed,Object? realmId = freezed,Object? realm = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { @override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? name = null,Object? description = null,Object? type = null,Object? isPublic = null,Object? pictureId = freezed,Object? picture = freezed,Object? backgroundId = freezed,Object? background = freezed,Object? realmId = freezed,Object? realm = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,Object? members = freezed,}) {
return _then(_SnChat( return _then(_SnChatRoom(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as int,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable as int,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,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable
@ -213,11 +223,12 @@ as int?,realm: freezed == realm ? _self.realm : realm // ignore: cast_nullable_t
as SnRealm?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as SnRealm?,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,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,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable
as DateTime?, as DateTime?,members: freezed == members ? _self._members : members // ignore: cast_nullable_to_non_nullable
as List<SnChatMember>?,
)); ));
} }
/// Create a copy of SnChat /// Create a copy of SnChatRoom
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@ -229,7 +240,7 @@ $SnCloudFileCopyWith<$Res>? get picture {
return $SnCloudFileCopyWith<$Res>(_self.picture!, (value) { return $SnCloudFileCopyWith<$Res>(_self.picture!, (value) {
return _then(_self.copyWith(picture: value)); return _then(_self.copyWith(picture: value));
}); });
}/// Create a copy of SnChat }/// Create a copy of SnChatRoom
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@ -241,7 +252,7 @@ $SnCloudFileCopyWith<$Res>? get background {
return $SnCloudFileCopyWith<$Res>(_self.background!, (value) { return $SnCloudFileCopyWith<$Res>(_self.background!, (value) {
return _then(_self.copyWith(background: value)); return _then(_self.copyWith(background: value));
}); });
}/// Create a copy of SnChat }/// Create a copy of SnChatRoom
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@ -655,7 +666,7 @@ $SnChatMemberCopyWith<$Res> get sender {
/// @nodoc /// @nodoc
mixin _$SnChatMember { mixin _$SnChatMember {
DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; String get id; int get chatRoomId; SnChat? get chatRoom; int get accountId; SnAccount get account; String? get nick; int get role; int get notify; DateTime? get joinedAt; bool get isBot; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; String get id; int get chatRoomId; SnChatRoom? get chatRoom; int get accountId; SnAccount get account; String? get nick; int get role; int get notify; DateTime? get joinedAt; bool get isBot;
/// Create a copy of SnChatMember /// Create a copy of SnChatMember
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@ -688,11 +699,11 @@ abstract mixin class $SnChatMemberCopyWith<$Res> {
factory $SnChatMemberCopyWith(SnChatMember value, $Res Function(SnChatMember) _then) = _$SnChatMemberCopyWithImpl; factory $SnChatMemberCopyWith(SnChatMember value, $Res Function(SnChatMember) _then) = _$SnChatMemberCopyWithImpl;
@useResult @useResult
$Res call({ $Res call({
DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, String id, int chatRoomId, SnChat? chatRoom, int accountId, SnAccount account, String? nick, int role, int notify, DateTime? joinedAt, bool isBot DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, String id, int chatRoomId, SnChatRoom? chatRoom, int accountId, SnAccount account, String? nick, int role, int notify, DateTime? joinedAt, bool isBot
}); });
$SnChatCopyWith<$Res>? get chatRoom;$SnAccountCopyWith<$Res> get account; $SnChatRoomCopyWith<$Res>? get chatRoom;$SnAccountCopyWith<$Res> get account;
} }
/// @nodoc /// @nodoc
@ -713,7 +724,7 @@ as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ign
as DateTime?,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as DateTime?,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,chatRoomId: null == chatRoomId ? _self.chatRoomId : chatRoomId // ignore: cast_nullable_to_non_nullable as String,chatRoomId: null == chatRoomId ? _self.chatRoomId : chatRoomId // ignore: cast_nullable_to_non_nullable
as int,chatRoom: freezed == chatRoom ? _self.chatRoom : chatRoom // ignore: cast_nullable_to_non_nullable as int,chatRoom: freezed == chatRoom ? _self.chatRoom : chatRoom // ignore: cast_nullable_to_non_nullable
as SnChat?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable as SnChatRoom?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable
as int,account: null == account ? _self.account : account // ignore: cast_nullable_to_non_nullable as int,account: null == account ? _self.account : account // ignore: cast_nullable_to_non_nullable
as SnAccount,nick: freezed == nick ? _self.nick : nick // ignore: cast_nullable_to_non_nullable as SnAccount,nick: freezed == nick ? _self.nick : nick // ignore: cast_nullable_to_non_nullable
as String?,role: null == role ? _self.role : role // ignore: cast_nullable_to_non_nullable as String?,role: null == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
@ -727,12 +738,12 @@ as bool,
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$SnChatCopyWith<$Res>? get chatRoom { $SnChatRoomCopyWith<$Res>? get chatRoom {
if (_self.chatRoom == null) { if (_self.chatRoom == null) {
return null; return null;
} }
return $SnChatCopyWith<$Res>(_self.chatRoom!, (value) { return $SnChatRoomCopyWith<$Res>(_self.chatRoom!, (value) {
return _then(_self.copyWith(chatRoom: value)); return _then(_self.copyWith(chatRoom: value));
}); });
}/// Create a copy of SnChatMember }/// Create a copy of SnChatMember
@ -760,7 +771,7 @@ class _SnChatMember implements SnChatMember {
@override final DateTime? deletedAt; @override final DateTime? deletedAt;
@override final String id; @override final String id;
@override final int chatRoomId; @override final int chatRoomId;
@override final SnChat? chatRoom; @override final SnChatRoom? chatRoom;
@override final int accountId; @override final int accountId;
@override final SnAccount account; @override final SnAccount account;
@override final String? nick; @override final String? nick;
@ -802,11 +813,11 @@ abstract mixin class _$SnChatMemberCopyWith<$Res> implements $SnChatMemberCopyWi
factory _$SnChatMemberCopyWith(_SnChatMember value, $Res Function(_SnChatMember) _then) = __$SnChatMemberCopyWithImpl; factory _$SnChatMemberCopyWith(_SnChatMember value, $Res Function(_SnChatMember) _then) = __$SnChatMemberCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $Res call({
DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, String id, int chatRoomId, SnChat? chatRoom, int accountId, SnAccount account, String? nick, int role, int notify, DateTime? joinedAt, bool isBot DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, String id, int chatRoomId, SnChatRoom? chatRoom, int accountId, SnAccount account, String? nick, int role, int notify, DateTime? joinedAt, bool isBot
}); });
@override $SnChatCopyWith<$Res>? get chatRoom;@override $SnAccountCopyWith<$Res> get account; @override $SnChatRoomCopyWith<$Res>? get chatRoom;@override $SnAccountCopyWith<$Res> get account;
} }
/// @nodoc /// @nodoc
@ -827,7 +838,7 @@ as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ign
as DateTime?,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as DateTime?,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,chatRoomId: null == chatRoomId ? _self.chatRoomId : chatRoomId // ignore: cast_nullable_to_non_nullable as String,chatRoomId: null == chatRoomId ? _self.chatRoomId : chatRoomId // ignore: cast_nullable_to_non_nullable
as int,chatRoom: freezed == chatRoom ? _self.chatRoom : chatRoom // ignore: cast_nullable_to_non_nullable as int,chatRoom: freezed == chatRoom ? _self.chatRoom : chatRoom // ignore: cast_nullable_to_non_nullable
as SnChat?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable as SnChatRoom?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable
as int,account: null == account ? _self.account : account // ignore: cast_nullable_to_non_nullable as int,account: null == account ? _self.account : account // ignore: cast_nullable_to_non_nullable
as SnAccount,nick: freezed == nick ? _self.nick : nick // ignore: cast_nullable_to_non_nullable as SnAccount,nick: freezed == nick ? _self.nick : nick // ignore: cast_nullable_to_non_nullable
as String?,role: null == role ? _self.role : role // ignore: cast_nullable_to_non_nullable as String?,role: null == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
@ -842,12 +853,12 @@ as bool,
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$SnChatCopyWith<$Res>? get chatRoom { $SnChatRoomCopyWith<$Res>? get chatRoom {
if (_self.chatRoom == null) { if (_self.chatRoom == null) {
return null; return null;
} }
return $SnChatCopyWith<$Res>(_self.chatRoom!, (value) { return $SnChatRoomCopyWith<$Res>(_self.chatRoom!, (value) {
return _then(_self.copyWith(chatRoom: value)); return _then(_self.copyWith(chatRoom: value));
}); });
}/// Create a copy of SnChatMember }/// Create a copy of SnChatMember

View File

@ -6,7 +6,7 @@ part of 'chat.dart';
// JsonSerializableGenerator // JsonSerializableGenerator
// ************************************************************************** // **************************************************************************
_SnChat _$SnChatFromJson(Map<String, dynamic> json) => _SnChat( _SnChatRoom _$SnChatRoomFromJson(Map<String, dynamic> json) => _SnChatRoom(
id: (json['id'] as num).toInt(), id: (json['id'] as num).toInt(),
name: json['name'] as String, name: json['name'] as String,
description: json['description'] as String, description: json['description'] as String,
@ -33,24 +33,30 @@ _SnChat _$SnChatFromJson(Map<String, dynamic> json) => _SnChat(
json['deleted_at'] == null json['deleted_at'] == null
? null ? null
: DateTime.parse(json['deleted_at'] as String), : DateTime.parse(json['deleted_at'] as String),
members:
(json['members'] as List<dynamic>?)
?.map((e) => SnChatMember.fromJson(e as Map<String, dynamic>))
.toList(),
); );
Map<String, dynamic> _$SnChatToJson(_SnChat instance) => <String, dynamic>{ Map<String, dynamic> _$SnChatRoomToJson(_SnChatRoom instance) =>
'id': instance.id, <String, dynamic>{
'name': instance.name, 'id': instance.id,
'description': instance.description, 'name': instance.name,
'type': instance.type, 'description': instance.description,
'is_public': instance.isPublic, 'type': instance.type,
'picture_id': instance.pictureId, 'is_public': instance.isPublic,
'picture': instance.picture?.toJson(), 'picture_id': instance.pictureId,
'background_id': instance.backgroundId, 'picture': instance.picture?.toJson(),
'background': instance.background?.toJson(), 'background_id': instance.backgroundId,
'realm_id': instance.realmId, 'background': instance.background?.toJson(),
'realm': instance.realm?.toJson(), 'realm_id': instance.realmId,
'created_at': instance.createdAt.toIso8601String(), 'realm': instance.realm?.toJson(),
'updated_at': instance.updatedAt.toIso8601String(), 'created_at': instance.createdAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(), 'updated_at': instance.updatedAt.toIso8601String(),
}; 'deleted_at': instance.deletedAt?.toIso8601String(),
'members': instance.members?.map((e) => e.toJson()).toList(),
};
_SnChatMessage _$SnChatMessageFromJson(Map<String, dynamic> json) => _SnChatMessage _$SnChatMessageFromJson(Map<String, dynamic> json) =>
_SnChatMessage( _SnChatMessage(
@ -152,7 +158,7 @@ _SnChatMember _$SnChatMemberFromJson(Map<String, dynamic> json) =>
chatRoom: chatRoom:
json['chat_room'] == null json['chat_room'] == null
? null ? null
: SnChat.fromJson(json['chat_room'] as Map<String, dynamic>), : SnChatRoom.fromJson(json['chat_room'] as Map<String, dynamic>),
accountId: (json['account_id'] as num).toInt(), accountId: (json['account_id'] as num).toInt(),
account: SnAccount.fromJson(json['account'] as Map<String, dynamic>), account: SnAccount.fromJson(json['account'] as Map<String, dynamic>),
nick: json['nick'] as String?, nick: json['nick'] as String?,

View File

@ -1,7 +1,10 @@
import 'dart:convert';
import 'package:auto_route/auto_route.dart'; import 'package:auto_route/auto_route.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_expandable_fab/flutter_expandable_fab.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:gap/gap.dart'; import 'package:gap/gap.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
@ -12,6 +15,7 @@ import 'package:island/pods/config.dart';
import 'package:island/pods/network.dart'; import 'package:island/pods/network.dart';
import 'package:island/route.gr.dart'; import 'package:island/route.gr.dart';
import 'package:island/services/file.dart'; import 'package:island/services/file.dart';
import 'package:island/widgets/account/account_picker.dart';
import 'package:island/widgets/alert.dart'; import 'package:island/widgets/alert.dart';
import 'package:island/widgets/app_scaffold.dart'; import 'package:island/widgets/app_scaffold.dart';
import 'package:island/widgets/content/cloud_files.dart'; import 'package:island/widgets/content/cloud_files.dart';
@ -23,10 +27,13 @@ import 'package:styled_widget/styled_widget.dart';
part 'chat.g.dart'; part 'chat.g.dart';
@riverpod @riverpod
Future<List<SnChat>> chatroomsJoined(Ref ref) async { Future<List<SnChatRoom>> chatroomsJoined(Ref ref) async {
final client = ref.watch(apiClientProvider); final client = ref.watch(apiClientProvider);
final resp = await client.get('/chat'); final resp = await client.get('/chat');
return resp.data.map((e) => SnChat.fromJson(e)).cast<SnChat>().toList(); return resp.data
.map((e) => SnChatRoom.fromJson(e))
.cast<SnChatRoom>()
.toList();
} }
@RoutePage() @RoutePage()
@ -37,6 +44,23 @@ class ChatListScreen extends HookConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final chats = ref.watch(chatroomsJoinedProvider); final chats = ref.watch(chatroomsJoinedProvider);
final fabKey = useMemoized(() => GlobalKey<ExpandableFabState>(), []);
Future<void> createDirectMessage() async {
final result = await showCupertinoModalBottomSheet(
context: context,
builder: (context) => AccountPickerSheet(),
);
if (result == null) return;
final client = ref.read(apiClientProvider);
try {
await client.post('/chat/direct', data: {'related_user_id': result.id});
ref.refresh(chatroomsJoinedProvider.future);
} catch (err) {
showErrorAlert(err);
}
}
return AppScaffold( return AppScaffold(
appBar: AppBar( appBar: AppBar(
title: Text('chat').tr(), title: Text('chat').tr(),
@ -53,12 +77,66 @@ class ChatListScreen extends HookConsumerWidget {
const Gap(8), const Gap(8),
], ],
), ),
floatingActionButton: FloatingActionButton( floatingActionButtonLocation: ExpandableFab.location,
heroTag: Key("chat-page-fab"), floatingActionButton: ExpandableFab(
onPressed: () { key: fabKey,
context.pushRoute(NewChatRoute()); distance: 75,
}, type: ExpandableFabType.up,
child: const Icon(Symbols.add), childrenAnimation: ExpandableFabAnimation.none,
overlayStyle: ExpandableFabOverlayStyle(
color: Theme.of(
context,
).colorScheme.surface.withAlpha((255 * 0.5).round()),
),
openButtonBuilder: RotateFloatingActionButtonBuilder(
child: const Icon(Symbols.add, size: 28),
fabSize: ExpandableFabSize.regular,
foregroundColor:
Theme.of(context).floatingActionButtonTheme.foregroundColor,
backgroundColor:
Theme.of(context).floatingActionButtonTheme.backgroundColor,
),
closeButtonBuilder: DefaultFloatingActionButtonBuilder(
heroTag: Key("chat-page-fab"),
child: const Icon(Symbols.close, size: 28),
fabSize: ExpandableFabSize.regular,
foregroundColor:
Theme.of(context).floatingActionButtonTheme.foregroundColor,
backgroundColor:
Theme.of(context).floatingActionButtonTheme.backgroundColor,
),
children: [
Row(
children: [
Text('createChatRoom').tr(),
const Gap(20),
FloatingActionButton(
heroTag: null,
tooltip: 'createChatRoom'.tr(),
onPressed: () {
context.pushRoute(NewChatRoute()).then((value) {
if (value != null) {
ref.refresh(chatroomsJoinedProvider.future);
}
});
},
child: const Icon(Symbols.chat_add_on),
),
],
),
Row(
children: [
Text('createDirectMessage').tr(),
const Gap(20),
FloatingActionButton(
heroTag: null,
tooltip: 'createDirectMessage'.tr(),
onPressed: createDirectMessage,
child: const Icon(Symbols.communication),
),
],
),
],
), ),
body: chats.when( body: chats.when(
data: data:
@ -72,6 +150,18 @@ class ChatListScreen extends HookConsumerWidget {
itemCount: items.length, itemCount: items.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final item = items[index]; final item = items[index];
if (item.type == 1) {
return ListTile(
leading: ProfilePictureWidget(
fileId: item.members!.first.account.profile.pictureId,
),
title: Text(item.members!.first.account.nick),
subtitle: Text("An direct message"),
onTap: () {
context.pushRoute(ChatRoomRoute(id: item.id));
},
);
}
return ListTile( return ListTile(
leading: leading:
item.pictureId == null item.pictureId == null
@ -89,18 +179,24 @@ class ChatListScreen extends HookConsumerWidget {
), ),
), ),
loading: () => const Center(child: CircularProgressIndicator()), loading: () => const Center(child: CircularProgressIndicator()),
error: (error, stack) => Center(child: Text('Error: $error')), error:
(error, stack) => GestureDetector(
child: Center(child: Text('Error: $error')),
onTap: () {
ref.invalidate(chatroomsJoinedProvider);
},
),
), ),
); );
} }
} }
@riverpod @riverpod
Future<SnChat?> chatroom(Ref ref, int? identifier) async { Future<SnChatRoom?> chatroom(Ref ref, int? identifier) async {
if (identifier == null) return null; if (identifier == null) return null;
final client = ref.watch(apiClientProvider); final client = ref.watch(apiClientProvider);
final resp = await client.get('/chat/$identifier'); final resp = await client.get('/chat/$identifier');
return SnChat.fromJson(resp.data); return SnChatRoom.fromJson(resp.data);
} }
@riverpod @riverpod
@ -208,7 +304,7 @@ class EditChatScreen extends HookConsumerWidget {
options: Options(method: id == null ? 'POST' : 'PATCH'), options: Options(method: id == null ? 'POST' : 'PATCH'),
); );
if (context.mounted) { if (context.mounted) {
context.maybePop(SnChat.fromJson(resp.data)); context.maybePop(SnChatRoom.fromJson(resp.data));
} }
} catch (err) { } catch (err) {
showErrorAlert(err); showErrorAlert(err);

View File

@ -6,12 +6,12 @@ part of 'chat.dart';
// RiverpodGenerator // RiverpodGenerator
// ************************************************************************** // **************************************************************************
String _$chatroomsJoinedHash() => r'3a2db4159663c54dfd7bc40519e2faa6df69b41f'; String _$chatroomsJoinedHash() => r'0c93fd3cb8fe5c87626836ced4f244bfa7598582';
/// See also [chatroomsJoined]. /// See also [chatroomsJoined].
@ProviderFor(chatroomsJoined) @ProviderFor(chatroomsJoined)
final chatroomsJoinedProvider = final chatroomsJoinedProvider =
AutoDisposeFutureProvider<List<SnChat>>.internal( AutoDisposeFutureProvider<List<SnChatRoom>>.internal(
chatroomsJoined, chatroomsJoined,
name: r'chatroomsJoinedProvider', name: r'chatroomsJoinedProvider',
debugGetCreateSourceHash: debugGetCreateSourceHash:
@ -24,8 +24,8 @@ final chatroomsJoinedProvider =
@Deprecated('Will be removed in 3.0. Use Ref instead') @Deprecated('Will be removed in 3.0. Use Ref instead')
// ignore: unused_element // ignore: unused_element
typedef ChatroomsJoinedRef = AutoDisposeFutureProviderRef<List<SnChat>>; typedef ChatroomsJoinedRef = AutoDisposeFutureProviderRef<List<SnChatRoom>>;
String _$chatroomHash() => r'27bd4cb49326bb2f2eac7d7db9db7f610e21afb2'; String _$chatroomHash() => r'3a945a61ea434f860fbeae9d40778fbfceddc5db';
/// Copied from Dart SDK /// Copied from Dart SDK
class _SystemHash { class _SystemHash {
@ -53,7 +53,7 @@ class _SystemHash {
const chatroomProvider = ChatroomFamily(); const chatroomProvider = ChatroomFamily();
/// See also [chatroom]. /// See also [chatroom].
class ChatroomFamily extends Family<AsyncValue<SnChat?>> { class ChatroomFamily extends Family<AsyncValue<SnChatRoom?>> {
/// See also [chatroom]. /// See also [chatroom].
const ChatroomFamily(); const ChatroomFamily();
@ -83,7 +83,7 @@ class ChatroomFamily extends Family<AsyncValue<SnChat?>> {
} }
/// See also [chatroom]. /// See also [chatroom].
class ChatroomProvider extends AutoDisposeFutureProvider<SnChat?> { class ChatroomProvider extends AutoDisposeFutureProvider<SnChatRoom?> {
/// See also [chatroom]. /// See also [chatroom].
ChatroomProvider(int? identifier) ChatroomProvider(int? identifier)
: this._internal( : this._internal(
@ -113,7 +113,7 @@ class ChatroomProvider extends AutoDisposeFutureProvider<SnChat?> {
@override @override
Override overrideWith( Override overrideWith(
FutureOr<SnChat?> Function(ChatroomRef provider) create, FutureOr<SnChatRoom?> Function(ChatroomRef provider) create,
) { ) {
return ProviderOverride( return ProviderOverride(
origin: this, origin: this,
@ -130,7 +130,7 @@ class ChatroomProvider extends AutoDisposeFutureProvider<SnChat?> {
} }
@override @override
AutoDisposeFutureProviderElement<SnChat?> createElement() { AutoDisposeFutureProviderElement<SnChatRoom?> createElement() {
return _ChatroomProviderElement(this); return _ChatroomProviderElement(this);
} }
@ -150,12 +150,13 @@ class ChatroomProvider extends AutoDisposeFutureProvider<SnChat?> {
@Deprecated('Will be removed in 3.0. Use Ref instead') @Deprecated('Will be removed in 3.0. Use Ref instead')
// ignore: unused_element // ignore: unused_element
mixin ChatroomRef on AutoDisposeFutureProviderRef<SnChat?> { mixin ChatroomRef on AutoDisposeFutureProviderRef<SnChatRoom?> {
/// The parameter `identifier` of this provider. /// The parameter `identifier` of this provider.
int? get identifier; int? get identifier;
} }
class _ChatroomProviderElement extends AutoDisposeFutureProviderElement<SnChat?> class _ChatroomProviderElement
extends AutoDisposeFutureProviderElement<SnChatRoom?>
with ChatroomRef { with ChatroomRef {
_ChatroomProviderElement(super.provider); _ChatroomProviderElement(super.provider);

View File

@ -443,19 +443,28 @@ class ChatRoomScreen extends HookConsumerWidget {
height: 26, height: 26,
width: 26, width: 26,
child: child:
room?.pictureId != null room!.type == 1
? ProfilePictureWidget( ? ProfilePictureWidget(
fileId: room?.pictureId, fileId:
room.members!.first.account.profile.pictureId,
)
: room.pictureId != null
? ProfilePictureWidget(
fileId: room.pictureId,
fallbackIcon: Symbols.chat, fallbackIcon: Symbols.chat,
) )
: CircleAvatar( : CircleAvatar(
child: Text( child: Text(
room?.name[0].toUpperCase() ?? '', room.name[0].toUpperCase(),
style: const TextStyle(fontSize: 12), style: const TextStyle(fontSize: 12),
), ),
), ),
), ),
Text(room?.name ?? 'unknown'.tr()).fontSize(19), Text(
room!.type == 1
? room.members!.first.account.nick
: room.name,
).fontSize(19),
], ],
), ),
loading: () => const Text('Loading...'), loading: () => const Text('Loading...'),
@ -613,7 +622,7 @@ class ChatRoomScreen extends HookConsumerWidget {
class _ChatInput extends StatelessWidget { class _ChatInput extends StatelessWidget {
final TextEditingController messageController; final TextEditingController messageController;
final SnChat chatRoom; final SnChatRoom chatRoom;
final VoidCallback onSend; final VoidCallback onSend;
final VoidCallback onClear; final VoidCallback onClear;
final Function(bool isPhoto) onPickFile; final Function(bool isPhoto) onPickFile;
@ -744,7 +753,12 @@ class _ChatInput extends StatelessWidget {
child: TextField( child: TextField(
controller: messageController, controller: messageController,
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'chatMessageHint'.tr(args: [chatRoom.name]), hintText:
chatRoom.type == 1
? 'chatDirectMessageHint'.tr(
args: [chatRoom.members!.first.account.nick],
)
: 'chatMessageHint'.tr(args: [chatRoom.name]),
border: InputBorder.none, border: InputBorder.none,
isDense: true, isDense: true,
contentPadding: const EdgeInsets.symmetric( contentPadding: const EdgeInsets.symmetric(

View File

@ -55,9 +55,26 @@ class ChatDetailScreen extends HookConsumerWidget {
leading: PageBackButton(shadows: [iconShadow]), leading: PageBackButton(shadows: [iconShadow]),
flexibleSpace: FlexibleSpaceBar( flexibleSpace: FlexibleSpaceBar(
background: background:
currentRoom?.backgroundId != null currentRoom!.type == 1 &&
currentRoom
.members!
.first
.account
.profile
.backgroundId !=
null
? CloudImageWidget( ? CloudImageWidget(
fileId: currentRoom!.backgroundId!, fileId:
currentRoom
.members!
.first
.account
.profile
.backgroundId!,
)
: currentRoom.backgroundId != null
? CloudImageWidget(
fileId: currentRoom.backgroundId!,
fit: BoxFit.cover, fit: BoxFit.cover,
) )
: Container( : Container(
@ -65,7 +82,9 @@ class ChatDetailScreen extends HookConsumerWidget {
Theme.of(context).appBarTheme.backgroundColor, Theme.of(context).appBarTheme.backgroundColor,
), ),
title: Text( title: Text(
currentRoom?.name ?? 'unknown'.tr(), currentRoom.type == 1
? currentRoom.members!.first.account.nick
: currentRoom.name,
).textColor(Theme.of(context).appBarTheme.foregroundColor), ).textColor(Theme.of(context).appBarTheme.foregroundColor),
), ),
actions: [ actions: [

View File

@ -70,11 +70,13 @@ class ProfilePictureWidget extends ConsumerWidget {
final String? fileId; final String? fileId;
final double radius; final double radius;
final IconData? fallbackIcon; final IconData? fallbackIcon;
final Color? fallbackColor;
const ProfilePictureWidget({ const ProfilePictureWidget({
super.key, super.key,
required this.fileId, required this.fileId,
this.radius = 20, this.radius = 20,
this.fallbackIcon, this.fallbackIcon,
this.fallbackColor,
}); });
@override @override
@ -93,6 +95,9 @@ class ProfilePictureWidget extends ConsumerWidget {
? Icon( ? Icon(
fallbackIcon ?? Symbols.account_circle, fallbackIcon ?? Symbols.account_circle,
size: radius, size: radius,
color:
fallbackColor ??
Theme.of(context).colorScheme.onPrimaryContainer,
).center() ).center()
: CachedNetworkImage(imageUrl: uri, fit: BoxFit.cover), : CachedNetworkImage(imageUrl: uri, fit: BoxFit.cover),
), ),

View File

@ -622,6 +622,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
flutter_expandable_fab:
dependency: "direct main"
description:
name: flutter_expandable_fab
sha256: "9de10aad89ebff35956d8eb4ceb0d8749835dc1184d3ab17b721eb06c778c519"
url: "https://pub.dev"
source: hosted
version: "2.5.0"
flutter_highlight: flutter_highlight:
dependency: "direct main" dependency: "direct main"
description: description:

View File

@ -89,6 +89,7 @@ dependencies:
drift_flutter: ^0.2.4 drift_flutter: ^0.2.4
path: ^1.9.1 path: ^1.9.1
collection: ^1.19.1 collection: ^1.19.1
flutter_expandable_fab: ^2.5.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: