This commit is contained in:
Henry Hiles 2025-11-11 14:45:01 -05:00
commit aaeee8e355
No known key found for this signature in database
10 changed files with 527 additions and 164 deletions

13
lib/models/full_room.dart Normal file
View file

@ -0,0 +1,13 @@
import "package:flutter/widgets.dart";
import "package:freezed_annotation/freezed_annotation.dart";
import "package:matrix/matrix.dart";
part "full_room.freezed.dart";
@freezed
abstract class FullRoom with _$FullRoom {
const factory FullRoom({
required Room roomData,
required String title,
required Image? avatar,
}) = _FullRoom;
}

View file

@ -0,0 +1,277 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// 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 'full_room.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$FullRoom {
Room get roomData; String get title; Image? get avatar;
/// Create a copy of FullRoom
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$FullRoomCopyWith<FullRoom> get copyWith => _$FullRoomCopyWithImpl<FullRoom>(this as FullRoom, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is FullRoom&&(identical(other.roomData, roomData) || other.roomData == roomData)&&(identical(other.title, title) || other.title == title)&&(identical(other.avatar, avatar) || other.avatar == avatar));
}
@override
int get hashCode => Object.hash(runtimeType,roomData,title,avatar);
@override
String toString() {
return 'FullRoom(roomData: $roomData, title: $title, avatar: $avatar)';
}
}
/// @nodoc
abstract mixin class $FullRoomCopyWith<$Res> {
factory $FullRoomCopyWith(FullRoom value, $Res Function(FullRoom) _then) = _$FullRoomCopyWithImpl;
@useResult
$Res call({
Room roomData, String title, Image? avatar
});
}
/// @nodoc
class _$FullRoomCopyWithImpl<$Res>
implements $FullRoomCopyWith<$Res> {
_$FullRoomCopyWithImpl(this._self, this._then);
final FullRoom _self;
final $Res Function(FullRoom) _then;
/// Create a copy of FullRoom
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? roomData = null,Object? title = null,Object? avatar = freezed,}) {
return _then(_self.copyWith(
roomData: null == roomData ? _self.roomData : roomData // ignore: cast_nullable_to_non_nullable
as Room,title: null == title ? _self.title : title // ignore: cast_nullable_to_non_nullable
as String,avatar: freezed == avatar ? _self.avatar : avatar // ignore: cast_nullable_to_non_nullable
as Image?,
));
}
}
/// Adds pattern-matching-related methods to [FullRoom].
extension FullRoomPatterns on FullRoom {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _FullRoom value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _FullRoom() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _FullRoom value) $default,){
final _that = this;
switch (_that) {
case _FullRoom():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _FullRoom value)? $default,){
final _that = this;
switch (_that) {
case _FullRoom() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( Room roomData, String title, Image? avatar)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _FullRoom() when $default != null:
return $default(_that.roomData,_that.title,_that.avatar);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( Room roomData, String title, Image? avatar) $default,) {final _that = this;
switch (_that) {
case _FullRoom():
return $default(_that.roomData,_that.title,_that.avatar);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( Room roomData, String title, Image? avatar)? $default,) {final _that = this;
switch (_that) {
case _FullRoom() when $default != null:
return $default(_that.roomData,_that.title,_that.avatar);case _:
return null;
}
}
}
/// @nodoc
class _FullRoom implements FullRoom {
const _FullRoom({required this.roomData, required this.title, required this.avatar});
@override final Room roomData;
@override final String title;
@override final Image? avatar;
/// Create a copy of FullRoom
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$FullRoomCopyWith<_FullRoom> get copyWith => __$FullRoomCopyWithImpl<_FullRoom>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _FullRoom&&(identical(other.roomData, roomData) || other.roomData == roomData)&&(identical(other.title, title) || other.title == title)&&(identical(other.avatar, avatar) || other.avatar == avatar));
}
@override
int get hashCode => Object.hash(runtimeType,roomData,title,avatar);
@override
String toString() {
return 'FullRoom(roomData: $roomData, title: $title, avatar: $avatar)';
}
}
/// @nodoc
abstract mixin class _$FullRoomCopyWith<$Res> implements $FullRoomCopyWith<$Res> {
factory _$FullRoomCopyWith(_FullRoom value, $Res Function(_FullRoom) _then) = __$FullRoomCopyWithImpl;
@override @useResult
$Res call({
Room roomData, String title, Image? avatar
});
}
/// @nodoc
class __$FullRoomCopyWithImpl<$Res>
implements _$FullRoomCopyWith<$Res> {
__$FullRoomCopyWithImpl(this._self, this._then);
final _FullRoom _self;
final $Res Function(_FullRoom) _then;
/// Create a copy of FullRoom
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? roomData = null,Object? title = null,Object? avatar = freezed,}) {
return _then(_FullRoom(
roomData: null == roomData ? _self.roomData : roomData // ignore: cast_nullable_to_non_nullable
as Room,title: null == title ? _self.title : title // ignore: cast_nullable_to_non_nullable
as String,avatar: freezed == avatar ? _self.avatar : avatar // ignore: cast_nullable_to_non_nullable
as Image?,
));
}
}
// dart format on

View file

@ -1,10 +1,14 @@
import "package:flutter/widgets.dart";
import "package:freezed_annotation/freezed_annotation.dart";
import "package:matrix/matrix.dart";
import "package:nexus/models/full_room.dart";
part "space.freezed.dart";
@freezed
abstract class Space with _$Space {
const factory Space({required Room roomData, required Image? avatar}) =
_Space;
const factory Space({
required String title,
required Widget? avatar,
required List<FullRoom> children,
@Default(false) bool fake,
}) = _Space;
}

View file

@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$Space {
Room get roomData; Image? get avatar;
String get title; Widget? get avatar; List<FullRoom> get children; bool get fake;
/// Create a copy of Space
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@ -25,16 +25,16 @@ $SpaceCopyWith<Space> get copyWith => _$SpaceCopyWithImpl<Space>(this as Space,
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is Space&&(identical(other.roomData, roomData) || other.roomData == roomData)&&(identical(other.avatar, avatar) || other.avatar == avatar));
return identical(this, other) || (other.runtimeType == runtimeType&&other is Space&&(identical(other.title, title) || other.title == title)&&(identical(other.avatar, avatar) || other.avatar == avatar)&&const DeepCollectionEquality().equals(other.children, children)&&(identical(other.fake, fake) || other.fake == fake));
}
@override
int get hashCode => Object.hash(runtimeType,roomData,avatar);
int get hashCode => Object.hash(runtimeType,title,avatar,const DeepCollectionEquality().hash(children),fake);
@override
String toString() {
return 'Space(roomData: $roomData, avatar: $avatar)';
return 'Space(title: $title, avatar: $avatar, children: $children, fake: $fake)';
}
@ -45,7 +45,7 @@ abstract mixin class $SpaceCopyWith<$Res> {
factory $SpaceCopyWith(Space value, $Res Function(Space) _then) = _$SpaceCopyWithImpl;
@useResult
$Res call({
Room roomData, Image? avatar
String title, Widget? avatar, List<FullRoom> children, bool fake
});
@ -62,11 +62,13 @@ class _$SpaceCopyWithImpl<$Res>
/// Create a copy of Space
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? roomData = null,Object? avatar = freezed,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? title = null,Object? avatar = freezed,Object? children = null,Object? fake = null,}) {
return _then(_self.copyWith(
roomData: null == roomData ? _self.roomData : roomData // ignore: cast_nullable_to_non_nullable
as Room,avatar: freezed == avatar ? _self.avatar : avatar // ignore: cast_nullable_to_non_nullable
as Image?,
title: null == title ? _self.title : title // ignore: cast_nullable_to_non_nullable
as String,avatar: freezed == avatar ? _self.avatar : avatar // ignore: cast_nullable_to_non_nullable
as Widget?,children: null == children ? _self.children : children // ignore: cast_nullable_to_non_nullable
as List<FullRoom>,fake: null == fake ? _self.fake : fake // ignore: cast_nullable_to_non_nullable
as bool,
));
}
@ -151,10 +153,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( Room roomData, Image? avatar)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String title, Widget? avatar, List<FullRoom> children, bool fake)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Space() when $default != null:
return $default(_that.roomData,_that.avatar);case _:
return $default(_that.title,_that.avatar,_that.children,_that.fake);case _:
return orElse();
}
@ -172,10 +174,10 @@ return $default(_that.roomData,_that.avatar);case _:
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( Room roomData, Image? avatar) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String title, Widget? avatar, List<FullRoom> children, bool fake) $default,) {final _that = this;
switch (_that) {
case _Space():
return $default(_that.roomData,_that.avatar);case _:
return $default(_that.title,_that.avatar,_that.children,_that.fake);case _:
throw StateError('Unexpected subclass');
}
@ -192,10 +194,10 @@ return $default(_that.roomData,_that.avatar);case _:
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( Room roomData, Image? avatar)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String title, Widget? avatar, List<FullRoom> children, bool fake)? $default,) {final _that = this;
switch (_that) {
case _Space() when $default != null:
return $default(_that.roomData,_that.avatar);case _:
return $default(_that.title,_that.avatar,_that.children,_that.fake);case _:
return null;
}
@ -207,11 +209,19 @@ return $default(_that.roomData,_that.avatar);case _:
class _Space implements Space {
const _Space({required this.roomData, required this.avatar});
const _Space({required this.title, required this.avatar, required final List<FullRoom> children, this.fake = false}): _children = children;
@override final Room roomData;
@override final Image? avatar;
@override final String title;
@override final Widget? avatar;
final List<FullRoom> _children;
@override List<FullRoom> get children {
if (_children is EqualUnmodifiableListView) return _children;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_children);
}
@override@JsonKey() final bool fake;
/// Create a copy of Space
/// with the given fields replaced by the non-null parameter values.
@ -223,16 +233,16 @@ _$SpaceCopyWith<_Space> get copyWith => __$SpaceCopyWithImpl<_Space>(this, _$ide
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Space&&(identical(other.roomData, roomData) || other.roomData == roomData)&&(identical(other.avatar, avatar) || other.avatar == avatar));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Space&&(identical(other.title, title) || other.title == title)&&(identical(other.avatar, avatar) || other.avatar == avatar)&&const DeepCollectionEquality().equals(other._children, _children)&&(identical(other.fake, fake) || other.fake == fake));
}
@override
int get hashCode => Object.hash(runtimeType,roomData,avatar);
int get hashCode => Object.hash(runtimeType,title,avatar,const DeepCollectionEquality().hash(_children),fake);
@override
String toString() {
return 'Space(roomData: $roomData, avatar: $avatar)';
return 'Space(title: $title, avatar: $avatar, children: $children, fake: $fake)';
}
@ -243,7 +253,7 @@ abstract mixin class _$SpaceCopyWith<$Res> implements $SpaceCopyWith<$Res> {
factory _$SpaceCopyWith(_Space value, $Res Function(_Space) _then) = __$SpaceCopyWithImpl;
@override @useResult
$Res call({
Room roomData, Image? avatar
String title, Widget? avatar, List<FullRoom> children, bool fake
});
@ -260,11 +270,13 @@ class __$SpaceCopyWithImpl<$Res>
/// Create a copy of Space
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? roomData = null,Object? avatar = freezed,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? title = null,Object? avatar = freezed,Object? children = null,Object? fake = null,}) {
return _then(_Space(
roomData: null == roomData ? _self.roomData : roomData // ignore: cast_nullable_to_non_nullable
as Room,avatar: freezed == avatar ? _self.avatar : avatar // ignore: cast_nullable_to_non_nullable
as Image?,
title: null == title ? _self.title : title // ignore: cast_nullable_to_non_nullable
as String,avatar: freezed == avatar ? _self.avatar : avatar // ignore: cast_nullable_to_non_nullable
as Widget?,children: null == children ? _self._children : children // ignore: cast_nullable_to_non_nullable
as List<FullRoom>,fake: null == fake ? _self.fake : fake // ignore: cast_nullable_to_non_nullable
as bool,
));
}