mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-04-25 09:39:12 -04:00
pagination
This commit is contained in:
parent
5473bd2ee4
commit
2c38fc6489
@ -11,7 +11,6 @@ class ActiveAccountInfo {
|
|||||||
const ActiveAccountInfo({
|
const ActiveAccountInfo({
|
||||||
required this.localAccount,
|
required this.localAccount,
|
||||||
required this.userLogin,
|
required this.userLogin,
|
||||||
//required this.accountRecord,
|
|
||||||
});
|
});
|
||||||
//
|
//
|
||||||
|
|
||||||
@ -41,5 +40,4 @@ class ActiveAccountInfo {
|
|||||||
//
|
//
|
||||||
final LocalAccount localAccount;
|
final LocalAccount localAccount;
|
||||||
final UserLogin userLogin;
|
final UserLogin userLogin;
|
||||||
//final DHTRecord accountRecord;
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:veilid_support/veilid_support.dart';
|
import 'package:veilid_support/veilid_support.dart';
|
||||||
|
|
||||||
|
// XXX: if we ever want to have more than one chat 'open', we should put the
|
||||||
|
// operations and state for that here.
|
||||||
|
|
||||||
class ActiveChatCubit extends Cubit<TypedKey?> {
|
class ActiveChatCubit extends Cubit<TypedKey?> {
|
||||||
ActiveChatCubit(super.initialState);
|
ActiveChatCubit(super.initialState);
|
||||||
|
|
||||||
|
272
lib/chat/cubits/chat_component_cubit.dart
Normal file
272
lib/chat/cubits/chat_component_cubit.dart
Normal file
@ -0,0 +1,272 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:async_tools/async_tools.dart';
|
||||||
|
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||||
|
import 'package:fixnum/fixnum.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
|
||||||
|
import 'package:flutter_chat_ui/flutter_chat_ui.dart';
|
||||||
|
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||||
|
import 'package:veilid_support/veilid_support.dart';
|
||||||
|
|
||||||
|
import '../../account_manager/account_manager.dart';
|
||||||
|
import '../../chat_list/chat_list.dart';
|
||||||
|
import '../../proto/proto.dart' as proto;
|
||||||
|
import '../models/chat_component_state.dart';
|
||||||
|
import '../models/message_state.dart';
|
||||||
|
import '../models/window_state.dart';
|
||||||
|
import 'cubits.dart';
|
||||||
|
|
||||||
|
const metadataKeyIdentityPublicKey = 'identityPublicKey';
|
||||||
|
const metadataKeyExpirationDuration = 'expiration';
|
||||||
|
const metadataKeyViewLimit = 'view_limit';
|
||||||
|
const metadataKeyAttachments = 'attachments';
|
||||||
|
|
||||||
|
class ChatComponentCubit extends Cubit<ChatComponentState> {
|
||||||
|
ChatComponentCubit._({
|
||||||
|
required SingleContactMessagesCubit messagesCubit,
|
||||||
|
required types.User localUser,
|
||||||
|
required IMap<TypedKey, types.User> remoteUsers,
|
||||||
|
}) : _messagesCubit = messagesCubit,
|
||||||
|
super(ChatComponentState(
|
||||||
|
chatKey: GlobalKey<ChatState>(),
|
||||||
|
scrollController: AutoScrollController(),
|
||||||
|
localUser: localUser,
|
||||||
|
remoteUsers: remoteUsers,
|
||||||
|
messageWindow: const AsyncLoading(),
|
||||||
|
title: '',
|
||||||
|
)) {
|
||||||
|
// Async Init
|
||||||
|
_initWait.add(_init);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ignore: prefer_constructors_over_static_methods
|
||||||
|
static ChatComponentCubit singleContact(
|
||||||
|
{required ActiveAccountInfo activeAccountInfo,
|
||||||
|
required proto.Account accountRecordInfo,
|
||||||
|
required ActiveConversationState activeConversationState,
|
||||||
|
required SingleContactMessagesCubit messagesCubit}) {
|
||||||
|
// Make local 'User'
|
||||||
|
final localUserIdentityKey =
|
||||||
|
activeAccountInfo.localAccount.identityMaster.identityPublicTypedKey();
|
||||||
|
final localUser = types.User(
|
||||||
|
id: localUserIdentityKey.toString(),
|
||||||
|
firstName: accountRecordInfo.profile.name,
|
||||||
|
metadata: {metadataKeyIdentityPublicKey: localUserIdentityKey});
|
||||||
|
// Make remote 'User's
|
||||||
|
final remoteUsers = {
|
||||||
|
activeConversationState.contact.identityPublicKey.toVeilid(): types.User(
|
||||||
|
id: activeConversationState.contact.identityPublicKey
|
||||||
|
.toVeilid()
|
||||||
|
.toString(),
|
||||||
|
firstName: activeConversationState.contact.editedProfile.name,
|
||||||
|
metadata: {
|
||||||
|
metadataKeyIdentityPublicKey:
|
||||||
|
activeConversationState.contact.identityPublicKey.toVeilid()
|
||||||
|
})
|
||||||
|
}.toIMap();
|
||||||
|
|
||||||
|
return ChatComponentCubit._(
|
||||||
|
messagesCubit: messagesCubit,
|
||||||
|
localUser: localUser,
|
||||||
|
remoteUsers: remoteUsers,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _init() async {
|
||||||
|
_messagesSubscription = _messagesCubit.stream.listen((messagesState) {
|
||||||
|
emit(state.copyWith(
|
||||||
|
messageWindow: _convertMessages(messagesState),
|
||||||
|
));
|
||||||
|
});
|
||||||
|
emit(state.copyWith(
|
||||||
|
messageWindow: _convertMessages(_messagesCubit.state),
|
||||||
|
title: _getTitle(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> close() async {
|
||||||
|
await _initWait();
|
||||||
|
await _messagesSubscription.cancel();
|
||||||
|
await super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Public Interface
|
||||||
|
|
||||||
|
// Set the tail position of the log for pagination.
|
||||||
|
// If tail is 0, the end of the log is used.
|
||||||
|
// If tail is negative, the position is subtracted from the current log
|
||||||
|
// length.
|
||||||
|
// If tail is positive, the position is absolute from the head of the log
|
||||||
|
// If follow is enabled, the tail offset will update when the log changes
|
||||||
|
Future<void> setWindow(
|
||||||
|
{int? tail, int? count, bool? follow, bool forceRefresh = false}) async {
|
||||||
|
//await _initWait();
|
||||||
|
await _messagesCubit.setWindow(
|
||||||
|
tail: tail, count: count, follow: follow, forceRefresh: forceRefresh);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send a message
|
||||||
|
void sendMessage(types.PartialText message) {
|
||||||
|
final text = message.text;
|
||||||
|
|
||||||
|
final replyId = (message.repliedMessage != null)
|
||||||
|
? base64UrlNoPadDecode(message.repliedMessage!.id)
|
||||||
|
: null;
|
||||||
|
Timestamp? expiration;
|
||||||
|
int? viewLimit;
|
||||||
|
List<proto.Attachment>? attachments;
|
||||||
|
final metadata = message.metadata;
|
||||||
|
if (metadata != null) {
|
||||||
|
final expirationValue =
|
||||||
|
metadata[metadataKeyExpirationDuration] as TimestampDuration?;
|
||||||
|
if (expirationValue != null) {
|
||||||
|
expiration = Veilid.instance.now().offset(expirationValue);
|
||||||
|
}
|
||||||
|
final viewLimitValue = metadata[metadataKeyViewLimit] as int?;
|
||||||
|
if (viewLimitValue != null) {
|
||||||
|
viewLimit = viewLimitValue;
|
||||||
|
}
|
||||||
|
final attachmentsValue =
|
||||||
|
metadata[metadataKeyAttachments] as List<proto.Attachment>?;
|
||||||
|
if (attachmentsValue != null) {
|
||||||
|
attachments = attachmentsValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_addTextMessage(
|
||||||
|
text: text,
|
||||||
|
replyId: replyId,
|
||||||
|
expiration: expiration,
|
||||||
|
viewLimit: viewLimit,
|
||||||
|
attachments: attachments ?? []);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run a chat command
|
||||||
|
void runCommand(String command) {
|
||||||
|
_messagesCubit.runCommand(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Private Implementation
|
||||||
|
|
||||||
|
String _getTitle() {
|
||||||
|
if (state.remoteUsers.length == 1) {
|
||||||
|
final remoteUser = state.remoteUsers.values.first;
|
||||||
|
return remoteUser.firstName ?? '<unnamed>';
|
||||||
|
} else {
|
||||||
|
return '<group chat with ${state.remoteUsers.length} users>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
types.Message? _messageStateToChatMessage(MessageState message) {
|
||||||
|
final authorIdentityPublicKey = message.content.author.toVeilid();
|
||||||
|
final author =
|
||||||
|
state.remoteUsers[authorIdentityPublicKey] ?? state.localUser;
|
||||||
|
|
||||||
|
types.Status? status;
|
||||||
|
if (message.sendState != null) {
|
||||||
|
assert(author == state.localUser,
|
||||||
|
'send state should only be on sent messages');
|
||||||
|
switch (message.sendState!) {
|
||||||
|
case MessageSendState.sending:
|
||||||
|
status = types.Status.sending;
|
||||||
|
case MessageSendState.sent:
|
||||||
|
status = types.Status.sent;
|
||||||
|
case MessageSendState.delivered:
|
||||||
|
status = types.Status.delivered;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (message.content.whichKind()) {
|
||||||
|
case proto.Message_Kind.text:
|
||||||
|
final contextText = message.content.text;
|
||||||
|
final textMessage = types.TextMessage(
|
||||||
|
author: author,
|
||||||
|
createdAt:
|
||||||
|
(message.sentTimestamp.value ~/ BigInt.from(1000)).toInt(),
|
||||||
|
id: message.content.authorUniqueIdString,
|
||||||
|
text: contextText.text,
|
||||||
|
showStatus: status != null,
|
||||||
|
status: status);
|
||||||
|
return textMessage;
|
||||||
|
case proto.Message_Kind.secret:
|
||||||
|
case proto.Message_Kind.delete:
|
||||||
|
case proto.Message_Kind.erase:
|
||||||
|
case proto.Message_Kind.settings:
|
||||||
|
case proto.Message_Kind.permissions:
|
||||||
|
case proto.Message_Kind.membership:
|
||||||
|
case proto.Message_Kind.moderation:
|
||||||
|
case proto.Message_Kind.notSet:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AsyncValue<WindowState<types.Message>> _convertMessages(
|
||||||
|
AsyncValue<WindowState<MessageState>> avMessagesState) {
|
||||||
|
final asError = avMessagesState.asError;
|
||||||
|
if (asError != null) {
|
||||||
|
return AsyncValue.error(asError.error, asError.stackTrace);
|
||||||
|
} else if (avMessagesState.asLoading != null) {
|
||||||
|
return const AsyncValue.loading();
|
||||||
|
}
|
||||||
|
final messagesState = avMessagesState.asData!.value;
|
||||||
|
|
||||||
|
// Convert protobuf messages to chat messages
|
||||||
|
final chatMessages = <types.Message>[];
|
||||||
|
final tsSet = <String>{};
|
||||||
|
for (final message in messagesState.window) {
|
||||||
|
final chatMessage = _messageStateToChatMessage(message);
|
||||||
|
if (chatMessage == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
chatMessages.insert(0, chatMessage);
|
||||||
|
if (!tsSet.add(chatMessage.id)) {
|
||||||
|
// ignore: avoid_print
|
||||||
|
print('duplicate id found: ${chatMessage.id}:\n'
|
||||||
|
'Messages:\n${messagesState.window}\n'
|
||||||
|
'ChatMessages:\n$chatMessages');
|
||||||
|
assert(false, 'should not have duplicate id');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AsyncValue.data(WindowState<types.Message>(
|
||||||
|
window: chatMessages.toIList(),
|
||||||
|
length: messagesState.length,
|
||||||
|
windowTail: messagesState.windowTail,
|
||||||
|
windowCount: messagesState.windowCount,
|
||||||
|
follow: messagesState.follow));
|
||||||
|
}
|
||||||
|
|
||||||
|
void _addTextMessage(
|
||||||
|
{required String text,
|
||||||
|
String? topic,
|
||||||
|
Uint8List? replyId,
|
||||||
|
Timestamp? expiration,
|
||||||
|
int? viewLimit,
|
||||||
|
List<proto.Attachment> attachments = const []}) {
|
||||||
|
final protoMessageText = proto.Message_Text()..text = text;
|
||||||
|
if (topic != null) {
|
||||||
|
protoMessageText.topic = topic;
|
||||||
|
}
|
||||||
|
if (replyId != null) {
|
||||||
|
protoMessageText.replyId = replyId;
|
||||||
|
}
|
||||||
|
protoMessageText
|
||||||
|
..expiration = expiration?.toInt64() ?? Int64.ZERO
|
||||||
|
..viewLimit = viewLimit ?? 0;
|
||||||
|
protoMessageText.attachments.addAll(attachments);
|
||||||
|
|
||||||
|
_messagesCubit.sendTextMessage(messageText: protoMessageText);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
final _initWait = WaitSet<void>();
|
||||||
|
final SingleContactMessagesCubit _messagesCubit;
|
||||||
|
late StreamSubscription<SingleContactMessagesState> _messagesSubscription;
|
||||||
|
double scrollOffset = 0;
|
||||||
|
}
|
@ -1,2 +1,3 @@
|
|||||||
export 'active_chat_cubit.dart';
|
export 'active_chat_cubit.dart';
|
||||||
|
export 'chat_component_cubit.dart';
|
||||||
export 'single_contact_messages_cubit.dart';
|
export 'single_contact_messages_cubit.dart';
|
||||||
|
@ -44,7 +44,7 @@ class RenderStateElement {
|
|||||||
bool sentOffline;
|
bool sentOffline;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef SingleContactMessagesState = AsyncValue<MessagesState>;
|
typedef SingleContactMessagesState = AsyncValue<WindowState<MessageState>>;
|
||||||
|
|
||||||
// Cubit that processes single-contact chats
|
// Cubit that processes single-contact chats
|
||||||
// Builds the reconciled chat record from the local and remote conversation keys
|
// Builds the reconciled chat record from the local and remote conversation keys
|
||||||
@ -189,6 +189,9 @@ class SingleContactMessagesCubit extends Cubit<SingleContactMessagesState> {
|
|||||||
Future<void> setWindow(
|
Future<void> setWindow(
|
||||||
{int? tail, int? count, bool? follow, bool forceRefresh = false}) async {
|
{int? tail, int? count, bool? follow, bool forceRefresh = false}) async {
|
||||||
await _initWait();
|
await _initWait();
|
||||||
|
|
||||||
|
print('setWindow: tail=$tail count=$count, follow=$follow');
|
||||||
|
|
||||||
await _reconciledMessagesCubit!.setWindow(
|
await _reconciledMessagesCubit!.setWindow(
|
||||||
tail: tail, count: count, follow: follow, forceRefresh: forceRefresh);
|
tail: tail, count: count, follow: follow, forceRefresh: forceRefresh);
|
||||||
}
|
}
|
||||||
@ -358,8 +361,8 @@ class SingleContactMessagesCubit extends Cubit<SingleContactMessagesState> {
|
|||||||
.toIList();
|
.toIList();
|
||||||
|
|
||||||
// Emit the rendered state
|
// Emit the rendered state
|
||||||
emit(AsyncValue.data(MessagesState(
|
emit(AsyncValue.data(WindowState<MessageState>(
|
||||||
windowMessages: messages,
|
window: messages,
|
||||||
length: reconciledMessages.length,
|
length: reconciledMessages.length,
|
||||||
windowTail: reconciledMessages.windowTail,
|
windowTail: reconciledMessages.windowTail,
|
||||||
windowCount: reconciledMessages.windowCount,
|
windowCount: reconciledMessages.windowCount,
|
||||||
|
34
lib/chat/models/chat_component_state.dart
Normal file
34
lib/chat/models/chat_component_state.dart
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import 'package:async_tools/async_tools.dart';
|
||||||
|
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_chat_types/flutter_chat_types.dart' show Message, User;
|
||||||
|
import 'package:flutter_chat_ui/flutter_chat_ui.dart' show ChatState;
|
||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||||
|
import 'package:veilid_support/veilid_support.dart';
|
||||||
|
|
||||||
|
import 'window_state.dart';
|
||||||
|
|
||||||
|
part 'chat_component_state.freezed.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class ChatComponentState with _$ChatComponentState {
|
||||||
|
const factory ChatComponentState(
|
||||||
|
{
|
||||||
|
// GlobalKey for the chat
|
||||||
|
required GlobalKey<ChatState> chatKey,
|
||||||
|
// ScrollController for the chat
|
||||||
|
required AutoScrollController scrollController,
|
||||||
|
// Local user
|
||||||
|
required User localUser,
|
||||||
|
// Remote users
|
||||||
|
required IMap<TypedKey, User> remoteUsers,
|
||||||
|
// Messages state
|
||||||
|
required AsyncValue<WindowState<Message>> messageWindow,
|
||||||
|
// Title of the chat
|
||||||
|
required String title}) = _ChatComponentState;
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ChatComponentStateExt on ChatComponentState {
|
||||||
|
//
|
||||||
|
}
|
267
lib/chat/models/chat_component_state.freezed.dart
Normal file
267
lib/chat/models/chat_component_state.freezed.dart
Normal file
@ -0,0 +1,267 @@
|
|||||||
|
// 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 'chat_component_state.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#adding-getters-and-methods-to-our-models');
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$ChatComponentState {
|
||||||
|
// GlobalKey for the chat
|
||||||
|
GlobalKey<ChatState> get chatKey =>
|
||||||
|
throw _privateConstructorUsedError; // ScrollController for the chat
|
||||||
|
AutoScrollController get scrollController =>
|
||||||
|
throw _privateConstructorUsedError; // Local user
|
||||||
|
User get localUser => throw _privateConstructorUsedError; // Remote users
|
||||||
|
IMap<Typed<FixedEncodedString43>, User> get remoteUsers =>
|
||||||
|
throw _privateConstructorUsedError; // Messages state
|
||||||
|
AsyncValue<WindowState<Message>> get messageWindow =>
|
||||||
|
throw _privateConstructorUsedError; // Title of the chat
|
||||||
|
String get title => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
$ChatComponentStateCopyWith<ChatComponentState> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $ChatComponentStateCopyWith<$Res> {
|
||||||
|
factory $ChatComponentStateCopyWith(
|
||||||
|
ChatComponentState value, $Res Function(ChatComponentState) then) =
|
||||||
|
_$ChatComponentStateCopyWithImpl<$Res, ChatComponentState>;
|
||||||
|
@useResult
|
||||||
|
$Res call(
|
||||||
|
{GlobalKey<ChatState> chatKey,
|
||||||
|
AutoScrollController scrollController,
|
||||||
|
User localUser,
|
||||||
|
IMap<Typed<FixedEncodedString43>, User> remoteUsers,
|
||||||
|
AsyncValue<WindowState<Message>> messageWindow,
|
||||||
|
String title});
|
||||||
|
|
||||||
|
$AsyncValueCopyWith<WindowState<Message>, $Res> get messageWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$ChatComponentStateCopyWithImpl<$Res, $Val extends ChatComponentState>
|
||||||
|
implements $ChatComponentStateCopyWith<$Res> {
|
||||||
|
_$ChatComponentStateCopyWithImpl(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? chatKey = null,
|
||||||
|
Object? scrollController = null,
|
||||||
|
Object? localUser = null,
|
||||||
|
Object? remoteUsers = null,
|
||||||
|
Object? messageWindow = null,
|
||||||
|
Object? title = null,
|
||||||
|
}) {
|
||||||
|
return _then(_value.copyWith(
|
||||||
|
chatKey: null == chatKey
|
||||||
|
? _value.chatKey
|
||||||
|
: chatKey // ignore: cast_nullable_to_non_nullable
|
||||||
|
as GlobalKey<ChatState>,
|
||||||
|
scrollController: null == scrollController
|
||||||
|
? _value.scrollController
|
||||||
|
: scrollController // ignore: cast_nullable_to_non_nullable
|
||||||
|
as AutoScrollController,
|
||||||
|
localUser: null == localUser
|
||||||
|
? _value.localUser
|
||||||
|
: localUser // ignore: cast_nullable_to_non_nullable
|
||||||
|
as User,
|
||||||
|
remoteUsers: null == remoteUsers
|
||||||
|
? _value.remoteUsers
|
||||||
|
: remoteUsers // ignore: cast_nullable_to_non_nullable
|
||||||
|
as IMap<Typed<FixedEncodedString43>, User>,
|
||||||
|
messageWindow: null == messageWindow
|
||||||
|
? _value.messageWindow
|
||||||
|
: messageWindow // ignore: cast_nullable_to_non_nullable
|
||||||
|
as AsyncValue<WindowState<Message>>,
|
||||||
|
title: null == title
|
||||||
|
? _value.title
|
||||||
|
: title // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
) as $Val);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
$AsyncValueCopyWith<WindowState<Message>, $Res> get messageWindow {
|
||||||
|
return $AsyncValueCopyWith<WindowState<Message>, $Res>(_value.messageWindow,
|
||||||
|
(value) {
|
||||||
|
return _then(_value.copyWith(messageWindow: value) as $Val);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$ChatComponentStateImplCopyWith<$Res>
|
||||||
|
implements $ChatComponentStateCopyWith<$Res> {
|
||||||
|
factory _$$ChatComponentStateImplCopyWith(_$ChatComponentStateImpl value,
|
||||||
|
$Res Function(_$ChatComponentStateImpl) then) =
|
||||||
|
__$$ChatComponentStateImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call(
|
||||||
|
{GlobalKey<ChatState> chatKey,
|
||||||
|
AutoScrollController scrollController,
|
||||||
|
User localUser,
|
||||||
|
IMap<Typed<FixedEncodedString43>, User> remoteUsers,
|
||||||
|
AsyncValue<WindowState<Message>> messageWindow,
|
||||||
|
String title});
|
||||||
|
|
||||||
|
@override
|
||||||
|
$AsyncValueCopyWith<WindowState<Message>, $Res> get messageWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$ChatComponentStateImplCopyWithImpl<$Res>
|
||||||
|
extends _$ChatComponentStateCopyWithImpl<$Res, _$ChatComponentStateImpl>
|
||||||
|
implements _$$ChatComponentStateImplCopyWith<$Res> {
|
||||||
|
__$$ChatComponentStateImplCopyWithImpl(_$ChatComponentStateImpl _value,
|
||||||
|
$Res Function(_$ChatComponentStateImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? chatKey = null,
|
||||||
|
Object? scrollController = null,
|
||||||
|
Object? localUser = null,
|
||||||
|
Object? remoteUsers = null,
|
||||||
|
Object? messageWindow = null,
|
||||||
|
Object? title = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$ChatComponentStateImpl(
|
||||||
|
chatKey: null == chatKey
|
||||||
|
? _value.chatKey
|
||||||
|
: chatKey // ignore: cast_nullable_to_non_nullable
|
||||||
|
as GlobalKey<ChatState>,
|
||||||
|
scrollController: null == scrollController
|
||||||
|
? _value.scrollController
|
||||||
|
: scrollController // ignore: cast_nullable_to_non_nullable
|
||||||
|
as AutoScrollController,
|
||||||
|
localUser: null == localUser
|
||||||
|
? _value.localUser
|
||||||
|
: localUser // ignore: cast_nullable_to_non_nullable
|
||||||
|
as User,
|
||||||
|
remoteUsers: null == remoteUsers
|
||||||
|
? _value.remoteUsers
|
||||||
|
: remoteUsers // ignore: cast_nullable_to_non_nullable
|
||||||
|
as IMap<Typed<FixedEncodedString43>, User>,
|
||||||
|
messageWindow: null == messageWindow
|
||||||
|
? _value.messageWindow
|
||||||
|
: messageWindow // ignore: cast_nullable_to_non_nullable
|
||||||
|
as AsyncValue<WindowState<Message>>,
|
||||||
|
title: null == title
|
||||||
|
? _value.title
|
||||||
|
: title // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$ChatComponentStateImpl implements _ChatComponentState {
|
||||||
|
const _$ChatComponentStateImpl(
|
||||||
|
{required this.chatKey,
|
||||||
|
required this.scrollController,
|
||||||
|
required this.localUser,
|
||||||
|
required this.remoteUsers,
|
||||||
|
required this.messageWindow,
|
||||||
|
required this.title});
|
||||||
|
|
||||||
|
// GlobalKey for the chat
|
||||||
|
@override
|
||||||
|
final GlobalKey<ChatState> chatKey;
|
||||||
|
// ScrollController for the chat
|
||||||
|
@override
|
||||||
|
final AutoScrollController scrollController;
|
||||||
|
// Local user
|
||||||
|
@override
|
||||||
|
final User localUser;
|
||||||
|
// Remote users
|
||||||
|
@override
|
||||||
|
final IMap<Typed<FixedEncodedString43>, User> remoteUsers;
|
||||||
|
// Messages state
|
||||||
|
@override
|
||||||
|
final AsyncValue<WindowState<Message>> messageWindow;
|
||||||
|
// Title of the chat
|
||||||
|
@override
|
||||||
|
final String title;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'ChatComponentState(chatKey: $chatKey, scrollController: $scrollController, localUser: $localUser, remoteUsers: $remoteUsers, messageWindow: $messageWindow, title: $title)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$ChatComponentStateImpl &&
|
||||||
|
(identical(other.chatKey, chatKey) || other.chatKey == chatKey) &&
|
||||||
|
(identical(other.scrollController, scrollController) ||
|
||||||
|
other.scrollController == scrollController) &&
|
||||||
|
(identical(other.localUser, localUser) ||
|
||||||
|
other.localUser == localUser) &&
|
||||||
|
(identical(other.remoteUsers, remoteUsers) ||
|
||||||
|
other.remoteUsers == remoteUsers) &&
|
||||||
|
(identical(other.messageWindow, messageWindow) ||
|
||||||
|
other.messageWindow == messageWindow) &&
|
||||||
|
(identical(other.title, title) || other.title == title));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, chatKey, scrollController,
|
||||||
|
localUser, remoteUsers, messageWindow, title);
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$ChatComponentStateImplCopyWith<_$ChatComponentStateImpl> get copyWith =>
|
||||||
|
__$$ChatComponentStateImplCopyWithImpl<_$ChatComponentStateImpl>(
|
||||||
|
this, _$identity);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _ChatComponentState implements ChatComponentState {
|
||||||
|
const factory _ChatComponentState(
|
||||||
|
{required final GlobalKey<ChatState> chatKey,
|
||||||
|
required final AutoScrollController scrollController,
|
||||||
|
required final User localUser,
|
||||||
|
required final IMap<Typed<FixedEncodedString43>, User> remoteUsers,
|
||||||
|
required final AsyncValue<WindowState<Message>> messageWindow,
|
||||||
|
required final String title}) = _$ChatComponentStateImpl;
|
||||||
|
|
||||||
|
@override // GlobalKey for the chat
|
||||||
|
GlobalKey<ChatState> get chatKey;
|
||||||
|
@override // ScrollController for the chat
|
||||||
|
AutoScrollController get scrollController;
|
||||||
|
@override // Local user
|
||||||
|
User get localUser;
|
||||||
|
@override // Remote users
|
||||||
|
IMap<Typed<FixedEncodedString43>, User> get remoteUsers;
|
||||||
|
@override // Messages state
|
||||||
|
AsyncValue<WindowState<Message>> get messageWindow;
|
||||||
|
@override // Title of the chat
|
||||||
|
String get title;
|
||||||
|
@override
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
_$$ChatComponentStateImplCopyWith<_$ChatComponentStateImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
@ -1,27 +0,0 @@
|
|||||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
|
|
||||||
import 'message_state.dart';
|
|
||||||
|
|
||||||
part 'messages_state.freezed.dart';
|
|
||||||
part 'messages_state.g.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class MessagesState with _$MessagesState {
|
|
||||||
const factory MessagesState({
|
|
||||||
// List of messages in the window
|
|
||||||
required IList<MessageState> windowMessages,
|
|
||||||
// Total number of messages
|
|
||||||
required int length,
|
|
||||||
// One past the end of the last element
|
|
||||||
required int windowTail,
|
|
||||||
// The total number of elements to try to keep in 'messages'
|
|
||||||
required int windowCount,
|
|
||||||
// If we should have the tail following the array
|
|
||||||
required bool follow,
|
|
||||||
}) = _MessagesState;
|
|
||||||
|
|
||||||
factory MessagesState.fromJson(dynamic json) =>
|
|
||||||
_$MessagesStateFromJson(json as Map<String, dynamic>);
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
||||||
|
|
||||||
part of 'messages_state.dart';
|
|
||||||
|
|
||||||
// **************************************************************************
|
|
||||||
// JsonSerializableGenerator
|
|
||||||
// **************************************************************************
|
|
||||||
|
|
||||||
_$MessagesStateImpl _$$MessagesStateImplFromJson(Map<String, dynamic> json) =>
|
|
||||||
_$MessagesStateImpl(
|
|
||||||
windowMessages: IList<MessageState>.fromJson(
|
|
||||||
json['window_messages'], (value) => MessageState.fromJson(value)),
|
|
||||||
length: (json['length'] as num).toInt(),
|
|
||||||
windowTail: (json['window_tail'] as num).toInt(),
|
|
||||||
windowCount: (json['window_count'] as num).toInt(),
|
|
||||||
follow: json['follow'] as bool,
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$$MessagesStateImplToJson(_$MessagesStateImpl instance) =>
|
|
||||||
<String, dynamic>{
|
|
||||||
'window_messages': instance.windowMessages.toJson(
|
|
||||||
(value) => value.toJson(),
|
|
||||||
),
|
|
||||||
'length': instance.length,
|
|
||||||
'window_tail': instance.windowTail,
|
|
||||||
'window_count': instance.windowCount,
|
|
||||||
'follow': instance.follow,
|
|
||||||
};
|
|
@ -1,2 +1,3 @@
|
|||||||
|
export 'chat_component_state.dart';
|
||||||
export 'message_state.dart';
|
export 'message_state.dart';
|
||||||
export 'messages_state.dart';
|
export 'window_state.dart';
|
||||||
|
27
lib/chat/models/window_state.dart
Normal file
27
lib/chat/models/window_state.dart
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
|
part 'window_state.freezed.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class WindowState<T> with _$WindowState<T> {
|
||||||
|
const factory WindowState({
|
||||||
|
// List of objects in the window
|
||||||
|
required IList<T> window,
|
||||||
|
// Total number of objects (windowTail max)
|
||||||
|
required int length,
|
||||||
|
// One past the end of the last element
|
||||||
|
required int windowTail,
|
||||||
|
// The total number of elements to try to keep in the window
|
||||||
|
required int windowCount,
|
||||||
|
// If we should have the tail following the array
|
||||||
|
required bool follow,
|
||||||
|
}) = _WindowState;
|
||||||
|
}
|
||||||
|
|
||||||
|
extension WindowStateExt<T> on WindowState<T> {
|
||||||
|
int get windowEnd => (length == 0) ? -1 : (windowTail - 1) % length;
|
||||||
|
int get windowStart =>
|
||||||
|
(length == 0) ? 0 : (windowTail - window.length) % length;
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
// ignore_for_file: type=lint
|
// 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
|
// 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 'messages_state.dart';
|
part of 'window_state.dart';
|
||||||
|
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
// FreezedGenerator
|
// FreezedGenerator
|
||||||
@ -14,37 +14,32 @@ T _$identity<T>(T value) => value;
|
|||||||
final _privateConstructorUsedError = UnsupportedError(
|
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#adding-getters-and-methods-to-our-models');
|
'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#adding-getters-and-methods-to-our-models');
|
||||||
|
|
||||||
MessagesState _$MessagesStateFromJson(Map<String, dynamic> json) {
|
|
||||||
return _MessagesState.fromJson(json);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$MessagesState {
|
mixin _$WindowState<T> {
|
||||||
// List of messages in the window
|
// List of objects in the window
|
||||||
IList<MessageState> get windowMessages =>
|
IList<T> get window =>
|
||||||
throw _privateConstructorUsedError; // Total number of messages
|
throw _privateConstructorUsedError; // Total number of objects (windowTail max)
|
||||||
int get length =>
|
int get length =>
|
||||||
throw _privateConstructorUsedError; // One past the end of the last element
|
throw _privateConstructorUsedError; // One past the end of the last element
|
||||||
int get windowTail =>
|
int get windowTail =>
|
||||||
throw _privateConstructorUsedError; // The total number of elements to try to keep in 'messages'
|
throw _privateConstructorUsedError; // The total number of elements to try to keep in the window
|
||||||
int get windowCount =>
|
int get windowCount =>
|
||||||
throw _privateConstructorUsedError; // If we should have the tail following the array
|
throw _privateConstructorUsedError; // If we should have the tail following the array
|
||||||
bool get follow => throw _privateConstructorUsedError;
|
bool get follow => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
$MessagesStateCopyWith<MessagesState> get copyWith =>
|
$WindowStateCopyWith<T, WindowState<T>> get copyWith =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract class $MessagesStateCopyWith<$Res> {
|
abstract class $WindowStateCopyWith<T, $Res> {
|
||||||
factory $MessagesStateCopyWith(
|
factory $WindowStateCopyWith(
|
||||||
MessagesState value, $Res Function(MessagesState) then) =
|
WindowState<T> value, $Res Function(WindowState<T>) then) =
|
||||||
_$MessagesStateCopyWithImpl<$Res, MessagesState>;
|
_$WindowStateCopyWithImpl<T, $Res, WindowState<T>>;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call(
|
$Res call(
|
||||||
{IList<MessageState> windowMessages,
|
{IList<T> window,
|
||||||
int length,
|
int length,
|
||||||
int windowTail,
|
int windowTail,
|
||||||
int windowCount,
|
int windowCount,
|
||||||
@ -52,9 +47,9 @@ abstract class $MessagesStateCopyWith<$Res> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$MessagesStateCopyWithImpl<$Res, $Val extends MessagesState>
|
class _$WindowStateCopyWithImpl<T, $Res, $Val extends WindowState<T>>
|
||||||
implements $MessagesStateCopyWith<$Res> {
|
implements $WindowStateCopyWith<T, $Res> {
|
||||||
_$MessagesStateCopyWithImpl(this._value, this._then);
|
_$WindowStateCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
// ignore: unused_field
|
// ignore: unused_field
|
||||||
final $Val _value;
|
final $Val _value;
|
||||||
@ -64,17 +59,17 @@ class _$MessagesStateCopyWithImpl<$Res, $Val extends MessagesState>
|
|||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
@override
|
@override
|
||||||
$Res call({
|
$Res call({
|
||||||
Object? windowMessages = null,
|
Object? window = null,
|
||||||
Object? length = null,
|
Object? length = null,
|
||||||
Object? windowTail = null,
|
Object? windowTail = null,
|
||||||
Object? windowCount = null,
|
Object? windowCount = null,
|
||||||
Object? follow = null,
|
Object? follow = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_value.copyWith(
|
return _then(_value.copyWith(
|
||||||
windowMessages: null == windowMessages
|
window: null == window
|
||||||
? _value.windowMessages
|
? _value.window
|
||||||
: windowMessages // ignore: cast_nullable_to_non_nullable
|
: window // ignore: cast_nullable_to_non_nullable
|
||||||
as IList<MessageState>,
|
as IList<T>,
|
||||||
length: null == length
|
length: null == length
|
||||||
? _value.length
|
? _value.length
|
||||||
: length // ignore: cast_nullable_to_non_nullable
|
: length // ignore: cast_nullable_to_non_nullable
|
||||||
@ -96,15 +91,15 @@ class _$MessagesStateCopyWithImpl<$Res, $Val extends MessagesState>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract class _$$MessagesStateImplCopyWith<$Res>
|
abstract class _$$WindowStateImplCopyWith<T, $Res>
|
||||||
implements $MessagesStateCopyWith<$Res> {
|
implements $WindowStateCopyWith<T, $Res> {
|
||||||
factory _$$MessagesStateImplCopyWith(
|
factory _$$WindowStateImplCopyWith(_$WindowStateImpl<T> value,
|
||||||
_$MessagesStateImpl value, $Res Function(_$MessagesStateImpl) then) =
|
$Res Function(_$WindowStateImpl<T>) then) =
|
||||||
__$$MessagesStateImplCopyWithImpl<$Res>;
|
__$$WindowStateImplCopyWithImpl<T, $Res>;
|
||||||
@override
|
@override
|
||||||
@useResult
|
@useResult
|
||||||
$Res call(
|
$Res call(
|
||||||
{IList<MessageState> windowMessages,
|
{IList<T> window,
|
||||||
int length,
|
int length,
|
||||||
int windowTail,
|
int windowTail,
|
||||||
int windowCount,
|
int windowCount,
|
||||||
@ -112,27 +107,27 @@ abstract class _$$MessagesStateImplCopyWith<$Res>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class __$$MessagesStateImplCopyWithImpl<$Res>
|
class __$$WindowStateImplCopyWithImpl<T, $Res>
|
||||||
extends _$MessagesStateCopyWithImpl<$Res, _$MessagesStateImpl>
|
extends _$WindowStateCopyWithImpl<T, $Res, _$WindowStateImpl<T>>
|
||||||
implements _$$MessagesStateImplCopyWith<$Res> {
|
implements _$$WindowStateImplCopyWith<T, $Res> {
|
||||||
__$$MessagesStateImplCopyWithImpl(
|
__$$WindowStateImplCopyWithImpl(
|
||||||
_$MessagesStateImpl _value, $Res Function(_$MessagesStateImpl) _then)
|
_$WindowStateImpl<T> _value, $Res Function(_$WindowStateImpl<T>) _then)
|
||||||
: super(_value, _then);
|
: super(_value, _then);
|
||||||
|
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
@override
|
@override
|
||||||
$Res call({
|
$Res call({
|
||||||
Object? windowMessages = null,
|
Object? window = null,
|
||||||
Object? length = null,
|
Object? length = null,
|
||||||
Object? windowTail = null,
|
Object? windowTail = null,
|
||||||
Object? windowCount = null,
|
Object? windowCount = null,
|
||||||
Object? follow = null,
|
Object? follow = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$MessagesStateImpl(
|
return _then(_$WindowStateImpl<T>(
|
||||||
windowMessages: null == windowMessages
|
window: null == window
|
||||||
? _value.windowMessages
|
? _value.window
|
||||||
: windowMessages // ignore: cast_nullable_to_non_nullable
|
: window // ignore: cast_nullable_to_non_nullable
|
||||||
as IList<MessageState>,
|
as IList<T>,
|
||||||
length: null == length
|
length: null == length
|
||||||
? _value.length
|
? _value.length
|
||||||
: length // ignore: cast_nullable_to_non_nullable
|
: length // ignore: cast_nullable_to_non_nullable
|
||||||
@ -154,30 +149,27 @@ class __$$MessagesStateImplCopyWithImpl<$Res>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@JsonSerializable()
|
|
||||||
class _$MessagesStateImpl
|
class _$WindowStateImpl<T>
|
||||||
with DiagnosticableTreeMixin
|
with DiagnosticableTreeMixin
|
||||||
implements _MessagesState {
|
implements _WindowState<T> {
|
||||||
const _$MessagesStateImpl(
|
const _$WindowStateImpl(
|
||||||
{required this.windowMessages,
|
{required this.window,
|
||||||
required this.length,
|
required this.length,
|
||||||
required this.windowTail,
|
required this.windowTail,
|
||||||
required this.windowCount,
|
required this.windowCount,
|
||||||
required this.follow});
|
required this.follow});
|
||||||
|
|
||||||
factory _$MessagesStateImpl.fromJson(Map<String, dynamic> json) =>
|
// List of objects in the window
|
||||||
_$$MessagesStateImplFromJson(json);
|
|
||||||
|
|
||||||
// List of messages in the window
|
|
||||||
@override
|
@override
|
||||||
final IList<MessageState> windowMessages;
|
final IList<T> window;
|
||||||
// Total number of messages
|
// Total number of objects (windowTail max)
|
||||||
@override
|
@override
|
||||||
final int length;
|
final int length;
|
||||||
// One past the end of the last element
|
// One past the end of the last element
|
||||||
@override
|
@override
|
||||||
final int windowTail;
|
final int windowTail;
|
||||||
// The total number of elements to try to keep in 'messages'
|
// The total number of elements to try to keep in the window
|
||||||
@override
|
@override
|
||||||
final int windowCount;
|
final int windowCount;
|
||||||
// If we should have the tail following the array
|
// If we should have the tail following the array
|
||||||
@ -186,15 +178,15 @@ class _$MessagesStateImpl
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
|
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
|
||||||
return 'MessagesState(windowMessages: $windowMessages, length: $length, windowTail: $windowTail, windowCount: $windowCount, follow: $follow)';
|
return 'WindowState<$T>(window: $window, length: $length, windowTail: $windowTail, windowCount: $windowCount, follow: $follow)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||||
super.debugFillProperties(properties);
|
super.debugFillProperties(properties);
|
||||||
properties
|
properties
|
||||||
..add(DiagnosticsProperty('type', 'MessagesState'))
|
..add(DiagnosticsProperty('type', 'WindowState<$T>'))
|
||||||
..add(DiagnosticsProperty('windowMessages', windowMessages))
|
..add(DiagnosticsProperty('window', window))
|
||||||
..add(DiagnosticsProperty('length', length))
|
..add(DiagnosticsProperty('length', length))
|
||||||
..add(DiagnosticsProperty('windowTail', windowTail))
|
..add(DiagnosticsProperty('windowTail', windowTail))
|
||||||
..add(DiagnosticsProperty('windowCount', windowCount))
|
..add(DiagnosticsProperty('windowCount', windowCount))
|
||||||
@ -205,9 +197,8 @@ class _$MessagesStateImpl
|
|||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) ||
|
return identical(this, other) ||
|
||||||
(other.runtimeType == runtimeType &&
|
(other.runtimeType == runtimeType &&
|
||||||
other is _$MessagesStateImpl &&
|
other is _$WindowStateImpl<T> &&
|
||||||
const DeepCollectionEquality()
|
const DeepCollectionEquality().equals(other.window, window) &&
|
||||||
.equals(other.windowMessages, windowMessages) &&
|
|
||||||
(identical(other.length, length) || other.length == length) &&
|
(identical(other.length, length) || other.length == length) &&
|
||||||
(identical(other.windowTail, windowTail) ||
|
(identical(other.windowTail, windowTail) ||
|
||||||
other.windowTail == windowTail) &&
|
other.windowTail == windowTail) &&
|
||||||
@ -216,11 +207,10 @@ class _$MessagesStateImpl
|
|||||||
(identical(other.follow, follow) || other.follow == follow));
|
(identical(other.follow, follow) || other.follow == follow));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(
|
int get hashCode => Object.hash(
|
||||||
runtimeType,
|
runtimeType,
|
||||||
const DeepCollectionEquality().hash(windowMessages),
|
const DeepCollectionEquality().hash(window),
|
||||||
length,
|
length,
|
||||||
windowTail,
|
windowTail,
|
||||||
windowCount,
|
windowCount,
|
||||||
@ -229,40 +219,31 @@ class _$MessagesStateImpl
|
|||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
_$$MessagesStateImplCopyWith<_$MessagesStateImpl> get copyWith =>
|
_$$WindowStateImplCopyWith<T, _$WindowStateImpl<T>> get copyWith =>
|
||||||
__$$MessagesStateImplCopyWithImpl<_$MessagesStateImpl>(this, _$identity);
|
__$$WindowStateImplCopyWithImpl<T, _$WindowStateImpl<T>>(
|
||||||
|
this, _$identity);
|
||||||
@override
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return _$$MessagesStateImplToJson(
|
|
||||||
this,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class _MessagesState implements MessagesState {
|
abstract class _WindowState<T> implements WindowState<T> {
|
||||||
const factory _MessagesState(
|
const factory _WindowState(
|
||||||
{required final IList<MessageState> windowMessages,
|
{required final IList<T> window,
|
||||||
required final int length,
|
required final int length,
|
||||||
required final int windowTail,
|
required final int windowTail,
|
||||||
required final int windowCount,
|
required final int windowCount,
|
||||||
required final bool follow}) = _$MessagesStateImpl;
|
required final bool follow}) = _$WindowStateImpl<T>;
|
||||||
|
|
||||||
factory _MessagesState.fromJson(Map<String, dynamic> json) =
|
@override // List of objects in the window
|
||||||
_$MessagesStateImpl.fromJson;
|
IList<T> get window;
|
||||||
|
@override // Total number of objects (windowTail max)
|
||||||
@override // List of messages in the window
|
|
||||||
IList<MessageState> get windowMessages;
|
|
||||||
@override // Total number of messages
|
|
||||||
int get length;
|
int get length;
|
||||||
@override // One past the end of the last element
|
@override // One past the end of the last element
|
||||||
int get windowTail;
|
int get windowTail;
|
||||||
@override // The total number of elements to try to keep in 'messages'
|
@override // The total number of elements to try to keep in the window
|
||||||
int get windowCount;
|
int get windowCount;
|
||||||
@override // If we should have the tail following the array
|
@override // If we should have the tail following the array
|
||||||
bool get follow;
|
bool get follow;
|
||||||
@override
|
@override
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
_$$MessagesStateImplCopyWith<_$MessagesStateImpl> get copyWith =>
|
_$$WindowStateImplCopyWith<T, _$WindowStateImpl<T>> get copyWith =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
}
|
}
|
@ -1,320 +0,0 @@
|
|||||||
import 'dart:math';
|
|
||||||
|
|
||||||
import 'package:async_tools/async_tools.dart';
|
|
||||||
import 'package:awesome_extensions/awesome_extensions.dart';
|
|
||||||
import 'package:fixnum/fixnum.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
|
|
||||||
import 'package:flutter_chat_ui/flutter_chat_ui.dart';
|
|
||||||
import 'package:veilid_support/veilid_support.dart';
|
|
||||||
|
|
||||||
import '../../account_manager/account_manager.dart';
|
|
||||||
import '../../chat_list/chat_list.dart';
|
|
||||||
import '../../contacts/contacts.dart';
|
|
||||||
import '../../proto/proto.dart' as proto;
|
|
||||||
import '../../theme/theme.dart';
|
|
||||||
import '../chat.dart';
|
|
||||||
|
|
||||||
const String metadataKeyExpirationDuration = 'expiration';
|
|
||||||
const String metadataKeyViewLimit = 'view_limit';
|
|
||||||
const String metadataKeyAttachments = 'attachments';
|
|
||||||
|
|
||||||
class ChatComponent extends StatelessWidget {
|
|
||||||
const ChatComponent._(
|
|
||||||
{required TypedKey localUserIdentityKey,
|
|
||||||
required SingleContactMessagesCubit messagesCubit,
|
|
||||||
required SingleContactMessagesState messagesState,
|
|
||||||
required types.User localUser,
|
|
||||||
required types.User remoteUser,
|
|
||||||
super.key})
|
|
||||||
: _localUserIdentityKey = localUserIdentityKey,
|
|
||||||
_messagesCubit = messagesCubit,
|
|
||||||
_messagesState = messagesState,
|
|
||||||
_localUser = localUser,
|
|
||||||
_remoteUser = remoteUser;
|
|
||||||
|
|
||||||
final TypedKey _localUserIdentityKey;
|
|
||||||
final SingleContactMessagesCubit _messagesCubit;
|
|
||||||
final SingleContactMessagesState _messagesState;
|
|
||||||
final types.User _localUser;
|
|
||||||
final types.User _remoteUser;
|
|
||||||
|
|
||||||
// Builder wrapper function that takes care of state management requirements
|
|
||||||
static Widget builder(
|
|
||||||
{required TypedKey localConversationRecordKey, Key? key}) =>
|
|
||||||
Builder(builder: (context) {
|
|
||||||
// Get all watched dependendies
|
|
||||||
final activeAccountInfo = context.watch<ActiveAccountInfo>();
|
|
||||||
final accountRecordInfo =
|
|
||||||
context.watch<AccountRecordCubit>().state.asData?.value;
|
|
||||||
if (accountRecordInfo == null) {
|
|
||||||
return debugPage('should always have an account record here');
|
|
||||||
}
|
|
||||||
final contactList =
|
|
||||||
context.watch<ContactListCubit>().state.state.asData?.value;
|
|
||||||
if (contactList == null) {
|
|
||||||
return debugPage('should always have a contact list here');
|
|
||||||
}
|
|
||||||
final avconversation = context.select<ActiveConversationsBlocMapCubit,
|
|
||||||
AsyncValue<ActiveConversationState>?>(
|
|
||||||
(x) => x.state[localConversationRecordKey]);
|
|
||||||
if (avconversation == null) {
|
|
||||||
return waitingPage();
|
|
||||||
}
|
|
||||||
final conversation = avconversation.asData?.value;
|
|
||||||
if (conversation == null) {
|
|
||||||
return avconversation.buildNotData();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make flutter_chat_ui 'User's
|
|
||||||
final localUserIdentityKey = activeAccountInfo
|
|
||||||
.localAccount.identityMaster
|
|
||||||
.identityPublicTypedKey();
|
|
||||||
|
|
||||||
final localUser = types.User(
|
|
||||||
id: localUserIdentityKey.toString(),
|
|
||||||
firstName: accountRecordInfo.profile.name,
|
|
||||||
);
|
|
||||||
final editedName = conversation.contact.editedProfile.name;
|
|
||||||
final remoteUser = types.User(
|
|
||||||
id: conversation.contact.identityPublicKey.toVeilid().toString(),
|
|
||||||
firstName: editedName);
|
|
||||||
|
|
||||||
// Get the messages cubit
|
|
||||||
final messages = context.select<ActiveSingleContactChatBlocMapCubit,
|
|
||||||
(SingleContactMessagesCubit, SingleContactMessagesState)?>(
|
|
||||||
(x) => x.tryOperate(localConversationRecordKey,
|
|
||||||
closure: (cubit) => (cubit, cubit.state)));
|
|
||||||
|
|
||||||
// Get the messages to display
|
|
||||||
// and ensure it is safe to operate() on the MessageCubit for this chat
|
|
||||||
if (messages == null) {
|
|
||||||
return waitingPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ChatComponent._(
|
|
||||||
localUserIdentityKey: localUserIdentityKey,
|
|
||||||
messagesCubit: messages.$1,
|
|
||||||
messagesState: messages.$2,
|
|
||||||
localUser: localUser,
|
|
||||||
remoteUser: remoteUser,
|
|
||||||
key: key);
|
|
||||||
});
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
types.Message? messageStateToChatMessage(MessageState message) {
|
|
||||||
final isLocal = message.content.author.toVeilid() == _localUserIdentityKey;
|
|
||||||
|
|
||||||
types.Status? status;
|
|
||||||
if (message.sendState != null) {
|
|
||||||
assert(isLocal, 'send state should only be on sent messages');
|
|
||||||
switch (message.sendState!) {
|
|
||||||
case MessageSendState.sending:
|
|
||||||
status = types.Status.sending;
|
|
||||||
case MessageSendState.sent:
|
|
||||||
status = types.Status.sent;
|
|
||||||
case MessageSendState.delivered:
|
|
||||||
status = types.Status.delivered;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (message.content.whichKind()) {
|
|
||||||
case proto.Message_Kind.text:
|
|
||||||
final contextText = message.content.text;
|
|
||||||
final textMessage = types.TextMessage(
|
|
||||||
author: isLocal ? _localUser : _remoteUser,
|
|
||||||
createdAt:
|
|
||||||
(message.sentTimestamp.value ~/ BigInt.from(1000)).toInt(),
|
|
||||||
id: message.content.authorUniqueIdString,
|
|
||||||
text: contextText.text,
|
|
||||||
showStatus: status != null,
|
|
||||||
status: status);
|
|
||||||
return textMessage;
|
|
||||||
case proto.Message_Kind.secret:
|
|
||||||
case proto.Message_Kind.delete:
|
|
||||||
case proto.Message_Kind.erase:
|
|
||||||
case proto.Message_Kind.settings:
|
|
||||||
case proto.Message_Kind.permissions:
|
|
||||||
case proto.Message_Kind.membership:
|
|
||||||
case proto.Message_Kind.moderation:
|
|
||||||
case proto.Message_Kind.notSet:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _addTextMessage(
|
|
||||||
{required String text,
|
|
||||||
String? topic,
|
|
||||||
Uint8List? replyId,
|
|
||||||
Timestamp? expiration,
|
|
||||||
int? viewLimit,
|
|
||||||
List<proto.Attachment> attachments = const []}) {
|
|
||||||
final protoMessageText = proto.Message_Text()..text = text;
|
|
||||||
if (topic != null) {
|
|
||||||
protoMessageText.topic = topic;
|
|
||||||
}
|
|
||||||
if (replyId != null) {
|
|
||||||
protoMessageText.replyId = replyId;
|
|
||||||
}
|
|
||||||
protoMessageText
|
|
||||||
..expiration = expiration?.toInt64() ?? Int64.ZERO
|
|
||||||
..viewLimit = viewLimit ?? 0;
|
|
||||||
protoMessageText.attachments.addAll(attachments);
|
|
||||||
|
|
||||||
_messagesCubit.sendTextMessage(messageText: protoMessageText);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _sendMessage(types.PartialText message) {
|
|
||||||
final text = message.text;
|
|
||||||
|
|
||||||
final replyId = (message.repliedMessage != null)
|
|
||||||
? base64UrlNoPadDecode(message.repliedMessage!.id)
|
|
||||||
: null;
|
|
||||||
Timestamp? expiration;
|
|
||||||
int? viewLimit;
|
|
||||||
List<proto.Attachment>? attachments;
|
|
||||||
final metadata = message.metadata;
|
|
||||||
if (metadata != null) {
|
|
||||||
final expirationValue =
|
|
||||||
metadata[metadataKeyExpirationDuration] as TimestampDuration?;
|
|
||||||
if (expirationValue != null) {
|
|
||||||
expiration = Veilid.instance.now().offset(expirationValue);
|
|
||||||
}
|
|
||||||
final viewLimitValue = metadata[metadataKeyViewLimit] as int?;
|
|
||||||
if (viewLimitValue != null) {
|
|
||||||
viewLimit = viewLimitValue;
|
|
||||||
}
|
|
||||||
final attachmentsValue =
|
|
||||||
metadata[metadataKeyAttachments] as List<proto.Attachment>?;
|
|
||||||
if (attachmentsValue != null) {
|
|
||||||
attachments = attachmentsValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_addTextMessage(
|
|
||||||
text: text,
|
|
||||||
replyId: replyId,
|
|
||||||
expiration: expiration,
|
|
||||||
viewLimit: viewLimit,
|
|
||||||
attachments: attachments ?? []);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _handleSendPressed(types.PartialText message) {
|
|
||||||
final text = message.text;
|
|
||||||
|
|
||||||
if (text.startsWith('/')) {
|
|
||||||
_messagesCubit.runCommand(text);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_sendMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// void _handleAttachmentPressed() async {
|
|
||||||
// //
|
|
||||||
// }
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final theme = Theme.of(context);
|
|
||||||
final scale = theme.extension<ScaleScheme>()!;
|
|
||||||
final textTheme = Theme.of(context).textTheme;
|
|
||||||
final chatTheme = makeChatTheme(scale, textTheme);
|
|
||||||
|
|
||||||
final messagesState = _messagesState.asData?.value;
|
|
||||||
if (messagesState == null) {
|
|
||||||
return _messagesState.buildNotData();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert protobuf messages to chat messages
|
|
||||||
final chatMessages = <types.Message>[];
|
|
||||||
final tsSet = <String>{};
|
|
||||||
for (final message in messagesState.windowMessages) {
|
|
||||||
final chatMessage = messageStateToChatMessage(message);
|
|
||||||
if (chatMessage == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
chatMessages.insert(0, chatMessage);
|
|
||||||
if (!tsSet.add(chatMessage.id)) {
|
|
||||||
// ignore: avoid_print
|
|
||||||
print('duplicate id found: ${chatMessage.id}:\n'
|
|
||||||
'Messages:\n${messagesState.windowMessages}\n'
|
|
||||||
'ChatMessages:\n$chatMessages');
|
|
||||||
assert(false, 'should not have duplicate id');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final isLastPage =
|
|
||||||
(messagesState.windowTail - messagesState.windowMessages.length) <= 0;
|
|
||||||
final follow = messagesState.windowTail == 0 ||
|
|
||||||
messagesState.windowTail == messagesState.length; xxx finish calculating pagination and get scroll position here somehow
|
|
||||||
|
|
||||||
return DefaultTextStyle(
|
|
||||||
style: textTheme.bodySmall!,
|
|
||||||
child: Align(
|
|
||||||
alignment: AlignmentDirectional.centerEnd,
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
height: 48,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: scale.primaryScale.subtleBorder,
|
|
||||||
),
|
|
||||||
child: Row(children: [
|
|
||||||
Align(
|
|
||||||
alignment: AlignmentDirectional.centerStart,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(
|
|
||||||
16, 0, 16, 0),
|
|
||||||
child: Text(_remoteUser.firstName!,
|
|
||||||
textAlign: TextAlign.start,
|
|
||||||
style: textTheme.titleMedium!.copyWith(
|
|
||||||
color: scale.primaryScale.borderText)),
|
|
||||||
)),
|
|
||||||
const Spacer(),
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.close,
|
|
||||||
color: scale.primaryScale.borderText),
|
|
||||||
onPressed: () async {
|
|
||||||
context.read<ActiveChatCubit>().setActiveChat(null);
|
|
||||||
}).paddingLTRB(16, 0, 16, 0)
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: DecoratedBox(
|
|
||||||
decoration: const BoxDecoration(),
|
|
||||||
child: Chat(
|
|
||||||
theme: chatTheme,
|
|
||||||
messages: chatMessages,
|
|
||||||
onEndReached: () async {
|
|
||||||
final tail = await _messagesCubit.setWindow(
|
|
||||||
tail: max(
|
|
||||||
0,
|
|
||||||
(messagesState.windowTail -
|
|
||||||
(messagesState.windowCount ~/ 2))),
|
|
||||||
count: messagesState.windowCount,
|
|
||||||
follow: follow);
|
|
||||||
},
|
|
||||||
isLastPage: isLastPage,
|
|
||||||
//onAttachmentPressed: _handleAttachmentPressed,
|
|
||||||
//onMessageTap: _handleMessageTap,
|
|
||||||
//onPreviewDataFetched: _handlePreviewDataFetched,
|
|
||||||
onSendPressed: _handleSendPressed,
|
|
||||||
//showUserAvatars: false,
|
|
||||||
//showUserNames: true,
|
|
||||||
user: _localUser,
|
|
||||||
emptyState: const EmptyChatWidget()),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
294
lib/chat/views/chat_component_widget.dart
Normal file
294
lib/chat/views/chat_component_widget.dart
Normal file
@ -0,0 +1,294 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:async_tools/async_tools.dart';
|
||||||
|
import 'package:awesome_extensions/awesome_extensions.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
|
||||||
|
import 'package:flutter_chat_ui/flutter_chat_ui.dart';
|
||||||
|
import 'package:veilid_support/veilid_support.dart';
|
||||||
|
|
||||||
|
import '../../account_manager/account_manager.dart';
|
||||||
|
import '../../chat_list/chat_list.dart';
|
||||||
|
import '../../theme/theme.dart';
|
||||||
|
import '../chat.dart';
|
||||||
|
|
||||||
|
const onEndReachedThreshold = 0.75;
|
||||||
|
|
||||||
|
class ChatComponentWidget extends StatelessWidget {
|
||||||
|
const ChatComponentWidget._({required super.key});
|
||||||
|
|
||||||
|
// Builder wrapper function that takes care of state management requirements
|
||||||
|
static Widget builder(
|
||||||
|
{required TypedKey localConversationRecordKey, Key? key}) =>
|
||||||
|
Builder(builder: (context) {
|
||||||
|
// Get all watched dependendies
|
||||||
|
final activeAccountInfo = context.watch<ActiveAccountInfo>();
|
||||||
|
final accountRecordInfo =
|
||||||
|
context.watch<AccountRecordCubit>().state.asData?.value;
|
||||||
|
if (accountRecordInfo == null) {
|
||||||
|
return debugPage('should always have an account record here');
|
||||||
|
}
|
||||||
|
|
||||||
|
final avconversation = context.select<ActiveConversationsBlocMapCubit,
|
||||||
|
AsyncValue<ActiveConversationState>?>(
|
||||||
|
(x) => x.state[localConversationRecordKey]);
|
||||||
|
if (avconversation == null) {
|
||||||
|
return waitingPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
final activeConversationState = avconversation.asData?.value;
|
||||||
|
if (activeConversationState == null) {
|
||||||
|
return avconversation.buildNotData();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the messages cubit
|
||||||
|
final messagesCubit = context.select<
|
||||||
|
ActiveSingleContactChatBlocMapCubit,
|
||||||
|
SingleContactMessagesCubit?>(
|
||||||
|
(x) => x.tryOperate(localConversationRecordKey,
|
||||||
|
closure: (cubit) => cubit));
|
||||||
|
if (messagesCubit == null) {
|
||||||
|
return waitingPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make chat component state
|
||||||
|
return BlocProvider(
|
||||||
|
create: (context) => ChatComponentCubit.singleContact(
|
||||||
|
activeAccountInfo: activeAccountInfo,
|
||||||
|
accountRecordInfo: accountRecordInfo,
|
||||||
|
activeConversationState: activeConversationState,
|
||||||
|
messagesCubit: messagesCubit,
|
||||||
|
),
|
||||||
|
child: ChatComponentWidget._(key: key));
|
||||||
|
});
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void _handleSendPressed(
|
||||||
|
ChatComponentCubit chatComponentCubit, types.PartialText message) {
|
||||||
|
final text = message.text;
|
||||||
|
|
||||||
|
if (text.startsWith('/')) {
|
||||||
|
chatComponentCubit.runCommand(text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
chatComponentCubit.sendMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// void _handleAttachmentPressed() async {
|
||||||
|
// //
|
||||||
|
// }
|
||||||
|
|
||||||
|
Future<void> _handlePageForward(
|
||||||
|
ChatComponentCubit chatComponentCubit,
|
||||||
|
WindowState<types.Message> messageWindow,
|
||||||
|
ScrollNotification notification) async {
|
||||||
|
print(
|
||||||
|
'_handlePageForward: messagesState.length=${messageWindow.length} messagesState.windowTail=${messageWindow.windowTail} messagesState.windowCount=${messageWindow.windowCount} ScrollNotification=$notification');
|
||||||
|
|
||||||
|
// Go forward a page
|
||||||
|
final tail = min(messageWindow.length,
|
||||||
|
messageWindow.windowTail + (messageWindow.windowCount ~/ 4)) %
|
||||||
|
messageWindow.length;
|
||||||
|
|
||||||
|
// Set follow
|
||||||
|
final follow = messageWindow.length == 0 ||
|
||||||
|
tail == 0; // xxx incorporate scroll position
|
||||||
|
|
||||||
|
// final scrollOffset = (notification.metrics.maxScrollExtent -
|
||||||
|
// notification.metrics.minScrollExtent) *
|
||||||
|
// (1.0 - onEndReachedThreshold);
|
||||||
|
|
||||||
|
// chatComponentCubit.scrollOffset = scrollOffset;
|
||||||
|
|
||||||
|
await chatComponentCubit.setWindow(
|
||||||
|
tail: tail, count: messageWindow.windowCount, follow: follow);
|
||||||
|
|
||||||
|
// chatComponentCubit.state.scrollController.position.jumpTo(
|
||||||
|
// chatComponentCubit.state.scrollController.offset + scrollOffset);
|
||||||
|
|
||||||
|
//chatComponentCubit.scrollOffset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handlePageBackward(
|
||||||
|
ChatComponentCubit chatComponentCubit,
|
||||||
|
WindowState<types.Message> messageWindow,
|
||||||
|
ScrollNotification notification,
|
||||||
|
) async {
|
||||||
|
print(
|
||||||
|
'_handlePageBackward: messagesState.length=${messageWindow.length} messagesState.windowTail=${messageWindow.windowTail} messagesState.windowCount=${messageWindow.windowCount} ScrollNotification=$notification');
|
||||||
|
|
||||||
|
// Go back a page
|
||||||
|
final tail = max(
|
||||||
|
messageWindow.windowCount,
|
||||||
|
(messageWindow.windowTail - (messageWindow.windowCount ~/ 4)) %
|
||||||
|
messageWindow.length);
|
||||||
|
|
||||||
|
// Set follow
|
||||||
|
final follow = messageWindow.length == 0 ||
|
||||||
|
tail == 0; // xxx incorporate scroll position
|
||||||
|
|
||||||
|
// final scrollOffset = -(notification.metrics.maxScrollExtent -
|
||||||
|
// notification.metrics.minScrollExtent) *
|
||||||
|
// (1.0 - onEndReachedThreshold);
|
||||||
|
|
||||||
|
// chatComponentCubit.scrollOffset = scrollOffset;
|
||||||
|
|
||||||
|
await chatComponentCubit.setWindow(
|
||||||
|
tail: tail, count: messageWindow.windowCount, follow: follow);
|
||||||
|
|
||||||
|
// chatComponentCubit.scrollOffset = scrollOffset;
|
||||||
|
|
||||||
|
// chatComponentCubit.state.scrollController.position.jumpTo(
|
||||||
|
// chatComponentCubit.state.scrollController.offset + scrollOffset);
|
||||||
|
|
||||||
|
//chatComponentCubit.scrollOffset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
final scale = theme.extension<ScaleScheme>()!;
|
||||||
|
final textTheme = Theme.of(context).textTheme;
|
||||||
|
final chatTheme = makeChatTheme(scale, textTheme);
|
||||||
|
|
||||||
|
// Get the enclosing chat component cubit that contains our state
|
||||||
|
// (created by ChatComponentWidget.builder())
|
||||||
|
final chatComponentCubit = context.watch<ChatComponentCubit>();
|
||||||
|
final chatComponentState = chatComponentCubit.state;
|
||||||
|
|
||||||
|
final messageWindow = chatComponentState.messageWindow.asData?.value;
|
||||||
|
if (messageWindow == null) {
|
||||||
|
return chatComponentState.messageWindow.buildNotData();
|
||||||
|
}
|
||||||
|
final isLastPage = messageWindow.windowStart == 0;
|
||||||
|
final isFirstPage = messageWindow.windowEnd == messageWindow.length - 1;
|
||||||
|
final title = chatComponentState.title;
|
||||||
|
|
||||||
|
if (chatComponentCubit.scrollOffset != 0) {
|
||||||
|
chatComponentState.scrollController.position.correctPixels(
|
||||||
|
chatComponentState.scrollController.position.pixels +
|
||||||
|
chatComponentCubit.scrollOffset);
|
||||||
|
|
||||||
|
chatComponentCubit.scrollOffset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DefaultTextStyle(
|
||||||
|
style: textTheme.bodySmall!,
|
||||||
|
child: Align(
|
||||||
|
alignment: AlignmentDirectional.centerEnd,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: 48,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: scale.primaryScale.subtleBorder,
|
||||||
|
),
|
||||||
|
child: Row(children: [
|
||||||
|
Align(
|
||||||
|
alignment: AlignmentDirectional.centerStart,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||||
|
16, 0, 16, 0),
|
||||||
|
child: Text(title,
|
||||||
|
textAlign: TextAlign.start,
|
||||||
|
style: textTheme.titleMedium!.copyWith(
|
||||||
|
color: scale.primaryScale.borderText)),
|
||||||
|
)),
|
||||||
|
const Spacer(),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.close,
|
||||||
|
color: scale.primaryScale.borderText),
|
||||||
|
onPressed: () async {
|
||||||
|
context.read<ActiveChatCubit>().setActiveChat(null);
|
||||||
|
}).paddingLTRB(16, 0, 16, 0)
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: DecoratedBox(
|
||||||
|
decoration: const BoxDecoration(),
|
||||||
|
child: NotificationListener<ScrollNotification>(
|
||||||
|
onNotification: (notification) {
|
||||||
|
if (chatComponentCubit.scrollOffset != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isFirstPage &&
|
||||||
|
notification.metrics.pixels <=
|
||||||
|
((notification.metrics.maxScrollExtent -
|
||||||
|
notification
|
||||||
|
.metrics.minScrollExtent) *
|
||||||
|
(1.0 - onEndReachedThreshold) +
|
||||||
|
notification.metrics.minScrollExtent)) {
|
||||||
|
//
|
||||||
|
final scrollOffset = (notification
|
||||||
|
.metrics.maxScrollExtent -
|
||||||
|
notification.metrics.minScrollExtent) *
|
||||||
|
(1.0 - onEndReachedThreshold);
|
||||||
|
|
||||||
|
chatComponentCubit.scrollOffset = scrollOffset;
|
||||||
|
|
||||||
|
//
|
||||||
|
singleFuture(chatComponentState.chatKey,
|
||||||
|
() async {
|
||||||
|
await _handlePageForward(chatComponentCubit,
|
||||||
|
messageWindow, notification);
|
||||||
|
});
|
||||||
|
} else if (!isLastPage &&
|
||||||
|
notification.metrics.pixels >=
|
||||||
|
((notification.metrics.maxScrollExtent -
|
||||||
|
notification
|
||||||
|
.metrics.minScrollExtent) *
|
||||||
|
onEndReachedThreshold +
|
||||||
|
notification.metrics.minScrollExtent)) {
|
||||||
|
//
|
||||||
|
final scrollOffset = -(notification
|
||||||
|
.metrics.maxScrollExtent -
|
||||||
|
notification.metrics.minScrollExtent) *
|
||||||
|
(1.0 - onEndReachedThreshold);
|
||||||
|
|
||||||
|
chatComponentCubit.scrollOffset = scrollOffset;
|
||||||
|
//
|
||||||
|
singleFuture(chatComponentState.chatKey,
|
||||||
|
() async {
|
||||||
|
await _handlePageBackward(chatComponentCubit,
|
||||||
|
messageWindow, notification);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
child: Chat(
|
||||||
|
key: chatComponentState.chatKey,
|
||||||
|
theme: chatTheme,
|
||||||
|
messages: messageWindow.window.toList(),
|
||||||
|
scrollToBottomOnSend: isFirstPage,
|
||||||
|
scrollController:
|
||||||
|
chatComponentState.scrollController,
|
||||||
|
// isLastPage: isLastPage,
|
||||||
|
// onEndReached: () async {
|
||||||
|
// await _handlePageBackward(
|
||||||
|
// chatComponentCubit, messageWindow);
|
||||||
|
// },
|
||||||
|
//onEndReachedThreshold: onEndReachedThreshold,
|
||||||
|
//onAttachmentPressed: _handleAttachmentPressed,
|
||||||
|
//onMessageTap: _handleMessageTap,
|
||||||
|
//onPreviewDataFetched: _handlePreviewDataFetched,
|
||||||
|
onSendPressed: (pt) =>
|
||||||
|
_handleSendPressed(chatComponentCubit, pt),
|
||||||
|
//showUserAvatars: false,
|
||||||
|
//showUserNames: true,
|
||||||
|
user: chatComponentState.localUser,
|
||||||
|
emptyState: const EmptyChatWidget())),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
export 'chat_component.dart';
|
export 'chat_component_widget.dart';
|
||||||
export 'empty_chat_widget.dart';
|
export 'empty_chat_widget.dart';
|
||||||
export 'new_chat_bottom_sheet.dart';
|
export 'new_chat_bottom_sheet.dart';
|
||||||
export 'no_conversation_widget.dart';
|
export 'no_conversation_widget.dart';
|
||||||
|
@ -33,8 +33,9 @@ class HomeAccountReadyChatState extends State<HomeAccountReadyChat> {
|
|||||||
if (activeChatLocalConversationKey == null) {
|
if (activeChatLocalConversationKey == null) {
|
||||||
return const NoConversationWidget();
|
return const NoConversationWidget();
|
||||||
}
|
}
|
||||||
return ChatComponent.builder(
|
return ChatComponentWidget.builder(
|
||||||
localConversationRecordKey: activeChatLocalConversationKey);
|
localConversationRecordKey: activeChatLocalConversationKey,
|
||||||
|
key: ValueKey(activeChatLocalConversationKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -40,12 +40,10 @@ class _HomeAccountReadyMainState extends State<HomeAccountReadyMain> {
|
|||||||
color: scale.secondaryScale.borderText,
|
color: scale.secondaryScale.borderText,
|
||||||
constraints: const BoxConstraints.expand(height: 64, width: 64),
|
constraints: const BoxConstraints.expand(height: 64, width: 64),
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
backgroundColor: MaterialStateProperty.all(
|
backgroundColor:
|
||||||
scale.primaryScale.hoverBorder),
|
WidgetStateProperty.all(scale.primaryScale.hoverBorder),
|
||||||
shape: MaterialStateProperty.all(
|
shape: WidgetStateProperty.all(const RoundedRectangleBorder(
|
||||||
const RoundedRectangleBorder(
|
borderRadius: BorderRadius.all(Radius.circular(16))))),
|
||||||
borderRadius:
|
|
||||||
BorderRadius.all(Radius.circular(16))))),
|
|
||||||
tooltip: translate('app_bar.settings_tooltip'),
|
tooltip: translate('app_bar.settings_tooltip'),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await GoRouterHelper(context).push('/settings');
|
await GoRouterHelper(context).push('/settings');
|
||||||
@ -71,8 +69,9 @@ class _HomeAccountReadyMainState extends State<HomeAccountReadyMain> {
|
|||||||
if (activeChatLocalConversationKey == null) {
|
if (activeChatLocalConversationKey == null) {
|
||||||
return const NoConversationWidget();
|
return const NoConversationWidget();
|
||||||
}
|
}
|
||||||
return ChatComponent.builder(
|
return ChatComponentWidget.builder(
|
||||||
localConversationRecordKey: activeChatLocalConversationKey);
|
localConversationRecordKey: activeChatLocalConversationKey,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore: prefer_expression_function_bodies
|
// ignore: prefer_expression_function_bodies
|
||||||
|
@ -10,7 +10,9 @@ const Map<String, LogLevel> _blocChangeLogLevels = {
|
|||||||
'TableDBArrayProtobufCubit<ReconciledMessage>': LogLevel.off,
|
'TableDBArrayProtobufCubit<ReconciledMessage>': LogLevel.off,
|
||||||
'DHTLogCubit<Message>': LogLevel.off,
|
'DHTLogCubit<Message>': LogLevel.off,
|
||||||
'SingleContactMessagesCubit': LogLevel.off,
|
'SingleContactMessagesCubit': LogLevel.off,
|
||||||
|
'ChatComponentCubit': LogLevel.off,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Map<String, LogLevel> _blocCreateCloseLogLevels = {};
|
const Map<String, LogLevel> _blocCreateCloseLogLevels = {};
|
||||||
const Map<String, LogLevel> _blocErrorLogLevels = {};
|
const Map<String, LogLevel> _blocErrorLogLevels = {};
|
||||||
|
|
||||||
|
@ -39,11 +39,13 @@ class _DHTLogWrite extends _DHTLogRead implements DHTLogWriteOperations {
|
|||||||
}
|
}
|
||||||
final bLookup = await _spine.lookupPosition(bPos);
|
final bLookup = await _spine.lookupPosition(bPos);
|
||||||
if (bLookup == null) {
|
if (bLookup == null) {
|
||||||
|
await aLookup.close();
|
||||||
throw StateError("can't lookup position b in swap of dht log");
|
throw StateError("can't lookup position b in swap of dht log");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Swap items in the segments
|
// Swap items in the segments
|
||||||
if (aLookup.shortArray == bLookup.shortArray) {
|
if (aLookup.shortArray == bLookup.shortArray) {
|
||||||
|
await bLookup.close();
|
||||||
await aLookup.scope((sa) => sa.operateWriteEventual((aWrite) async {
|
await aLookup.scope((sa) => sa.operateWriteEventual((aWrite) async {
|
||||||
await aWrite.swap(aLookup.pos, bLookup.pos);
|
await aWrite.swap(aLookup.pos, bLookup.pos);
|
||||||
return true;
|
return true;
|
||||||
@ -76,7 +78,9 @@ class _DHTLogWrite extends _DHTLogRead implements DHTLogWriteOperations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write item to the segment
|
// Write item to the segment
|
||||||
return lookup.scope((sa) => sa.operateWrite((write) async {
|
return lookup.scope((sa) async {
|
||||||
|
try {
|
||||||
|
return sa.operateWrite((write) async {
|
||||||
// If this a new segment, then clear it in case we have wrapped around
|
// If this a new segment, then clear it in case we have wrapped around
|
||||||
if (lookup.pos == 0) {
|
if (lookup.pos == 0) {
|
||||||
await write.clear();
|
await write.clear();
|
||||||
@ -85,7 +89,11 @@ class _DHTLogWrite extends _DHTLogRead implements DHTLogWriteOperations {
|
|||||||
throw StateError('appending should be at the end');
|
throw StateError('appending should be at the end');
|
||||||
}
|
}
|
||||||
return write.tryAdd(value);
|
return write.tryAdd(value);
|
||||||
}));
|
});
|
||||||
|
} on DHTExceptionTryAgain {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -110,7 +118,9 @@ class _DHTLogWrite extends _DHTLogRead implements DHTLogWriteOperations {
|
|||||||
final sublistValues = values.sublist(valueIdx, valueIdx + sacount);
|
final sublistValues = values.sublist(valueIdx, valueIdx + sacount);
|
||||||
|
|
||||||
dws.add(() async {
|
dws.add(() async {
|
||||||
final ok = await lookup.scope((sa) => sa.operateWrite((write) async {
|
final ok = await lookup.scope((sa) async {
|
||||||
|
try {
|
||||||
|
return sa.operateWrite((write) async {
|
||||||
// If this a new segment, then clear it in
|
// If this a new segment, then clear it in
|
||||||
// case we have wrapped around
|
// case we have wrapped around
|
||||||
if (lookup.pos == 0) {
|
if (lookup.pos == 0) {
|
||||||
@ -120,7 +130,11 @@ class _DHTLogWrite extends _DHTLogRead implements DHTLogWriteOperations {
|
|||||||
throw StateError('appending should be at the end');
|
throw StateError('appending should be at the end');
|
||||||
}
|
}
|
||||||
return write.tryAddAll(sublistValues);
|
return write.tryAddAll(sublistValues);
|
||||||
}));
|
});
|
||||||
|
} on DHTExceptionTryAgain {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
@ -103,6 +103,7 @@ class TableDBArrayProtobufCubit<T extends GeneratedMessage>
|
|||||||
final elements = avElements.asData!.value;
|
final elements = avElements.asData!.value;
|
||||||
emit(AsyncValue.data(TableDBArrayProtobufStateData(
|
emit(AsyncValue.data(TableDBArrayProtobufStateData(
|
||||||
windowElements: elements,
|
windowElements: elements,
|
||||||
|
length: _array.length,
|
||||||
windowTail: _tail,
|
windowTail: _tail,
|
||||||
windowCount: _count,
|
windowCount: _count,
|
||||||
follow: _follow)));
|
follow: _follow)));
|
||||||
|
95
pubspec.lock
95
pubspec.lock
@ -37,10 +37,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: archive
|
name: archive
|
||||||
sha256: ecf4273855368121b1caed0d10d4513c7241dfc813f7d3c8933b36622ae9b265
|
sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.5.1"
|
version: "3.6.1"
|
||||||
args:
|
args:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -155,18 +155,18 @@ packages:
|
|||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: build_runner
|
name: build_runner
|
||||||
sha256: "1414d6d733a85d8ad2f1dfcb3ea7945759e35a123cb99ccfac75d0758f75edfa"
|
sha256: "644dc98a0f179b872f612d3eb627924b578897c629788e858157fa5e704ca0c7"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.10"
|
version: "2.4.11"
|
||||||
build_runner_core:
|
build_runner_core:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: build_runner_core
|
name: build_runner_core
|
||||||
sha256: "4ae8ffe5ac758da294ecf1802f2aff01558d8b1b00616aa7538ea9a8a5d50799"
|
sha256: e3c79f69a64bdfcd8a776a3c28db4eb6e3fb5356d013ae5eb2e52007706d5dbe
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.3.0"
|
version: "7.3.1"
|
||||||
built_collection:
|
built_collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -219,10 +219,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: camera_android
|
name: camera_android
|
||||||
sha256: b350ac087f111467e705b2b76cc1322f7f5bdc122aa83b4b243b0872f390d229
|
sha256: "3af7f0b55f184d392d2eec238aaa30552ebeef2915e5e094f5488bf50d6d7ca2"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.10.9+2"
|
version: "0.10.9+3"
|
||||||
camera_avfoundation:
|
camera_avfoundation:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -251,10 +251,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: change_case
|
name: change_case
|
||||||
sha256: "47c48c36f95f20c6d0ba03efabceff261d05026cca322cc2c4c01c343371b5bb"
|
sha256: "99cfdf2018c627c8a3af5a23ea4c414eb69c75c31322d23b9660ebc3cf30b514"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
version: "2.1.0"
|
||||||
characters:
|
characters:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -403,10 +403,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: fast_immutable_collections
|
name: fast_immutable_collections
|
||||||
sha256: "533806a7f0c624c2e479d05d3fdce4c87109a7cd0db39b8cc3830d3a2e8dedc7"
|
sha256: c3c73f4f989d3302066e4ec94e6ec73b5dc872592d02194f49f1352d64126b8c
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "10.2.3"
|
version: "10.2.4"
|
||||||
ffi:
|
ffi:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -471,19 +471,18 @@ packages:
|
|||||||
flutter_chat_ui:
|
flutter_chat_ui:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: flutter_chat_ui
|
path: "../flutter_chat_ui"
|
||||||
sha256: "40fb37acc328dd179eadc3d67bf8bd2d950dc0da34464aa8d48e8707e0234c09"
|
relative: true
|
||||||
url: "https://pub.dev"
|
source: path
|
||||||
source: hosted
|
|
||||||
version: "1.6.13"
|
version: "1.6.13"
|
||||||
flutter_form_builder:
|
flutter_form_builder:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: flutter_form_builder
|
name: flutter_form_builder
|
||||||
sha256: "560eb5e367d81170c6ade1e7ae63ecc5167936ae2cdfaae8a345e91bce19d2f2"
|
sha256: "447f8808f68070f7df968e8063aada3c9d2e90e789b5b70f3b44e4b315212656"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "9.2.1"
|
version: "9.3.0"
|
||||||
flutter_hooks:
|
flutter_hooks:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -533,10 +532,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: flutter_plugin_android_lifecycle
|
name: flutter_plugin_android_lifecycle
|
||||||
sha256: "8cf40eebf5dec866a6d1956ad7b4f7016e6c0cc69847ab946833b7d43743809f"
|
sha256: c6b0b4c05c458e1c01ad9bcc14041dd7b1f6783d487be4386f793f47a8a4d03e
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.19"
|
version: "2.0.20"
|
||||||
flutter_shaders:
|
flutter_shaders:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -573,10 +572,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: flutter_translate
|
name: flutter_translate
|
||||||
sha256: "8b1c449bf6d17753e6f188185f735ebc0a328d21d745878a43be66857de8ebb3"
|
sha256: bc09db690098879e3f90eb3aac3499e5282f32d5f9d8f1cc597d67bbc1e065ef
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.4"
|
version: "4.1.0"
|
||||||
flutter_web_plugins:
|
flutter_web_plugins:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -586,10 +585,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: form_builder_validators
|
name: form_builder_validators
|
||||||
sha256: "19aa5282b7cede82d0025ab031a98d0554b84aa2ba40f12013471a3b3e22bf02"
|
sha256: "475853a177bfc832ec12551f752fd0001278358a6d42d2364681ff15f48f67cf"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "9.1.0"
|
version: "10.0.1"
|
||||||
freezed:
|
freezed:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
@ -634,10 +633,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: go_router
|
name: go_router
|
||||||
sha256: aa073287b8f43553678e6fa9e8bb9c83212ff76e09542129a8099bbc8db4df65
|
sha256: abec47eb8c8c36ebf41d0a4c64dbbe7f956e39a012b3aafc530e951bdc12fe3f
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "14.1.2"
|
version: "14.1.4"
|
||||||
graphs:
|
graphs:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -706,10 +705,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: image
|
name: image
|
||||||
sha256: "4c68bfd5ae83e700b5204c1e74451e7bf3cf750e6843c6e158289cf56bda018e"
|
sha256: "2237616a36c0d69aef7549ab439b833fb7f9fb9fc861af2cc9ac3eedddd69ca8"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.1.7"
|
version: "4.2.0"
|
||||||
intl:
|
intl:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -826,10 +825,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: motion_toast
|
name: motion_toast
|
||||||
sha256: "4763b2aa3499d0bf00ffd9737479b73141d0397f532542893156efb4a5ac1994"
|
sha256: "8dc8af93c606d0a08f2592591164f4a761099c5470e589f25689de6c601f124e"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.9.1"
|
version: "2.10.0"
|
||||||
nested:
|
nested:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -890,10 +889,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path_provider_android
|
name: path_provider_android
|
||||||
sha256: a248d8146ee5983446bf03ed5ea8f6533129a12b11f12057ad1b4a67a2b3b41d
|
sha256: "9c96da072b421e98183f9ea7464898428e764bc0ce5567f27ec8693442e72514"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.4"
|
version: "2.2.5"
|
||||||
path_provider_foundation:
|
path_provider_foundation:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1018,10 +1017,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: pubspec_parse
|
name: pubspec_parse
|
||||||
sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367
|
sha256: c799b721d79eb6ee6fa56f00c04b472dcd44a30d258fac2174a6ec57302678f8
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.3"
|
version: "1.3.0"
|
||||||
qr:
|
qr:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1095,7 +1094,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.9"
|
version: "0.1.9"
|
||||||
scroll_to_index:
|
scroll_to_index:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: scroll_to_index
|
name: scroll_to_index
|
||||||
sha256: b707546e7500d9f070d63e5acf74fd437ec7eeeb68d3412ef7b0afada0b4f176
|
sha256: b707546e7500d9f070d63e5acf74fd437ec7eeeb68d3412ef7b0afada0b4f176
|
||||||
@ -1106,10 +1105,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: searchable_listview
|
name: searchable_listview
|
||||||
sha256: dfa6358f5e097f45b5b51a160cb6189e112e3abe0f728f4740349cd3b6575617
|
sha256: "5e547f2a3f88f99a798cfe64882cfce51496d8f3177bea4829dd7bcf3fa8910d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.13.0"
|
version: "2.14.0"
|
||||||
share_plus:
|
share_plus:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -1138,10 +1137,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shared_preferences_android
|
name: shared_preferences_android
|
||||||
sha256: "1ee8bf911094a1b592de7ab29add6f826a7331fb854273d55918693d5364a1f2"
|
sha256: "93d0ec9dd902d85f326068e6a899487d1f65ffcd5798721a95330b26c8131577"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.2"
|
version: "2.2.3"
|
||||||
shared_preferences_foundation:
|
shared_preferences_foundation:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1392,26 +1391,26 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: universal_platform
|
name: universal_platform
|
||||||
sha256: d315be0f6641898b280ffa34e2ddb14f3d12b1a37882557869646e0cc363d0cc
|
sha256: "64e16458a0ea9b99260ceb5467a214c1f298d647c659af1bff6d3bf82536b1ec"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.0+1"
|
version: "1.1.0"
|
||||||
url_launcher:
|
url_launcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher
|
name: url_launcher
|
||||||
sha256: "6ce1e04375be4eed30548f10a315826fd933c1e493206eab82eed01f438c8d2e"
|
sha256: "21b704ce5fa560ea9f3b525b43601c678728ba46725bab9b01187b4831377ed3"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.2.6"
|
version: "6.3.0"
|
||||||
url_launcher_android:
|
url_launcher_android:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher_android
|
name: url_launcher_android
|
||||||
sha256: "17cd5e205ea615e2c6ea7a77323a11712dffa0720a8a90540db57a01347f9ad9"
|
sha256: ceb2625f0c24ade6ef6778d1de0b2e44f2db71fded235eb52295247feba8c5cf
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.3.2"
|
version: "6.3.3"
|
||||||
url_launcher_ios:
|
url_launcher_ios:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1542,10 +1541,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: web_socket
|
name: web_socket
|
||||||
sha256: "217f49b5213796cb508d6a942a5dc604ce1cb6a0a6b3d8cb3f0c314f0ecea712"
|
sha256: "24301d8c293ce6fe327ffe6f59d8fd8834735f0ec36e4fd383ec7ff8a64aa078"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.4"
|
version: "0.1.5"
|
||||||
web_socket_channel:
|
web_socket_channel:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1628,4 +1627,4 @@ packages:
|
|||||||
version: "1.1.2"
|
version: "1.1.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.4.0 <4.0.0"
|
dart: ">=3.4.0 <4.0.0"
|
||||||
flutter: ">=3.19.1"
|
flutter: ">=3.22.0"
|
||||||
|
40
pubspec.yaml
40
pubspec.yaml
@ -10,30 +10,33 @@ environment:
|
|||||||
dependencies:
|
dependencies:
|
||||||
animated_theme_switcher: ^2.0.10
|
animated_theme_switcher: ^2.0.10
|
||||||
ansicolor: ^2.0.2
|
ansicolor: ^2.0.2
|
||||||
archive: ^3.5.1
|
archive: ^3.6.1
|
||||||
async_tools: ^0.1.1
|
async_tools: ^0.1.1
|
||||||
awesome_extensions: ^2.0.14
|
awesome_extensions: ^2.0.16
|
||||||
badges: ^3.1.2
|
badges: ^3.1.2
|
||||||
basic_utils: ^5.7.0
|
basic_utils: ^5.7.0
|
||||||
bloc: ^8.1.4
|
bloc: ^8.1.4
|
||||||
bloc_advanced_tools: ^0.1.1
|
bloc_advanced_tools: ^0.1.1
|
||||||
blurry_modal_progress_hud: ^1.1.1
|
blurry_modal_progress_hud: ^1.1.1
|
||||||
change_case: ^2.0.1
|
change_case: ^2.1.0
|
||||||
charcode: ^1.3.1
|
charcode: ^1.3.1
|
||||||
circular_profile_avatar: ^2.0.5
|
circular_profile_avatar: ^2.0.5
|
||||||
circular_reveal_animation: ^2.0.1
|
circular_reveal_animation: ^2.0.1
|
||||||
cool_dropdown: ^2.1.0
|
cool_dropdown: ^2.1.0
|
||||||
cupertino_icons: ^1.0.8
|
cupertino_icons: ^1.0.8
|
||||||
equatable: ^2.0.5
|
equatable: ^2.0.5
|
||||||
fast_immutable_collections: ^10.2.2
|
fast_immutable_collections: ^10.2.4
|
||||||
fixnum: ^1.1.0
|
fixnum: ^1.1.0
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_animate: ^4.5.0
|
flutter_animate: ^4.5.0
|
||||||
flutter_bloc: ^8.1.5
|
flutter_bloc: ^8.1.5
|
||||||
flutter_chat_types: ^3.6.2
|
flutter_chat_types: ^3.6.2
|
||||||
flutter_chat_ui: ^1.6.12
|
flutter_chat_ui:
|
||||||
flutter_form_builder: ^9.2.1
|
git:
|
||||||
|
url: https://gitlab.com/veilid/flutter_chat_ui.git
|
||||||
|
ref: main
|
||||||
|
flutter_form_builder: ^9.3.0
|
||||||
flutter_hooks: ^0.20.5
|
flutter_hooks: ^0.20.5
|
||||||
flutter_localizations:
|
flutter_localizations:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
@ -41,18 +44,18 @@ dependencies:
|
|||||||
flutter_slidable: ^3.1.0
|
flutter_slidable: ^3.1.0
|
||||||
flutter_spinkit: ^5.2.1
|
flutter_spinkit: ^5.2.1
|
||||||
flutter_svg: ^2.0.10+1
|
flutter_svg: ^2.0.10+1
|
||||||
flutter_translate: ^4.0.4
|
flutter_translate: ^4.1.0
|
||||||
form_builder_validators: ^9.1.0
|
form_builder_validators: ^10.0.1
|
||||||
freezed_annotation: ^2.4.1
|
freezed_annotation: ^2.4.1
|
||||||
go_router: ^14.1.2
|
go_router: ^14.1.4
|
||||||
hydrated_bloc: ^9.1.5
|
hydrated_bloc: ^9.1.5
|
||||||
image: ^4.1.7
|
image: ^4.2.0
|
||||||
intl: ^0.18.1
|
intl: ^0.19.0
|
||||||
json_annotation: ^4.9.0
|
json_annotation: ^4.9.0
|
||||||
loggy: ^2.0.3
|
loggy: ^2.0.3
|
||||||
meta: ^1.11.0
|
meta: ^1.12.0
|
||||||
mobile_scanner: ^5.1.1
|
mobile_scanner: ^5.1.1
|
||||||
motion_toast: ^2.9.1
|
motion_toast: ^2.10.0
|
||||||
pasteboard: ^0.2.0
|
pasteboard: ^0.2.0
|
||||||
path: ^1.9.0
|
path: ^1.9.0
|
||||||
path_provider: ^2.1.3
|
path_provider: ^2.1.3
|
||||||
@ -65,7 +68,8 @@ dependencies:
|
|||||||
quickalert: ^1.1.0
|
quickalert: ^1.1.0
|
||||||
radix_colors: ^1.0.4
|
radix_colors: ^1.0.4
|
||||||
reorderable_grid: ^1.0.10
|
reorderable_grid: ^1.0.10
|
||||||
searchable_listview: ^2.12.0
|
scroll_to_index: ^3.0.1
|
||||||
|
searchable_listview: ^2.14.0
|
||||||
share_plus: ^9.0.0
|
share_plus: ^9.0.0
|
||||||
shared_preferences: ^2.2.3
|
shared_preferences: ^2.2.3
|
||||||
signal_strength_indicator: ^0.4.1
|
signal_strength_indicator: ^0.4.1
|
||||||
@ -83,7 +87,7 @@ dependencies:
|
|||||||
path: ../veilid/veilid-flutter
|
path: ../veilid/veilid-flutter
|
||||||
veilid_support:
|
veilid_support:
|
||||||
path: packages/veilid_support
|
path: packages/veilid_support
|
||||||
window_manager: ^0.3.8
|
window_manager: ^0.3.9
|
||||||
xterm: ^4.0.0
|
xterm: ^4.0.0
|
||||||
zxing2: ^0.2.3
|
zxing2: ^0.2.3
|
||||||
|
|
||||||
@ -92,12 +96,12 @@ dependency_overrides:
|
|||||||
path: ../dart_async_tools
|
path: ../dart_async_tools
|
||||||
bloc_advanced_tools:
|
bloc_advanced_tools:
|
||||||
path: ../bloc_advanced_tools
|
path: ../bloc_advanced_tools
|
||||||
# REMOVE ONCE form_builder_validators HAS A FIX UPSTREAM
|
flutter_chat_ui:
|
||||||
intl: 0.19.0
|
path: ../flutter_chat_ui
|
||||||
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
build_runner: ^2.4.9
|
build_runner: ^2.4.11
|
||||||
freezed: ^2.5.2
|
freezed: ^2.5.2
|
||||||
icons_launcher: ^2.1.7
|
icons_launcher: ^2.1.7
|
||||||
json_serializable: ^6.8.0
|
json_serializable: ^6.8.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user