Compare commits
8 Commits
433beec2dd
...
1.2.1+20
| Author | SHA1 | Date | |
|---|---|---|---|
| cc1e0599aa | |||
| 221b97901f | |||
| 498bb0e5fb | |||
| aa94dfcfe0 | |||
| 65d9253876 | |||
| 3ac510c4b1 | |||
| 253cd1ecbd | |||
| c82c48dfec |
@@ -1,5 +1,30 @@
|
||||
import 'package:solian/models/account.dart';
|
||||
|
||||
class AttachmentPlaceholder {
|
||||
int chunkCount;
|
||||
int chunkSize;
|
||||
Attachment meta;
|
||||
|
||||
AttachmentPlaceholder({
|
||||
required this.chunkCount,
|
||||
required this.chunkSize,
|
||||
required this.meta,
|
||||
});
|
||||
|
||||
factory AttachmentPlaceholder.fromJson(Map<String, dynamic> json) =>
|
||||
AttachmentPlaceholder(
|
||||
chunkCount: json['chunk_count'],
|
||||
chunkSize: json['chunk_size'],
|
||||
meta: Attachment.fromJson(json['meta']),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'chunk_count': chunkCount,
|
||||
'chunk_size': chunkSize,
|
||||
'meta': meta.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
class Attachment {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
@@ -14,7 +39,9 @@ class Attachment {
|
||||
String hash;
|
||||
int destination;
|
||||
bool isAnalyzed;
|
||||
bool isUploaded;
|
||||
Map<String, dynamic>? metadata;
|
||||
Map<String, dynamic>? fileChunks;
|
||||
bool isMature;
|
||||
Account? account;
|
||||
int? accountId;
|
||||
@@ -33,7 +60,9 @@ class Attachment {
|
||||
required this.hash,
|
||||
required this.destination,
|
||||
required this.isAnalyzed,
|
||||
required this.isUploaded,
|
||||
required this.metadata,
|
||||
required this.fileChunks,
|
||||
required this.isMature,
|
||||
required this.account,
|
||||
required this.accountId,
|
||||
@@ -55,7 +84,9 @@ class Attachment {
|
||||
hash: json['hash'],
|
||||
destination: json['destination'],
|
||||
isAnalyzed: json['is_analyzed'],
|
||||
isUploaded: json['is_uploaded'],
|
||||
metadata: json['metadata'],
|
||||
fileChunks: json['file_chunks'],
|
||||
isMature: json['is_mature'],
|
||||
account:
|
||||
json['account'] != null ? Account.fromJson(json['account']) : null,
|
||||
@@ -76,7 +107,9 @@ class Attachment {
|
||||
'hash': hash,
|
||||
'destination': destination,
|
||||
'is_analyzed': isAnalyzed,
|
||||
'is_uploaded': isUploaded,
|
||||
'metadata': metadata,
|
||||
'file_chunks': fileChunks,
|
||||
'is_mature': isMature,
|
||||
'account': account?.toJson(),
|
||||
'account_id': accountId,
|
||||
|
||||
@@ -1,24 +1,27 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:collection';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:cross_file/cross_file.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:path/path.dart' show basename;
|
||||
import 'package:solian/models/attachment.dart';
|
||||
import 'package:solian/providers/content/attachment.dart';
|
||||
|
||||
class AttachmentUploadTask {
|
||||
File file;
|
||||
String usage;
|
||||
XFile file;
|
||||
String pool;
|
||||
Map<String, dynamic>? metadata;
|
||||
Map<String, int>? chunkFiles;
|
||||
|
||||
double progress = 0;
|
||||
double? progress;
|
||||
bool isUploading = false;
|
||||
bool isCompleted = false;
|
||||
dynamic error;
|
||||
|
||||
AttachmentUploadTask({
|
||||
required this.file,
|
||||
required this.usage,
|
||||
required this.pool,
|
||||
this.metadata,
|
||||
});
|
||||
}
|
||||
@@ -73,32 +76,36 @@ class AttachmentUploaderController extends GetxController {
|
||||
|
||||
_startProgressSyncTimer();
|
||||
queueOfUpload[queueIndex].isUploading = true;
|
||||
queueOfUpload[queueIndex].progress = 0;
|
||||
|
||||
final task = queueOfUpload[queueIndex];
|
||||
final result = await _rawUploadAttachment(
|
||||
await task.file.readAsBytes(),
|
||||
task.file.path,
|
||||
task.usage,
|
||||
null,
|
||||
onProgress: (value) {
|
||||
queueOfUpload[queueIndex].progress = value;
|
||||
_progressOfUpload = value;
|
||||
},
|
||||
onError: (err) {
|
||||
queueOfUpload[queueIndex].error = err;
|
||||
queueOfUpload[queueIndex].isUploading = false;
|
||||
},
|
||||
);
|
||||
try {
|
||||
final result = await _chunkedUploadAttachment(
|
||||
task.file,
|
||||
task.pool,
|
||||
null,
|
||||
onData: (_) {},
|
||||
onProgress: (progress) {
|
||||
queueOfUpload[queueIndex].progress = progress;
|
||||
_progressOfUpload = progress;
|
||||
},
|
||||
);
|
||||
return result;
|
||||
} catch (err) {
|
||||
queueOfUpload[queueIndex].error = err;
|
||||
queueOfUpload[queueIndex].isUploading = false;
|
||||
} finally {
|
||||
_progressOfUpload = 1;
|
||||
if (queueOfUpload[queueIndex].error == null) {
|
||||
queueOfUpload.removeAt(queueIndex);
|
||||
}
|
||||
_stopProgressSyncTimer();
|
||||
_syncProgress();
|
||||
|
||||
if (queueOfUpload[queueIndex].error == null) {
|
||||
queueOfUpload.removeAt(queueIndex);
|
||||
isUploading.value = false;
|
||||
}
|
||||
_stopProgressSyncTimer();
|
||||
_syncProgress();
|
||||
|
||||
isUploading.value = false;
|
||||
|
||||
return result;
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<void> performUploadQueue({
|
||||
@@ -115,24 +122,26 @@ class AttachmentUploaderController extends GetxController {
|
||||
}
|
||||
|
||||
queueOfUpload[idx].isUploading = true;
|
||||
queueOfUpload[idx].progress = 0;
|
||||
|
||||
final task = queueOfUpload[idx];
|
||||
final result = await _rawUploadAttachment(
|
||||
await task.file.readAsBytes(),
|
||||
task.file.path,
|
||||
task.usage,
|
||||
null,
|
||||
onProgress: (value) {
|
||||
queueOfUpload[idx].progress = value;
|
||||
_progressOfUpload = (idx + value) / queueOfUpload.length;
|
||||
},
|
||||
onError: (err) {
|
||||
queueOfUpload[idx].error = err;
|
||||
queueOfUpload[idx].isUploading = false;
|
||||
},
|
||||
);
|
||||
_progressOfUpload = (idx + 1) / queueOfUpload.length;
|
||||
if (result != null) onData(result);
|
||||
try {
|
||||
final result = await _chunkedUploadAttachment(
|
||||
task.file,
|
||||
task.pool,
|
||||
null,
|
||||
onData: (_) {},
|
||||
onProgress: (progress) {
|
||||
queueOfUpload[idx].progress = progress;
|
||||
},
|
||||
);
|
||||
if (result != null) onData(result);
|
||||
} catch (err) {
|
||||
queueOfUpload[idx].error = err;
|
||||
queueOfUpload[idx].isUploading = false;
|
||||
} finally {
|
||||
_progressOfUpload = (idx + 1) / queueOfUpload.length;
|
||||
}
|
||||
|
||||
queueOfUpload[idx].isUploading = false;
|
||||
queueOfUpload[idx].isCompleted = true;
|
||||
@@ -145,69 +154,94 @@ class AttachmentUploaderController extends GetxController {
|
||||
isUploading.value = false;
|
||||
}
|
||||
|
||||
Future<void> uploadAttachmentWithCallback(
|
||||
Uint8List data,
|
||||
String path,
|
||||
String pool,
|
||||
Map<String, dynamic>? metadata,
|
||||
Function(Attachment?) callback,
|
||||
) async {
|
||||
if (isUploading.value) throw Exception('uploading blocked');
|
||||
|
||||
isUploading.value = true;
|
||||
final result = await _rawUploadAttachment(
|
||||
data,
|
||||
path,
|
||||
pool,
|
||||
metadata,
|
||||
onProgress: (progress) {
|
||||
progressOfUpload.value = progress;
|
||||
},
|
||||
);
|
||||
isUploading.value = false;
|
||||
callback(result);
|
||||
}
|
||||
|
||||
Future<Attachment?> uploadAttachment(
|
||||
Future<Attachment?> uploadAttachmentFromData(
|
||||
Uint8List data,
|
||||
String path,
|
||||
String pool,
|
||||
Map<String, dynamic>? metadata,
|
||||
) async {
|
||||
if (isUploading.value) throw Exception('uploading blocked');
|
||||
|
||||
isUploading.value = true;
|
||||
final result = await _rawUploadAttachment(
|
||||
data,
|
||||
path,
|
||||
pool,
|
||||
metadata,
|
||||
onProgress: (progress) {
|
||||
progressOfUpload.value = progress;
|
||||
},
|
||||
);
|
||||
isUploading.value = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<Attachment?> _rawUploadAttachment(
|
||||
Uint8List data, String path, String pool, Map<String, dynamic>? metadata,
|
||||
{Function(double)? onProgress, Function(dynamic err)? onError}) async {
|
||||
final AttachmentProvider provider = Get.find();
|
||||
final AttachmentProvider attach = Get.find();
|
||||
|
||||
try {
|
||||
final result = await provider.createAttachment(
|
||||
final result = await attach.createAttachmentDirectly(
|
||||
data,
|
||||
path,
|
||||
pool,
|
||||
metadata,
|
||||
onProgress: onProgress,
|
||||
);
|
||||
return result;
|
||||
} catch (err) {
|
||||
if (onError != null) {
|
||||
onError(err);
|
||||
}
|
||||
} catch (_) {
|
||||
return null;
|
||||
} finally {
|
||||
isUploading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<Attachment?> _chunkedUploadAttachment(
|
||||
XFile file,
|
||||
String pool,
|
||||
Map<String, dynamic>? metadata, {
|
||||
required Function(AttachmentPlaceholder) onData,
|
||||
required Function(double) onProgress,
|
||||
}) async {
|
||||
final AttachmentProvider attach = Get.find();
|
||||
|
||||
final holder = await attach.createAttachmentMultipartPlaceholder(
|
||||
await file.length(),
|
||||
file.path,
|
||||
pool,
|
||||
metadata,
|
||||
);
|
||||
onData(holder);
|
||||
|
||||
onProgress(0);
|
||||
|
||||
final filename = basename(file.path);
|
||||
final chunks = holder.meta.fileChunks ?? {};
|
||||
var currentTask = 0;
|
||||
|
||||
final queue = Queue<Future<void>>();
|
||||
final activeTasks = <Future<void>>[];
|
||||
|
||||
for (final entry in chunks.entries) {
|
||||
queue.add(() async {
|
||||
final beginCursor = entry.value * holder.chunkSize;
|
||||
final endCursor = (entry.value + 1) * holder.chunkSize;
|
||||
final data = Uint8List.fromList(await file
|
||||
.openRead(beginCursor, endCursor)
|
||||
.expand((chunk) => chunk)
|
||||
.toList());
|
||||
|
||||
final out = await attach.uploadAttachmentMultipartChunk(
|
||||
data,
|
||||
filename,
|
||||
holder.meta.rid,
|
||||
entry.key,
|
||||
);
|
||||
holder.meta = out;
|
||||
|
||||
currentTask++;
|
||||
onProgress(currentTask / chunks.length);
|
||||
onData(holder);
|
||||
}());
|
||||
}
|
||||
|
||||
while (queue.isNotEmpty || activeTasks.isNotEmpty) {
|
||||
while (activeTasks.length < 3 && queue.isNotEmpty) {
|
||||
final task = queue.removeFirst();
|
||||
activeTasks.add(task);
|
||||
|
||||
task.then((_) => activeTasks.remove(task));
|
||||
}
|
||||
|
||||
if (activeTasks.isNotEmpty) {
|
||||
await Future.any(activeTasks);
|
||||
}
|
||||
}
|
||||
|
||||
return holder.meta;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,10 @@ class ChatCallProvider extends GetxController {
|
||||
RxBool isReady = false.obs;
|
||||
RxBool isMounted = false.obs;
|
||||
RxBool isInitialized = false.obs;
|
||||
RxBool isBusy = false.obs;
|
||||
|
||||
RxString lastDuration = '00:00:00'.obs;
|
||||
Timer? lastDurationUpdateTimer;
|
||||
|
||||
String? token;
|
||||
String? endpoint;
|
||||
@@ -38,6 +42,34 @@ class ChatCallProvider extends GetxController {
|
||||
RxList<ParticipantTrack> participantTracks = RxList.empty(growable: true);
|
||||
Rx<ParticipantTrack?> focusTrack = Rx(null);
|
||||
|
||||
void _updateDuration() {
|
||||
if (current.value == null) {
|
||||
lastDuration.value = '00:00:00';
|
||||
return;
|
||||
}
|
||||
|
||||
Duration duration = DateTime.now().difference(current.value!.createdAt);
|
||||
|
||||
String twoDigits(int n) => n.toString().padLeft(2, '0');
|
||||
String formattedTime = '${twoDigits(duration.inHours)}:'
|
||||
'${twoDigits(duration.inMinutes.remainder(60))}:'
|
||||
'${twoDigits(duration.inSeconds.remainder(60))}';
|
||||
lastDuration.value = formattedTime;
|
||||
}
|
||||
|
||||
void enableDurationUpdater() {
|
||||
_updateDuration();
|
||||
lastDurationUpdateTimer = Timer.periodic(
|
||||
const Duration(seconds: 1),
|
||||
(_) => _updateDuration(),
|
||||
);
|
||||
}
|
||||
|
||||
void disableDurationUpdater() {
|
||||
lastDurationUpdateTimer?.cancel();
|
||||
lastDurationUpdateTimer = null;
|
||||
}
|
||||
|
||||
Future<void> checkPermissions() async {
|
||||
if (lkPlatformIs(PlatformType.macOS) || lkPlatformIs(PlatformType.linux)) {
|
||||
return;
|
||||
@@ -119,8 +151,6 @@ class ChatCallProvider extends GetxController {
|
||||
void joinRoom(String url, String token) async {
|
||||
if (isMounted.value) {
|
||||
return;
|
||||
} else {
|
||||
isMounted.value = true;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -134,6 +164,8 @@ class ChatCallProvider extends GetxController {
|
||||
);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
} finally {
|
||||
isMounted.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,6 +197,7 @@ class ChatCallProvider extends GetxController {
|
||||
Hardware.instance.setSpeakerphoneOn(true);
|
||||
}
|
||||
|
||||
isBusy.value = false;
|
||||
isInitialized.value = true;
|
||||
}
|
||||
|
||||
@@ -367,6 +400,7 @@ class ChatCallProvider extends GetxController {
|
||||
}
|
||||
|
||||
void disposeRoom() {
|
||||
isBusy.value = false;
|
||||
isMounted.value = false;
|
||||
isInitialized.value = false;
|
||||
current.value = null;
|
||||
|
||||
@@ -7,7 +7,6 @@ import 'package:solian/models/attachment.dart';
|
||||
import 'package:solian/models/pagination.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/services.dart';
|
||||
import 'package:dio/dio.dart' as dio;
|
||||
|
||||
class AttachmentProvider extends GetConnect {
|
||||
static Map<String, String> mimetypeOverrides = {
|
||||
@@ -83,16 +82,21 @@ class AttachmentProvider extends GetConnect {
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<Attachment> createAttachment(
|
||||
Uint8List data, String path, String pool, Map<String, dynamic>? metadata,
|
||||
{Function(double)? onProgress}) async {
|
||||
Future<Attachment> createAttachmentDirectly(
|
||||
Uint8List data,
|
||||
String path,
|
||||
String pool,
|
||||
Map<String, dynamic>? metadata,
|
||||
) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
|
||||
await auth.ensureCredentials();
|
||||
final client = auth.configureClient(
|
||||
'uc',
|
||||
timeout: const Duration(minutes: 3),
|
||||
);
|
||||
|
||||
final filePayload =
|
||||
dio.MultipartFile.fromBytes(data, filename: basename(path));
|
||||
final filePayload = MultipartFile(data, filename: basename(path));
|
||||
final fileAlt = basename(path).contains('.')
|
||||
? basename(path).substring(0, basename(path).lastIndexOf('.'))
|
||||
: basename(path);
|
||||
@@ -105,30 +109,82 @@ class AttachmentProvider extends GetConnect {
|
||||
if (mimetypeOverrides.keys.contains(fileExt)) {
|
||||
mimetypeOverride = mimetypeOverrides[fileExt];
|
||||
}
|
||||
final payload = dio.FormData.fromMap({
|
||||
final payload = FormData({
|
||||
'alt': fileAlt,
|
||||
'file': filePayload,
|
||||
'pool': pool,
|
||||
if (mimetypeOverride != null) 'mimetype': mimetypeOverride,
|
||||
'metadata': jsonEncode(metadata),
|
||||
});
|
||||
final resp = await dio.Dio(
|
||||
dio.BaseOptions(
|
||||
baseUrl: ServiceFinder.buildUrl('files', null),
|
||||
headers: {'Authorization': 'Bearer ${auth.credentials!.accessToken}'},
|
||||
),
|
||||
).post(
|
||||
'/attachments',
|
||||
data: payload,
|
||||
onSendProgress: (count, total) {
|
||||
if (onProgress != null) onProgress(count / total);
|
||||
},
|
||||
);
|
||||
final resp = await client.post('/attachments', payload);
|
||||
if (resp.statusCode != 200) {
|
||||
throw Exception(resp.data);
|
||||
throw Exception(resp.bodyString);
|
||||
}
|
||||
|
||||
return Attachment.fromJson(resp.data);
|
||||
return Attachment.fromJson(resp.body);
|
||||
}
|
||||
|
||||
Future<AttachmentPlaceholder> createAttachmentMultipartPlaceholder(
|
||||
int size,
|
||||
String path,
|
||||
String pool,
|
||||
Map<String, dynamic>? metadata,
|
||||
) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
|
||||
final client = auth.configureClient('uc');
|
||||
|
||||
final fileAlt = basename(path).contains('.')
|
||||
? basename(path).substring(0, basename(path).lastIndexOf('.'))
|
||||
: basename(path);
|
||||
final fileExt = basename(path)
|
||||
.substring(basename(path).lastIndexOf('.') + 1)
|
||||
.toLowerCase();
|
||||
|
||||
// Override for some files cannot be detected mimetype by server-side
|
||||
String? mimetypeOverride;
|
||||
if (mimetypeOverrides.keys.contains(fileExt)) {
|
||||
mimetypeOverride = mimetypeOverrides[fileExt];
|
||||
}
|
||||
final resp = await client.post('/attachments/multipart', {
|
||||
'alt': fileAlt,
|
||||
'name': basename(path),
|
||||
'size': size,
|
||||
'pool': pool,
|
||||
if (mimetypeOverride != null) 'mimetype': mimetypeOverride,
|
||||
'metadata': metadata,
|
||||
});
|
||||
if (resp.statusCode != 200) {
|
||||
throw Exception(resp.bodyString);
|
||||
}
|
||||
|
||||
return AttachmentPlaceholder.fromJson(resp.body);
|
||||
}
|
||||
|
||||
Future<Attachment> uploadAttachmentMultipartChunk(
|
||||
Uint8List data,
|
||||
String name,
|
||||
String rid,
|
||||
String cid,
|
||||
) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
|
||||
final client = auth.configureClient(
|
||||
'uc',
|
||||
timeout: const Duration(minutes: 3),
|
||||
);
|
||||
|
||||
final payload = FormData({
|
||||
'file': MultipartFile(data, filename: name),
|
||||
});
|
||||
final resp = await client.post('/attachments/multipart/$rid/$cid', payload);
|
||||
if (resp.statusCode != 200) {
|
||||
throw Exception(resp.bodyString);
|
||||
}
|
||||
|
||||
return Attachment.fromJson(resp.body);
|
||||
}
|
||||
|
||||
Future<Response> updateAttachment(
|
||||
|
||||
@@ -113,7 +113,7 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
|
||||
|
||||
Attachment? attachResult;
|
||||
try {
|
||||
attachResult = await provider.createAttachment(
|
||||
attachResult = await provider.createAttachmentDirectly(
|
||||
await file.readAsBytes(),
|
||||
file.path,
|
||||
'avatar',
|
||||
|
||||
@@ -12,16 +12,15 @@ import 'package:solian/widgets/chat/call/call_participant.dart';
|
||||
import 'package:livekit_client/livekit_client.dart' as livekit;
|
||||
|
||||
class CallScreen extends StatefulWidget {
|
||||
const CallScreen({super.key});
|
||||
final bool hideAppBar;
|
||||
|
||||
const CallScreen({super.key, this.hideAppBar = false});
|
||||
|
||||
@override
|
||||
State<CallScreen> createState() => _CallScreenState();
|
||||
}
|
||||
|
||||
class _CallScreenState extends State<CallScreen> with TickerProviderStateMixin {
|
||||
Timer? _timer;
|
||||
String _currentDuration = '00:00:00';
|
||||
|
||||
int _layoutMode = 0;
|
||||
|
||||
bool _showControls = true;
|
||||
@@ -37,26 +36,6 @@ class _CallScreenState extends State<CallScreen> with TickerProviderStateMixin {
|
||||
curve: Curves.fastOutSlowIn,
|
||||
);
|
||||
|
||||
String _parseDuration() {
|
||||
final ChatCallProvider provider = Get.find();
|
||||
if (provider.current.value == null) return '00:00:00';
|
||||
Duration duration =
|
||||
DateTime.now().difference(provider.current.value!.createdAt);
|
||||
|
||||
String twoDigits(int n) => n.toString().padLeft(2, '0');
|
||||
String formattedTime = '${twoDigits(duration.inHours)}:'
|
||||
'${twoDigits(duration.inMinutes.remainder(60))}:'
|
||||
'${twoDigits(duration.inSeconds.remainder(60))}';
|
||||
|
||||
return formattedTime;
|
||||
}
|
||||
|
||||
void _updateDuration() {
|
||||
setState(() {
|
||||
_currentDuration = _parseDuration();
|
||||
});
|
||||
}
|
||||
|
||||
void _switchLayout() {
|
||||
if (_layoutMode < 1) {
|
||||
setState(() => _layoutMode++);
|
||||
@@ -191,15 +170,15 @@ class _CallScreenState extends State<CallScreen> with TickerProviderStateMixin {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
Get.find<ChatCallProvider>().setupRoom();
|
||||
super.initState();
|
||||
|
||||
_updateDuration();
|
||||
_planAutoHideControls();
|
||||
_timer = Timer.periodic(
|
||||
const Duration(seconds: 1),
|
||||
(_) => _updateDuration(),
|
||||
);
|
||||
Future.delayed(Duration.zero, () {
|
||||
Get.find<ChatCallProvider>()
|
||||
..setupRoom()
|
||||
..enableDurationUpdater();
|
||||
|
||||
_planAutoHideControls();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -210,30 +189,34 @@ class _CallScreenState extends State<CallScreen> with TickerProviderStateMixin {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ChatCallProvider provider = Get.find();
|
||||
final ChatCallProvider ctrl = Get.find();
|
||||
|
||||
return Material(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: AppBarLeadingButton.adaptive(context),
|
||||
centerTitle: true,
|
||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||
title: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(children: [
|
||||
TextSpan(
|
||||
text: 'call'.tr,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
appBar: widget.hideAppBar
|
||||
? null
|
||||
: AppBar(
|
||||
leading: AppBarLeadingButton.adaptive(context),
|
||||
centerTitle: true,
|
||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||
title: Obx(
|
||||
() => RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(children: [
|
||||
TextSpan(
|
||||
text: 'call'.tr,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
const TextSpan(text: '\n'),
|
||||
TextSpan(
|
||||
text: ctrl.lastDuration.value,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
),
|
||||
const TextSpan(text: '\n'),
|
||||
TextSpan(
|
||||
text: _currentDuration,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
@@ -259,13 +242,21 @@ class _CallScreenState extends State<CallScreen> with TickerProviderStateMixin {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(call.room.serverRegion ?? 'unknown'),
|
||||
const SizedBox(width: 6),
|
||||
Text(call.room.serverVersion ?? 'unknown')
|
||||
],
|
||||
),
|
||||
Obx(() {
|
||||
return Row(
|
||||
children: [
|
||||
Text(
|
||||
call.channel.value?.name ??
|
||||
'unknown'.tr,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(call.lastDuration.value)
|
||||
],
|
||||
);
|
||||
}),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
@@ -332,7 +323,6 @@ class _CallScreenState extends State<CallScreen> with TickerProviderStateMixin {
|
||||
Expanded(
|
||||
child: Material(
|
||||
color: Theme.of(context).colorScheme.surfaceContainerLow,
|
||||
elevation: 2,
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
switch (_layoutMode) {
|
||||
@@ -345,15 +335,15 @@ class _CallScreenState extends State<CallScreen> with TickerProviderStateMixin {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (provider.room.localParticipant != null)
|
||||
if (ctrl.room.localParticipant != null)
|
||||
SizeTransition(
|
||||
sizeFactor: _controlsAnimation,
|
||||
axis: Axis.vertical,
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: ControlsWidget(
|
||||
provider.room,
|
||||
provider.room.localParticipant!,
|
||||
ctrl.room,
|
||||
ctrl.room.localParticipant!,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -370,17 +360,13 @@ class _CallScreenState extends State<CallScreen> with TickerProviderStateMixin {
|
||||
|
||||
@override
|
||||
void deactivate() {
|
||||
_timer?.cancel();
|
||||
_timer = null;
|
||||
Get.find<ChatCallProvider>().disableDurationUpdater();
|
||||
super.deactivate();
|
||||
}
|
||||
|
||||
@override
|
||||
void activate() {
|
||||
_timer ??= Timer.periodic(
|
||||
const Duration(seconds: 1),
|
||||
(_) => _updateDuration(),
|
||||
);
|
||||
Get.find<ChatCallProvider>().enableDurationUpdater();
|
||||
super.activate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,11 @@ import 'package:solian/models/channel.dart';
|
||||
import 'package:solian/models/event.dart';
|
||||
import 'package:solian/models/packet.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/providers/call.dart';
|
||||
import 'package:solian/providers/content/channel.dart';
|
||||
import 'package:solian/providers/websocket.dart';
|
||||
import 'package:solian/router.dart';
|
||||
import 'package:solian/screens/channel/call/call.dart';
|
||||
import 'package:solian/screens/channel/channel_detail.dart';
|
||||
import 'package:solian/theme.dart';
|
||||
import 'package:solian/widgets/app_bar_leading.dart';
|
||||
@@ -39,7 +41,7 @@ class ChannelChatScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ChannelChatScreenState extends State<ChannelChatScreen>
|
||||
with WidgetsBindingObserver {
|
||||
with WidgetsBindingObserver, TickerProviderStateMixin {
|
||||
DateTime? _isOutOfSyncSince;
|
||||
|
||||
bool _isBusy = false;
|
||||
@@ -238,77 +240,104 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
|
||||
);
|
||||
}
|
||||
|
||||
return Column(
|
||||
return Row(
|
||||
children: [
|
||||
if (_ongoingCall != null)
|
||||
ChannelCallIndicator(
|
||||
channel: _channel!,
|
||||
ongoingCall: _ongoingCall!,
|
||||
),
|
||||
Expanded(
|
||||
child: ChatEventList(
|
||||
scope: widget.realm,
|
||||
channel: _channel!,
|
||||
chatController: _chatController,
|
||||
onEdit: (item) {
|
||||
setState(() => _messageToEditing = item);
|
||||
},
|
||||
onReply: (item) {
|
||||
setState(() => _messageToReplying = item);
|
||||
},
|
||||
),
|
||||
),
|
||||
if (_isOutOfSyncSince != null)
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.only(left: 16, right: 8),
|
||||
tileColor: Theme.of(context).colorScheme.surfaceContainerLow,
|
||||
leading: const Icon(Icons.history_toggle_off),
|
||||
title: Text('messageOutOfSync'.tr),
|
||||
subtitle: Text('messageOutOfSyncCaption'.tr),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () {
|
||||
setState(() => _isOutOfSyncSince = null);
|
||||
},
|
||||
),
|
||||
onTap: _isBusy
|
||||
? null
|
||||
: () {
|
||||
_keepUpdateWithServer();
|
||||
child: Column(
|
||||
children: [
|
||||
if (_ongoingCall != null)
|
||||
ChannelCallIndicator(
|
||||
channel: _channel!,
|
||||
ongoingCall: _ongoingCall!,
|
||||
onJoin: () {
|
||||
if (!SolianTheme.isLargeScreen(context)) {
|
||||
final ChatCallProvider call = Get.find();
|
||||
call.gotoScreen(context);
|
||||
}
|
||||
},
|
||||
),
|
||||
Obx(() {
|
||||
if (_chatController.isLoading.isTrue) {
|
||||
return const LinearProgressIndicator().animate().slideY();
|
||||
} else {
|
||||
return const SizedBox();
|
||||
}
|
||||
}),
|
||||
ClipRect(
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 50, sigmaY: 50),
|
||||
child: SafeArea(
|
||||
child: ChatMessageInput(
|
||||
edit: _messageToEditing,
|
||||
reply: _messageToReplying,
|
||||
realm: widget.realm,
|
||||
placeholder: placeholder,
|
||||
channel: _channel!,
|
||||
onSent: (Event item) {
|
||||
setState(() {
|
||||
_chatController.addPendingEvent(item);
|
||||
});
|
||||
},
|
||||
onReset: () {
|
||||
setState(() {
|
||||
_messageToReplying = null;
|
||||
_messageToEditing = null;
|
||||
});
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: ChatEventList(
|
||||
scope: widget.realm,
|
||||
channel: _channel!,
|
||||
chatController: _chatController,
|
||||
onEdit: (item) {
|
||||
setState(() => _messageToEditing = item);
|
||||
},
|
||||
onReply: (item) {
|
||||
setState(() => _messageToReplying = item);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_isOutOfSyncSince != null)
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.only(left: 16, right: 8),
|
||||
tileColor:
|
||||
Theme.of(context).colorScheme.surfaceContainerLow,
|
||||
leading: const Icon(Icons.history_toggle_off),
|
||||
title: Text('messageOutOfSync'.tr),
|
||||
subtitle: Text('messageOutOfSyncCaption'.tr),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () {
|
||||
setState(() => _isOutOfSyncSince = null);
|
||||
},
|
||||
),
|
||||
onTap: _isBusy
|
||||
? null
|
||||
: () {
|
||||
_keepUpdateWithServer();
|
||||
},
|
||||
),
|
||||
Obx(() {
|
||||
if (_chatController.isLoading.isTrue) {
|
||||
return const LinearProgressIndicator().animate().slideY();
|
||||
} else {
|
||||
return const SizedBox();
|
||||
}
|
||||
}),
|
||||
ClipRect(
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 50, sigmaY: 50),
|
||||
child: SafeArea(
|
||||
child: ChatMessageInput(
|
||||
edit: _messageToEditing,
|
||||
reply: _messageToReplying,
|
||||
realm: widget.realm,
|
||||
placeholder: placeholder,
|
||||
channel: _channel!,
|
||||
onSent: (Event item) {
|
||||
setState(() {
|
||||
_chatController.addPendingEvent(item);
|
||||
});
|
||||
},
|
||||
onReset: () {
|
||||
setState(() {
|
||||
_messageToReplying = null;
|
||||
_messageToEditing = null;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
final ChatCallProvider call = Get.find();
|
||||
if (call.isMounted.value && SolianTheme.isLargeScreen(context)) {
|
||||
return const Expanded(
|
||||
child: Row(children: [
|
||||
VerticalDivider(width: 0.3, thickness: 0.3),
|
||||
Expanded(
|
||||
child: CallScreen(hideAppBar: true),
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
return const SizedBox();
|
||||
}),
|
||||
],
|
||||
);
|
||||
}),
|
||||
|
||||
@@ -174,7 +174,7 @@ const i18nEnglish = {
|
||||
'attachmentAttached': 'Exists Files',
|
||||
'attachmentUploadBlocked':
|
||||
'Upload blocked, there is currently a task in progress...',
|
||||
'attachmentAdd': 'Attach attachments',
|
||||
'attachmentAdd': 'Attach file',
|
||||
'attachmentAddGalleryPhoto': 'Gallery photo',
|
||||
'attachmentAddGalleryVideo': 'Gallery video',
|
||||
'attachmentAddCameraPhoto': 'Capture photo',
|
||||
@@ -269,6 +269,7 @@ const i18nEnglish = {
|
||||
'callOngoing': 'A call is ongoing...',
|
||||
'callOngoingEmpty': 'A call is on hold...',
|
||||
'callOngoingParticipants': '@count people are calling...',
|
||||
'callOngoingJoined': 'Call last @duration',
|
||||
'callJoin': 'Join',
|
||||
'callResume': 'Resume',
|
||||
'callMicrophone': 'Microphone',
|
||||
@@ -379,4 +380,5 @@ const i18nEnglish = {
|
||||
'messageOutOfSyncCaption':
|
||||
'Since the App has entered the background, there may be a time difference between the message list and the server. Click to Refresh.',
|
||||
'messageHistoryWipe': 'Wipe local message history',
|
||||
'unknown': 'Unknown',
|
||||
};
|
||||
|
||||
@@ -247,6 +247,7 @@ const i18nSimplifiedChinese = {
|
||||
'callOngoing': '一则通话正在进行中…',
|
||||
'callOngoingEmpty': '一则通话待机中…',
|
||||
'callOngoingParticipants': '@count 人正在进行通话…',
|
||||
'callOngoingJoined': '通话进行 @duration',
|
||||
'callJoin': '加入',
|
||||
'callResume': '恢复',
|
||||
'callMicrophone': '麦克风',
|
||||
@@ -345,4 +346,5 @@ const i18nSimplifiedChinese = {
|
||||
'messageOutOfSync': '消息可能与服务器脱节',
|
||||
'messageOutOfSyncCaption': '由于 App 进入后台,消息列表可能与服务器存在时差,点击刷新。',
|
||||
'messageHistoryWipe': '清除消息记录',
|
||||
'unknown': '未知',
|
||||
};
|
||||
|
||||
@@ -64,7 +64,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) return;
|
||||
|
||||
if (widget.singleMode) {
|
||||
if (!widget.singleMode) {
|
||||
final medias = await _imagePicker.pickMultiImage(
|
||||
maxWidth: widget.imageMaxWidth,
|
||||
maxHeight: widget.imageMaxHeight,
|
||||
@@ -72,8 +72,8 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
|
||||
if (medias.isEmpty) return;
|
||||
|
||||
_enqueueTaskBatch(medias.map((x) {
|
||||
final file = File(x.path);
|
||||
return AttachmentUploadTask(file: file, usage: widget.pool);
|
||||
final file = XFile(x.path);
|
||||
return AttachmentUploadTask(file: file, pool: widget.pool);
|
||||
}));
|
||||
} else {
|
||||
final media = await _imagePicker.pickMedia(
|
||||
@@ -83,7 +83,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
|
||||
if (media == null) return;
|
||||
|
||||
_enqueueTask(
|
||||
AttachmentUploadTask(file: File(media.path), usage: widget.pool),
|
||||
AttachmentUploadTask(file: XFile(media.path), pool: widget.pool),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -95,9 +95,8 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
|
||||
final media = await _imagePicker.pickVideo(source: ImageSource.gallery);
|
||||
if (media == null) return;
|
||||
|
||||
final file = File(media.path);
|
||||
_enqueueTask(
|
||||
AttachmentUploadTask(file: file, usage: widget.pool),
|
||||
AttachmentUploadTask(file: XFile(media.path), pool: widget.pool),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -113,7 +112,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
|
||||
List<File> files = result.paths.map((path) => File(path!)).toList();
|
||||
|
||||
_enqueueTaskBatch(files.map((x) {
|
||||
return AttachmentUploadTask(file: x, usage: widget.pool);
|
||||
return AttachmentUploadTask(file: XFile(x.path), pool: widget.pool);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -129,9 +128,8 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
|
||||
}
|
||||
if (media == null) return;
|
||||
|
||||
final file = File(media.path);
|
||||
_enqueueTask(
|
||||
AttachmentUploadTask(file: file, usage: widget.pool),
|
||||
AttachmentUploadTask(file: XFile(media.path), pool: widget.pool),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -197,20 +195,16 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
|
||||
|
||||
if (_uploadController.isUploading.value) return;
|
||||
|
||||
_uploadController.uploadAttachmentWithCallback(
|
||||
data,
|
||||
'Pasted Image',
|
||||
widget.pool,
|
||||
null,
|
||||
(item) {
|
||||
if (item == null) return;
|
||||
widget.onAdd(item.rid);
|
||||
if (mounted) {
|
||||
setState(() => _attachments.add(item));
|
||||
if (widget.singleMode) Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
);
|
||||
_uploadController
|
||||
.uploadAttachmentFromData(data, 'Pasted Image', widget.pool, null)
|
||||
.then((item) {
|
||||
if (item == null) return;
|
||||
widget.onAdd(item.rid);
|
||||
if (mounted) {
|
||||
setState(() => _attachments.add(item));
|
||||
if (widget.singleMode) Navigator.pop(context);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String _formatBytes(int bytes, {int decimals = 2}) {
|
||||
@@ -304,7 +298,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
|
||||
],
|
||||
);
|
||||
if (croppedFile == null) return;
|
||||
_uploadController.queueOfUpload[queueIndex].file = File(croppedFile.path);
|
||||
_uploadController.queueOfUpload[queueIndex].file = XFile(croppedFile.path);
|
||||
_uploadController.queueOfUpload.refresh();
|
||||
}
|
||||
|
||||
@@ -347,9 +341,25 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
|
||||
fontFamily: 'monospace',
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'In queue #${index + 1}',
|
||||
style: const TextStyle(fontSize: 12),
|
||||
Row(
|
||||
children: [
|
||||
FutureBuilder(
|
||||
future: element.file.length(),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) return const SizedBox();
|
||||
return Text(
|
||||
_formatBytes(snapshot.data!),
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
if (element.progress != null)
|
||||
Text(
|
||||
'${(element.progress! * 100).toStringAsFixed(2)}%',
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -581,8 +591,8 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
|
||||
onDragDone: (detail) async {
|
||||
if (_uploadController.isUploading.value) return;
|
||||
_enqueueTaskBatch(detail.files.map((x) {
|
||||
final file = File(x.path);
|
||||
return AttachmentUploadTask(file: file, usage: widget.pool);
|
||||
final file = XFile(x.path);
|
||||
return AttachmentUploadTask(file: file, pool: widget.pool);
|
||||
}));
|
||||
},
|
||||
child: Column(
|
||||
@@ -596,15 +606,13 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
'attachmentAdd'.tr,
|
||||
style:
|
||||
Theme.of(context).textTheme.headlineSmall,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Text(
|
||||
'attachmentAdd'.tr,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Obx(() {
|
||||
|
||||
@@ -9,14 +9,20 @@ import 'package:solian/models/call.dart';
|
||||
import 'package:solian/models/channel.dart';
|
||||
import 'package:solian/platform.dart';
|
||||
import 'package:solian/providers/call.dart';
|
||||
import 'package:solian/theme.dart';
|
||||
import 'package:solian/widgets/chat/call/call_prejoin.dart';
|
||||
|
||||
class ChannelCallIndicator extends StatelessWidget {
|
||||
final Channel channel;
|
||||
final Call ongoingCall;
|
||||
final Function onJoin;
|
||||
|
||||
const ChannelCallIndicator(
|
||||
{super.key, required this.channel, required this.ongoingCall});
|
||||
const ChannelCallIndicator({
|
||||
super.key,
|
||||
required this.channel,
|
||||
required this.ongoingCall,
|
||||
required this.onJoin,
|
||||
});
|
||||
|
||||
void _showCallPrejoin(BuildContext context) {
|
||||
showModalBottomSheet(
|
||||
@@ -25,6 +31,7 @@ class ChannelCallIndicator extends StatelessWidget {
|
||||
builder: (context) => ChatCallPrejoinPopup(
|
||||
ongoingCall: ongoingCall,
|
||||
channel: channel,
|
||||
onJoin: onJoin,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -40,48 +47,72 @@ class ChannelCallIndicator extends StatelessWidget {
|
||||
dividerColor: Colors.transparent,
|
||||
content: Row(
|
||||
children: [
|
||||
if (ongoingCall.participants.isEmpty) Text('callOngoingEmpty'.tr),
|
||||
if (ongoingCall.participants.isNotEmpty)
|
||||
Text('callOngoingParticipants'.trParams({
|
||||
'count': ongoingCall.participants.length.toString(),
|
||||
})),
|
||||
Obx(() {
|
||||
if (call.isInitialized.value) {
|
||||
return Text('callOngoingJoined'.trParams({
|
||||
'duration': call.lastDuration.value,
|
||||
}));
|
||||
} else if (ongoingCall.participants.isEmpty) {
|
||||
return Text('callOngoingEmpty'.tr);
|
||||
} else {
|
||||
return Text('callOngoingParticipants'.trParams({
|
||||
'count': ongoingCall.participants.length.toString(),
|
||||
}));
|
||||
}
|
||||
}),
|
||||
const SizedBox(width: 6),
|
||||
if (ongoingCall.participants.isNotEmpty)
|
||||
Container(
|
||||
height: 28,
|
||||
constraints: const BoxConstraints(maxWidth: 120),
|
||||
child: AvatarStack(
|
||||
Obx(() {
|
||||
if (call.isInitialized.value) {
|
||||
return const SizedBox();
|
||||
}
|
||||
if (ongoingCall.participants.isNotEmpty) {
|
||||
return Container(
|
||||
height: 28,
|
||||
borderWidth: 0,
|
||||
avatars: ongoingCall.participants.map((x) {
|
||||
final userinfo = Account.fromJson(jsonDecode(x['metadata']));
|
||||
return PlatformInfo.canCacheImage
|
||||
? CachedNetworkImageProvider(userinfo.avatar)
|
||||
as ImageProvider
|
||||
: NetworkImage(userinfo.avatar) as ImageProvider;
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
constraints: const BoxConstraints(maxWidth: 120),
|
||||
child: AvatarStack(
|
||||
height: 28,
|
||||
borderWidth: 0,
|
||||
avatars: ongoingCall.participants.map((x) {
|
||||
final userinfo =
|
||||
Account.fromJson(jsonDecode(x['metadata']));
|
||||
return PlatformInfo.canCacheImage
|
||||
? CachedNetworkImageProvider(userinfo.avatar)
|
||||
as ImageProvider
|
||||
: NetworkImage(userinfo.avatar) as ImageProvider;
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
return const SizedBox();
|
||||
})
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
Obx(() {
|
||||
if (call.current.value == null) {
|
||||
if (call.isBusy.value) {
|
||||
return const SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 3),
|
||||
).paddingAll(16);
|
||||
} else if (call.current.value == null) {
|
||||
return TextButton(
|
||||
onPressed: () => _showCallPrejoin(context),
|
||||
child: Text('callJoin'.tr),
|
||||
);
|
||||
} else if (call.channel.value?.id == channel.id) {
|
||||
} else if (call.channel.value?.id == channel.id &&
|
||||
!SolianTheme.isLargeScreen(context)) {
|
||||
return TextButton(
|
||||
onPressed: () => call.gotoScreen(context),
|
||||
onPressed: () => onJoin(),
|
||||
child: Text('callResume'.tr),
|
||||
);
|
||||
} else {
|
||||
} else if (!SolianTheme.isLargeScreen(context)) {
|
||||
return TextButton(
|
||||
onPressed: null,
|
||||
child: Text('callJoin'.tr),
|
||||
);
|
||||
}
|
||||
return const SizedBox();
|
||||
})
|
||||
],
|
||||
);
|
||||
|
||||
@@ -88,10 +88,12 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
void _disconnect() async {
|
||||
if (await showDisconnectDialog() != true) return;
|
||||
|
||||
final ChatCallProvider provider = Get.find();
|
||||
if (provider.current.value != null) {
|
||||
provider.disposeRoom();
|
||||
Navigator.pop(context);
|
||||
final ChatCallProvider call = Get.find();
|
||||
if (call.current.value != null) {
|
||||
call.disposeRoom();
|
||||
if (Navigator.canPop(context)) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,8 +211,7 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
runSpacing: 5,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Transform.flip(
|
||||
flipX: true, child: const Icon(Icons.exit_to_app)),
|
||||
icon: const Icon(Icons.exit_to_app),
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
onPressed: _disconnect,
|
||||
),
|
||||
|
||||
@@ -11,11 +11,13 @@ import 'package:solian/providers/call.dart';
|
||||
class ChatCallPrejoinPopup extends StatefulWidget {
|
||||
final Call ongoingCall;
|
||||
final Channel channel;
|
||||
final Function onJoin;
|
||||
|
||||
const ChatCallPrejoinPopup({
|
||||
super.key,
|
||||
required this.ongoingCall,
|
||||
required this.channel,
|
||||
required this.onJoin,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -25,22 +27,23 @@ class ChatCallPrejoinPopup extends StatefulWidget {
|
||||
class _ChatCallPrejoinPopupState extends State<ChatCallPrejoinPopup> {
|
||||
bool _isBusy = false;
|
||||
|
||||
void performJoin() async {
|
||||
void _performJoin() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
final ChatCallProvider provider = Get.find();
|
||||
final ChatCallProvider call = Get.find();
|
||||
if (auth.isAuthorized.isFalse) return;
|
||||
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
provider.setCall(widget.ongoingCall, widget.channel);
|
||||
call.setCall(widget.ongoingCall, widget.channel);
|
||||
call.isBusy.value = true;
|
||||
|
||||
try {
|
||||
final resp = await provider.getRoomToken();
|
||||
final resp = await call.getRoomToken();
|
||||
final token = resp.$1;
|
||||
final endpoint = resp.$2;
|
||||
|
||||
provider.initRoom();
|
||||
provider.setupRoomListeners(
|
||||
call.initRoom();
|
||||
call.setupRoomListeners(
|
||||
onDisconnected: (reason) {
|
||||
context.showSnackbar(
|
||||
'callDisconnected'.trParams({'reason': reason.toString()}),
|
||||
@@ -48,23 +51,22 @@ class _ChatCallPrejoinPopupState extends State<ChatCallPrejoinPopup> {
|
||||
},
|
||||
);
|
||||
|
||||
provider.joinRoom(endpoint, token);
|
||||
call.joinRoom(endpoint, token);
|
||||
|
||||
provider.gotoScreen(context).then((_) {
|
||||
Navigator.pop(context);
|
||||
});
|
||||
Navigator.pop(context);
|
||||
} catch (e) {
|
||||
context.showErrorDialog(e);
|
||||
}
|
||||
|
||||
widget.onJoin();
|
||||
setState(() => _isBusy = false);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
final ChatCallProvider provider = Get.find();
|
||||
provider.checkPermissions().then((_) {
|
||||
provider.initHardware();
|
||||
final ChatCallProvider call = Get.find();
|
||||
call.checkPermissions().then((_) {
|
||||
call.initHardware();
|
||||
});
|
||||
|
||||
super.initState();
|
||||
@@ -169,7 +171,7 @@ class _ChatCallPrejoinPopupState extends State<ChatCallPrejoinPopup> {
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.primaryContainer,
|
||||
),
|
||||
onPressed: _isBusy ? null : performJoin,
|
||||
onPressed: _isBusy ? null : _performJoin,
|
||||
child: Text('callJoin'.tr),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -7,10 +7,10 @@ class ChatCallCurrentIndicator extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ChatCallProvider provider = Get.find();
|
||||
final ChatCallProvider call = Get.find();
|
||||
|
||||
return Obx(() {
|
||||
if (provider.current.value == null || provider.channel.value == null) {
|
||||
if (call.current.value == null || call.channel.value == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
|
||||
@@ -18,11 +18,8 @@ class ChatCallCurrentIndicator extends StatelessWidget {
|
||||
tileColor: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
leading: const Icon(Icons.call),
|
||||
title: Text(provider.channel.value!.name),
|
||||
title: Text(call.channel.value!.name),
|
||||
subtitle: Text('callAlreadyOngoing'.tr),
|
||||
onTap: () {
|
||||
provider.gotoScreen(context);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class ChatEvent extends StatelessWidget {
|
||||
return Container(
|
||||
key: Key('m${item.uuid}attachments-box'),
|
||||
width: MediaQuery.of(context).size.width,
|
||||
padding: EdgeInsets.only(top: isMerged ? 0 : 4),
|
||||
padding: EdgeInsets.only(top: isMerged ? 0 : 4, bottom: 4),
|
||||
constraints: const BoxConstraints(
|
||||
maxHeight: 720,
|
||||
),
|
||||
@@ -296,8 +296,8 @@ class ChatEvent extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 12),
|
||||
_buildLinkExpansion().paddingOnly(left: 52),
|
||||
_buildAttachment(context).paddingOnly(left: 56),
|
||||
_buildLinkExpansion().paddingOnly(left: 52, right: 8),
|
||||
_buildAttachment(context).paddingOnly(left: 56, right: 8),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/platform.dart';
|
||||
import 'package:solian/providers/link_expander.dart';
|
||||
@@ -12,6 +13,9 @@ class LinkExpansion extends StatelessWidget {
|
||||
const LinkExpansion({super.key, required this.content});
|
||||
|
||||
Widget _buildImage(String url, {double? width, double? height}) {
|
||||
if (url.endsWith('svg')) {
|
||||
return SvgPicture.network(url, width: width, height: height);
|
||||
}
|
||||
return PlatformInfo.canCacheImage
|
||||
? CachedNetworkImage(imageUrl: url, width: width, height: height)
|
||||
: Image.network(url, width: width, height: height);
|
||||
@@ -20,10 +24,7 @@ class LinkExpansion extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final linkRegex = RegExp(
|
||||
r'(?:(?:https?|ftp):\/\/|www\.)'
|
||||
r'(?:[-_a-z0-9]+\.)*(?:[-a-z0-9]+\.[-a-z0-9]+)'
|
||||
r'[^\s<]*'
|
||||
r'[^\s<?!.,:*_~]',
|
||||
r'(?<!\()(?:(?:https?):\/\/|www\.)(?:[-_a-z0-9]+\.)*(?:[-a-z0-9]+\.[-a-z0-9]+)[^\s<]*[^\s<?!.,:*_~]',
|
||||
);
|
||||
final matches = linkRegex.allMatches(content);
|
||||
if (matches.isEmpty) {
|
||||
@@ -46,7 +47,7 @@ class LinkExpansion extends StatelessWidget {
|
||||
}
|
||||
|
||||
final isRichDescription = [
|
||||
"solsynth.dev",
|
||||
'solsynth.dev',
|
||||
].contains(Uri.parse(snapshot.data!.url).host);
|
||||
|
||||
return GestureDetector(
|
||||
|
||||
@@ -163,6 +163,12 @@ PODS:
|
||||
- WebRTC-SDK (= 125.6422.04)
|
||||
- macos_window_utils (1.0.0):
|
||||
- FlutterMacOS
|
||||
- media_kit_libs_macos_video (1.0.4):
|
||||
- FlutterMacOS
|
||||
- media_kit_native_event_loop (1.0.0):
|
||||
- FlutterMacOS
|
||||
- media_kit_video (0.0.1):
|
||||
- FlutterMacOS
|
||||
- nanopb (2.30910.0):
|
||||
- nanopb/decode (= 2.30910.0)
|
||||
- nanopb/encode (= 2.30910.0)
|
||||
@@ -180,6 +186,8 @@ PODS:
|
||||
- PromisesObjC (= 2.4.0)
|
||||
- protocol_handler_macos (0.0.1):
|
||||
- FlutterMacOS
|
||||
- screen_brightness_macos (0.1.0):
|
||||
- FlutterMacOS
|
||||
- share_plus (0.0.1):
|
||||
- FlutterMacOS
|
||||
- shared_preferences_foundation (0.0.1):
|
||||
@@ -190,9 +198,6 @@ PODS:
|
||||
- FlutterMacOS
|
||||
- url_launcher_macos (0.0.1):
|
||||
- FlutterMacOS
|
||||
- video_player_avfoundation (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- wakelock_plus (0.0.1):
|
||||
- FlutterMacOS
|
||||
- WebRTC-SDK (125.6422.04)
|
||||
@@ -212,15 +217,18 @@ DEPENDENCIES:
|
||||
- gal (from `Flutter/ephemeral/.symlinks/plugins/gal/darwin`)
|
||||
- livekit_client (from `Flutter/ephemeral/.symlinks/plugins/livekit_client/macos`)
|
||||
- macos_window_utils (from `Flutter/ephemeral/.symlinks/plugins/macos_window_utils/macos`)
|
||||
- media_kit_libs_macos_video (from `Flutter/ephemeral/.symlinks/plugins/media_kit_libs_macos_video/macos`)
|
||||
- media_kit_native_event_loop (from `Flutter/ephemeral/.symlinks/plugins/media_kit_native_event_loop/macos`)
|
||||
- media_kit_video (from `Flutter/ephemeral/.symlinks/plugins/media_kit_video/macos`)
|
||||
- package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`)
|
||||
- pasteboard (from `Flutter/ephemeral/.symlinks/plugins/pasteboard/macos`)
|
||||
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
|
||||
- protocol_handler_macos (from `Flutter/ephemeral/.symlinks/plugins/protocol_handler_macos/macos`)
|
||||
- screen_brightness_macos (from `Flutter/ephemeral/.symlinks/plugins/screen_brightness_macos/macos`)
|
||||
- share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`)
|
||||
- shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`)
|
||||
- sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/darwin`)
|
||||
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
|
||||
- video_player_avfoundation (from `Flutter/ephemeral/.symlinks/plugins/video_player_avfoundation/darwin`)
|
||||
- wakelock_plus (from `Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos`)
|
||||
|
||||
SPEC REPOS:
|
||||
@@ -272,6 +280,12 @@ EXTERNAL SOURCES:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/livekit_client/macos
|
||||
macos_window_utils:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/macos_window_utils/macos
|
||||
media_kit_libs_macos_video:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/media_kit_libs_macos_video/macos
|
||||
media_kit_native_event_loop:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/media_kit_native_event_loop/macos
|
||||
media_kit_video:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/media_kit_video/macos
|
||||
package_info_plus:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos
|
||||
pasteboard:
|
||||
@@ -280,6 +294,8 @@ EXTERNAL SOURCES:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin
|
||||
protocol_handler_macos:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/protocol_handler_macos/macos
|
||||
screen_brightness_macos:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/screen_brightness_macos/macos
|
||||
share_plus:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/share_plus/macos
|
||||
shared_preferences_foundation:
|
||||
@@ -288,8 +304,6 @@ EXTERNAL SOURCES:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/sqflite/darwin
|
||||
url_launcher_macos:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
|
||||
video_player_avfoundation:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/video_player_avfoundation/darwin
|
||||
wakelock_plus:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos
|
||||
|
||||
@@ -321,6 +335,9 @@ SPEC CHECKSUMS:
|
||||
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
|
||||
livekit_client: 95f3b71e6545845aa658a6df0a3a62dcc3471d7c
|
||||
macos_window_utils: 933f91f64805e2eb91a5bd057cf97cd097276663
|
||||
media_kit_libs_macos_video: b3e2bbec2eef97c285f2b1baa7963c67c753fb82
|
||||
media_kit_native_event_loop: 81fd5b45192b72f8b5b69eaf5b540f45777eb8d5
|
||||
media_kit_video: c75b07f14d59706c775778e4dd47dd027de8d1e5
|
||||
nanopb: 438bc412db1928dac798aa6fd75726007be04262
|
||||
package_info_plus: fa739dd842b393193c5ca93c26798dff6e3d0e0c
|
||||
pasteboard: 9b69dba6fedbb04866be632205d532fe2f6b1d99
|
||||
@@ -328,11 +345,11 @@ SPEC CHECKSUMS:
|
||||
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
|
||||
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851
|
||||
protocol_handler_macos: d10a6c01d6373389ffd2278013ab4c47ed6d6daa
|
||||
screen_brightness_macos: 2d6d3af2165592d9a55ffcd95b7550970e41ebda
|
||||
share_plus: 36537c04ce0c3e3f5bd297ce4318b6d5ee5fd6cf
|
||||
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
|
||||
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
|
||||
url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399
|
||||
video_player_avfoundation: 7c6c11d8470e1675df7397027218274b6d2360b3
|
||||
wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269
|
||||
WebRTC-SDK: c3d69a87e7185fad3568f6f3cff7c9ac5890acf3
|
||||
|
||||
|
||||
42
pubspec.lock
42
pubspec.lock
@@ -263,7 +263,7 @@ packages:
|
||||
source: hosted
|
||||
version: "3.1.1"
|
||||
cross_file:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: cross_file
|
||||
sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670"
|
||||
@@ -787,6 +787,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.0"
|
||||
flutter_svg:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_svg
|
||||
sha256: "7b4ca6cf3304575fe9c8ec64813c8d02ee41d2afe60bcfe0678bcb5375d596a2"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.10+1"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
@@ -1293,6 +1301,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.9.0"
|
||||
path_parsing:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_parsing
|
||||
sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
path_provider:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1978,6 +1994,30 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.4.2"
|
||||
vector_graphics:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_graphics
|
||||
sha256: "32c3c684e02f9bc0afb0ae0aa653337a2fe022e8ab064bcd7ffda27a74e288e3"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.11+1"
|
||||
vector_graphics_codec:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_graphics_codec
|
||||
sha256: c86987475f162fadff579e7320c7ddda04cd2fdeffbe1129227a85d9ac9e03da
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.11+1"
|
||||
vector_graphics_compiler:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_graphics_compiler
|
||||
sha256: "12faff3f73b1741a36ca7e31b292ddeb629af819ca9efe9953b70bd63fc8cd81"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.11+1"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -2,7 +2,7 @@ name: solian
|
||||
description: "The Solar Network App"
|
||||
publish_to: "none"
|
||||
|
||||
version: 1.2.1+19
|
||||
version: 1.2.1+20
|
||||
|
||||
environment:
|
||||
sdk: ">=3.3.4 <4.0.0"
|
||||
@@ -71,6 +71,8 @@ dependencies:
|
||||
media_kit: ^1.1.10+1
|
||||
media_kit_video: ^1.2.4
|
||||
media_kit_libs_video: ^1.0.4
|
||||
flutter_svg: ^2.0.10+1
|
||||
cross_file: ^0.3.4+2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user