direct waiting
This commit is contained in:
parent
fbb9db5103
commit
2b1be1989a
|
|
@ -71,6 +71,10 @@ PODS:
|
||||||
- GoogleUtilities/UserDefaults (~> 7.8)
|
- GoogleUtilities/UserDefaults (~> 7.8)
|
||||||
- nanopb (< 2.30911.0, >= 2.30908.0)
|
- nanopb (< 2.30911.0, >= 2.30908.0)
|
||||||
- Flutter (1.0.0)
|
- Flutter (1.0.0)
|
||||||
|
- flutter_background_service_ios (0.0.3):
|
||||||
|
- Flutter
|
||||||
|
- flutter_local_notifications (0.0.1):
|
||||||
|
- Flutter
|
||||||
- flutter_secure_storage (6.0.0):
|
- flutter_secure_storage (6.0.0):
|
||||||
- Flutter
|
- Flutter
|
||||||
- flutter_vibrate (0.0.1):
|
- flutter_vibrate (0.0.1):
|
||||||
|
|
@ -157,6 +161,8 @@ DEPENDENCIES:
|
||||||
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
|
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
|
||||||
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
|
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
|
||||||
- Flutter (from `Flutter`)
|
- Flutter (from `Flutter`)
|
||||||
|
- flutter_background_service_ios (from `.symlinks/plugins/flutter_background_service_ios/ios`)
|
||||||
|
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
|
||||||
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
|
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
|
||||||
- flutter_vibrate (from `.symlinks/plugins/flutter_vibrate/ios`)
|
- flutter_vibrate (from `.symlinks/plugins/flutter_vibrate/ios`)
|
||||||
- home_widget (from `.symlinks/plugins/home_widget/ios`)
|
- home_widget (from `.symlinks/plugins/home_widget/ios`)
|
||||||
|
|
@ -205,6 +211,10 @@ EXTERNAL SOURCES:
|
||||||
:path: ".symlinks/plugins/firebase_messaging/ios"
|
:path: ".symlinks/plugins/firebase_messaging/ios"
|
||||||
Flutter:
|
Flutter:
|
||||||
:path: Flutter
|
:path: Flutter
|
||||||
|
flutter_background_service_ios:
|
||||||
|
:path: ".symlinks/plugins/flutter_background_service_ios/ios"
|
||||||
|
flutter_local_notifications:
|
||||||
|
:path: ".symlinks/plugins/flutter_local_notifications/ios"
|
||||||
flutter_secure_storage:
|
flutter_secure_storage:
|
||||||
:path: ".symlinks/plugins/flutter_secure_storage/ios"
|
:path: ".symlinks/plugins/flutter_secure_storage/ios"
|
||||||
flutter_vibrate:
|
flutter_vibrate:
|
||||||
|
|
@ -252,6 +262,8 @@ SPEC CHECKSUMS:
|
||||||
FirebaseInstallations: 913cf60d0400ebd5d6b63a28b290372ab44590dd
|
FirebaseInstallations: 913cf60d0400ebd5d6b63a28b290372ab44590dd
|
||||||
FirebaseMessaging: 7b5d8033e183ab59eb5b852a53201559e976d366
|
FirebaseMessaging: 7b5d8033e183ab59eb5b852a53201559e976d366
|
||||||
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
|
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
|
||||||
|
flutter_background_service_ios: e30e0d3ee69e4cee66272d0c78eacd48c2e94aac
|
||||||
|
flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086
|
||||||
flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be
|
flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be
|
||||||
flutter_vibrate: 9f4c2ab57008965f78969472367c329dd77eb801
|
flutter_vibrate: 9f4c2ab57008965f78969472367c329dd77eb801
|
||||||
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
|
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
|
||||||
|
|
@ -275,7 +287,7 @@ SPEC CHECKSUMS:
|
||||||
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
|
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
|
||||||
video_player_avfoundation: 7c6c11d8470e1675df7397027218274b6d2360b3
|
video_player_avfoundation: 7c6c11d8470e1675df7397027218274b6d2360b3
|
||||||
wakelock_plus: 78ec7c5b202cab7761af8e2b2b3d0671be6c4ae1
|
wakelock_plus: 78ec7c5b202cab7761af8e2b2b3d0671be6c4ae1
|
||||||
webview_flutter_wkwebview: be0f0d33777f1bfd0c9fdcb594786704dbf65f36
|
webview_flutter_wkwebview: 2a23822e9039b7b1bc52e5add778e5d89ad488d1
|
||||||
|
|
||||||
PODFILE CHECKSUM: 76346ded4b0438dd89826a25813fc91ef681eb1f
|
PODFILE CHECKSUM: 76346ded4b0438dd89826a25813fc91ef681eb1f
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ class MessageData {
|
||||||
final RadarAttachment? radar;
|
final RadarAttachment? radar;
|
||||||
final File? audioFile;
|
final File? audioFile;
|
||||||
final int? audioDuration;
|
final int? audioDuration;
|
||||||
|
final double? duration;
|
||||||
|
|
||||||
MessageData({
|
MessageData({
|
||||||
required this.id,
|
required this.id,
|
||||||
|
|
@ -27,6 +28,7 @@ class MessageData {
|
||||||
this.radar,
|
this.radar,
|
||||||
this.audioFile,
|
this.audioFile,
|
||||||
this.audioDuration,
|
this.audioDuration,
|
||||||
|
this.duration,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory MessageData.fromJson(Map<String, dynamic> json) => MessageData(
|
factory MessageData.fromJson(Map<String, dynamic> json) => MessageData(
|
||||||
|
|
@ -36,6 +38,7 @@ class MessageData {
|
||||||
writedByAdmin: json['writedByAdmin'],
|
writedByAdmin: json['writedByAdmin'],
|
||||||
readed: json['readed'],
|
readed: json['readed'],
|
||||||
createdAt: json['createdAt'],
|
createdAt: json['createdAt'],
|
||||||
|
duration: json['duration'],
|
||||||
audioDuration: json['waveform'] == null
|
audioDuration: json['waveform'] == null
|
||||||
? null
|
? null
|
||||||
: jsonDecode(json['waveform'])['duration'] ?? 0,
|
: jsonDecode(json['waveform'])['duration'] ?? 0,
|
||||||
|
|
@ -53,6 +56,7 @@ class MessageData {
|
||||||
'writedByAdmin': writedByAdmin,
|
'writedByAdmin': writedByAdmin,
|
||||||
'readed': readed,
|
'readed': readed,
|
||||||
'createdAt': createdAt,
|
'createdAt': createdAt,
|
||||||
|
'duration': duration,
|
||||||
'news': news?.toJson(),
|
'news': news?.toJson(),
|
||||||
'radar': radar?.toJson(),
|
'radar': radar?.toJson(),
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
import 'dart:typed_data';
|
||||||
import 'package:didvan/services/storage/storage.dart';
|
import 'package:didvan/services/storage/storage.dart';
|
||||||
|
|
||||||
// ignore: depend_on_referenced_packages
|
// ignore: depend_on_referenced_packages
|
||||||
|
|
@ -160,6 +161,46 @@ class RequestService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> multipartBytes({
|
||||||
|
required Uint8List file,
|
||||||
|
required String method,
|
||||||
|
required String fileName,
|
||||||
|
required String fieldName,
|
||||||
|
required String mediaFormat,
|
||||||
|
required String mediaExtension,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final request = http.MultipartRequest(method, Uri.parse(url));
|
||||||
|
_headers.update('Content-Type', (_) => 'multipart/form-data');
|
||||||
|
request.headers.addAll(_headers);
|
||||||
|
if (_requestBody != null) {
|
||||||
|
_requestBody!.forEach((key, value) {
|
||||||
|
request.fields.addAll({key.toString(): value.toString()});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
request.files.add(
|
||||||
|
http.MultipartFile.fromBytes(
|
||||||
|
fieldName,
|
||||||
|
file,
|
||||||
|
filename: '$fileName.$mediaExtension',
|
||||||
|
contentType: parser.MediaType(mediaFormat, mediaExtension),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final streamedResponse = await request
|
||||||
|
.send()
|
||||||
|
.timeout(
|
||||||
|
const Duration(seconds: 30),
|
||||||
|
)
|
||||||
|
.catchError(
|
||||||
|
(e) => throw e,
|
||||||
|
);
|
||||||
|
final response = await http.Response.fromStream(streamedResponse);
|
||||||
|
_handleResponse(response);
|
||||||
|
} catch (e) {
|
||||||
|
_handleError(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> put() async {
|
Future<void> put() async {
|
||||||
try {
|
try {
|
||||||
final response = await http
|
final response = await http
|
||||||
|
|
|
||||||
|
|
@ -38,13 +38,14 @@ class _AudioWaveState extends State<AudioWave> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
print(widget.file);
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
if (widget.totalDuration == null) {
|
if (widget.totalDuration == null) {
|
||||||
await VoiceService.getDuration(src: widget.file).then((duration) {
|
await VoiceService.getDuration(src: widget.file).then((duration) {
|
||||||
setState(() {
|
setState(() {
|
||||||
totalDuration = duration;
|
totalDuration = duration;
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
print(totalDuration!.inSeconds);
|
print(totalDuration?.inSeconds);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import 'package:didvan/constants/app_icons.dart';
|
||||||
import 'package:didvan/models/message_data/message_data.dart';
|
import 'package:didvan/models/message_data/message_data.dart';
|
||||||
import 'package:didvan/services/media/voice.dart';
|
import 'package:didvan/services/media/voice.dart';
|
||||||
import 'package:didvan/utils/date_time.dart';
|
import 'package:didvan/utils/date_time.dart';
|
||||||
|
import 'package:didvan/views/ai/widgets/audio_wave.dart';
|
||||||
import 'package:didvan/views/direct/direct_state.dart';
|
import 'package:didvan/views/direct/direct_state.dart';
|
||||||
import 'package:didvan/views/direct/widgets/audio_widget.dart';
|
import 'package:didvan/views/direct/widgets/audio_widget.dart';
|
||||||
import 'package:didvan/views/widgets/didvan/divider.dart';
|
import 'package:didvan/views/widgets/didvan/divider.dart';
|
||||||
|
|
@ -86,34 +87,9 @@ class Message extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
if (message.text != null) DidvanText(message.text!),
|
if (message.text != null) DidvanText(message.text!),
|
||||||
if (message.audio != null || message.audioFile != null)
|
if (message.audio != null || message.audioFile != null)
|
||||||
FutureBuilder(
|
AudioWave(
|
||||||
future: VoiceService.getDuration(
|
file: message.audio ?? message.audioFile!.path,
|
||||||
src: message.audioFile == null
|
),
|
||||||
? message.audio!
|
|
||||||
: message.audioFile!.path),
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (!snapshot.hasData) {
|
|
||||||
return Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.center,
|
|
||||||
children: List.generate(
|
|
||||||
5,
|
|
||||||
(index) => SpinKitWave(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.primary
|
|
||||||
.withOpacity(0.4),
|
|
||||||
size: 32,
|
|
||||||
itemCount: 10,
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
return AudioWidget(
|
|
||||||
audioFile: message.audioFile,
|
|
||||||
audioUrl: message.audio,
|
|
||||||
id: message.id,
|
|
||||||
duration: snapshot.data,
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
if (message.radar != null || message.news != null)
|
if (message.radar != null || message.news != null)
|
||||||
const DidvanDivider(),
|
const DidvanDivider(),
|
||||||
if (message.radar != null || message.news != null)
|
if (message.radar != null || message.news != null)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue