Skip to content

Commit

Permalink
Merge pull request #81 from ZhuJHua/dev
Browse files Browse the repository at this point in the history
fix(fix display error when local send):
  • Loading branch information
ZhuJHua authored Dec 18, 2024
2 parents 06f9dcf + dbcd3f7 commit 703d780
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 68 deletions.
61 changes: 46 additions & 15 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ PODS:
- DKImagePickerController/PhotoGallery
- Flutter
- Flutter (1.0.0)
- flutter_inappwebview_ios (0.0.1):
- flutter_image_compress_common (1.0.0):
- Flutter
- flutter_inappwebview_ios/Core (= 0.0.1)
- OrderedSet (~> 6.0.3)
- flutter_inappwebview_ios/Core (0.0.1):
- Flutter
- OrderedSet (~> 6.0.3)
- Mantle
- SDWebImage
- SDWebImageWebPCoder
- flutter_keyboard_visibility_temp_fork (0.0.1):
- Flutter
- flutter_native_splash (2.4.3):
- Flutter
- fluttertoast (0.0.2):
- Flutter
- Toast
Expand All @@ -67,9 +67,24 @@ PODS:
- Flutter
- isar_flutter_libs (1.0.0):
- Flutter
- libwebp (1.3.2):
- libwebp/demux (= 1.3.2)
- libwebp/mux (= 1.3.2)
- libwebp/sharpyuv (= 1.3.2)
- libwebp/webp (= 1.3.2)
- libwebp/demux (1.3.2):
- libwebp/webp
- libwebp/mux (1.3.2):
- libwebp/demux
- libwebp/sharpyuv (1.3.2)
- libwebp/webp (1.3.2):
- libwebp/sharpyuv
- local_auth_darwin (0.0.1):
- Flutter
- FlutterMacOS
- Mantle (2.2.0):
- Mantle/extobjc (= 2.2.0)
- Mantle/extobjc (2.2.0)
- media_kit_libs_ios_video (1.0.4):
- Flutter
- media_kit_native_event_loop (1.0.0):
Expand All @@ -82,7 +97,6 @@ PODS:
- objectbox_flutter_libs (0.0.1):
- Flutter
- ObjectBox (= 4.0.1)
- OrderedSet (6.0.3)
- package_info_plus (0.4.5):
- Flutter
- path_provider_foundation (0.0.1):
Expand All @@ -94,13 +108,18 @@ PODS:
- Flutter
- record_darwin (1.0.0):
- Flutter
- rive_common (0.0.1):
- Flutter
- rust_lib_mood_diary (0.0.1):
- Flutter
- screen_brightness_ios (0.1.0):
- Flutter
- SDWebImage (5.19.7):
- SDWebImage/Core (= 5.19.7)
- SDWebImage/Core (5.19.7)
- SDWebImageWebPCoder (0.14.6):
- libwebp (~> 1.0)
- SDWebImage/Core (~> 5.17)
- share_plus (0.0.1):
- Flutter
- shared_preferences_foundation (0.0.1):
Expand Down Expand Up @@ -151,8 +170,9 @@ DEPENDENCIES:
- fc_native_video_thumbnail (from `.symlinks/plugins/fc_native_video_thumbnail/darwin`)
- file_picker (from `.symlinks/plugins/file_picker/ios`)
- Flutter (from `Flutter`)
- flutter_inappwebview_ios (from `.symlinks/plugins/flutter_inappwebview_ios/ios`)
- flutter_image_compress_common (from `.symlinks/plugins/flutter_image_compress_common/ios`)
- flutter_keyboard_visibility_temp_fork (from `.symlinks/plugins/flutter_keyboard_visibility_temp_fork/ios`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- gal (from `.symlinks/plugins/gal/darwin`)
- geolocator_apple (from `.symlinks/plugins/geolocator_apple/ios`)
Expand All @@ -169,6 +189,7 @@ DEPENDENCIES:
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- quill_native_bridge_ios (from `.symlinks/plugins/quill_native_bridge_ios/ios`)
- record_darwin (from `.symlinks/plugins/record_darwin/ios`)
- rive_common (from `.symlinks/plugins/rive_common/ios`)
- rust_lib_mood_diary (from `.symlinks/plugins/rust_lib_mood_diary/ios`)
- screen_brightness_ios (from `.symlinks/plugins/screen_brightness_ios/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
Expand All @@ -184,9 +205,11 @@ SPEC REPOS:
trunk:
- DKImagePickerController
- DKPhotoGallery
- libwebp
- Mantle
- ObjectBox
- OrderedSet
- SDWebImage
- SDWebImageWebPCoder
- SwiftyGif
- TensorFlowLiteC
- TensorFlowLiteSwift
Expand All @@ -207,10 +230,12 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/file_picker/ios"
Flutter:
:path: Flutter
flutter_inappwebview_ios:
:path: ".symlinks/plugins/flutter_inappwebview_ios/ios"
flutter_image_compress_common:
:path: ".symlinks/plugins/flutter_image_compress_common/ios"
flutter_keyboard_visibility_temp_fork:
:path: ".symlinks/plugins/flutter_keyboard_visibility_temp_fork/ios"
flutter_native_splash:
:path: ".symlinks/plugins/flutter_native_splash/ios"
fluttertoast:
:path: ".symlinks/plugins/fluttertoast/ios"
gal:
Expand Down Expand Up @@ -243,6 +268,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/quill_native_bridge_ios/ios"
record_darwin:
:path: ".symlinks/plugins/record_darwin/ios"
rive_common:
:path: ".symlinks/plugins/rive_common/ios"
rust_lib_mood_diary:
:path: ".symlinks/plugins/rust_lib_mood_diary/ios"
screen_brightness_ios:
Expand All @@ -267,36 +294,40 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
app_links: e7a6750a915a9e161c58d91bc610e8cd1d4d0ad0
audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40
connectivity_plus: 4c41c08fc6d7c91f63bc7aec70ffe3730b04f563
connectivity_plus: 18382e7311ba19efcaee94442b23b32507b20695
device_info_plus: bf2e3232933866d73fe290f2942f2156cdd10342
DKImagePickerController: 946cec48c7873164274ecc4624d19e3da4c1ef3c
DKPhotoGallery: b3834fecb755ee09a593d7c9e389d8b5d6deed60
fc_native_video_thumbnail: 927d4dcfd4c7e9f2cc1a20bb52dfee83de3792c2
file_picker: 09aa5ec1ab24135ccd7a1621c46c84134bfd6655
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_inappwebview_ios: 6f63631e2c62a7c350263b13fa5427aedefe81d4
flutter_image_compress_common: ec1d45c362c9d30a3f6a0426c297f47c52007e3e
flutter_keyboard_visibility_temp_fork: 8a8809c4129e31d25fca77446e0f3fd548122ced
flutter_native_splash: e8a1e01082d97a8099d973f919f57904c925008a
fluttertoast: e9a18c7be5413da53898f660530c56f35edfba9c
gal: 61e868295d28fe67ffa297fae6dacebf56fd53e1
gal: 6a522c75909f1244732d4596d11d6a2f86ff37a5
geolocator_apple: 9bcea1918ff7f0062d98345d238ae12718acfbc1
image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1
isar_flutter_libs: b69f437aeab9c521821c3f376198c4371fa21073
libwebp: 1786c9f4ff8a279e4dac1e8f385004d5fc253009
local_auth_darwin: 66e40372f1c29f383a314c738c7446e2f7fdadc3
Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d
media_kit_libs_ios_video: a5fe24bc7875ccd6378a0978c13185e1344651c1
media_kit_native_event_loop: e6b2ab20cf0746eb1c33be961fcf79667304fa2a
media_kit_video: 5da63f157170e5bf303bf85453b7ef6971218a2e
network_info_plus: 6613d9d7cdeb0e6f366ed4dbe4b3c51c52d567a9
ObjectBox: 0bc4bb75eea85f6af06b369148b334c2056bbc29
objectbox_flutter_libs: 2ce0da386c780878687c736b528ceaf371573efb
OrderedSet: e539b66b644ff081c73a262d24ad552a69be3a94
package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
quill_native_bridge_ios: 2b01d585fcc73d0f5eed78c0bd244ee564b06f5a
record_darwin: 3b1a8e7d5c0cbf45ad6165b4d83a6ca643d929c3
rive_common: 4743dbfd2911c99066547a3c6454681e0fa907df
rust_lib_mood_diary: 38a92354760d3409ebc859f812193e7c69e184ef
screen_brightness_ios: 715ca807df953bf676d339f11464e438143ee625
SDWebImage: 8a6b7b160b4d710e2a22b6900e25301075c34cb3
SDWebImageWebPCoder: e38c0a70396191361d60c092933e22c20d5b1380
share_plus: 8b6f8b3447e494cca5317c8c3073de39b3600d1f
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
sqflite_darwin: 5a7236e3b501866c1c9befc6771dfd73ffb8702d
Expand Down
4 changes: 2 additions & 2 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,9 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = 3XA29H789G;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.lifestyle";
Expand Down
20 changes: 4 additions & 16 deletions lib/components/loading/loading.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@ class Processing extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
return RiveAnimatedIcon(
return LoopingRiveIcon(
riveIcon: RiveIcon.reload,
width: 80,
height: 80,
color: colorScheme.onSurface,
loopAnimation: true,
splashFactory: NoSplash.splashFactory,
mouseCursor: SystemMouseCursors.move,
strokeWidth: 4.0,
);
}
Expand All @@ -26,14 +23,11 @@ class SearchLoading extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
return RiveAnimatedIcon(
return LoopingRiveIcon(
riveIcon: RiveIcon.search,
width: 80,
height: 80,
color: colorScheme.onSurface,
loopAnimation: true,
splashFactory: NoSplash.splashFactory,
mouseCursor: SystemMouseCursors.move,
strokeWidth: 4.0,
);
}
Expand All @@ -45,14 +39,11 @@ class EditingLoading extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
return RiveAnimatedIcon(
return LoopingRiveIcon(
riveIcon: RiveIcon.edit,
width: 80,
height: 80,
color: colorScheme.onSurface,
loopAnimation: true,
splashFactory: NoSplash.splashFactory,
mouseCursor: SystemMouseCursors.move,
strokeWidth: 4.0,
);
}
Expand All @@ -64,14 +55,11 @@ class NetworkLoading extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
return RiveAnimatedIcon(
return LoopingRiveIcon(
riveIcon: RiveIcon.wifi,
width: 80,
height: 80,
color: colorScheme.onSurface,
loopAnimation: true,
splashFactory: NoSplash.splashFactory,
mouseCursor: SystemMouseCursors.move,
strokeWidth: 4.0,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import '../../../utils/file_util.dart';
import '../../../utils/http_util.dart';
import '../../../utils/log_util.dart';
import '../../../utils/notice_util.dart';
import '../../../utils/send_util.dart';
import 'local_send_client_state.dart';

class LocalSendClientLogic extends GetxController {
Expand Down Expand Up @@ -161,15 +162,13 @@ class LocalSendClientLogic extends GetxController {
await dio.MultipartFile.fromFile(filePath, filename: audioName),
));
}
final startTime = DateTime.now();
// 发送请求并监听进度
final uploadSpeedCalculator = UploadSpeedCalculator();
var response = await HttpUtil().upload(
'http://${state.serverIp}:${state.serverPort}',
data: formData,
onSendProgress: (int sent, int total) {
final currentTime = DateTime.now();
final timeElapsed = currentTime.difference(startTime).inMilliseconds / 1000;
state.speed.value = sent / timeElapsed;
uploadSpeedCalculator.updateSpeed(sent);
state.speed.value = uploadSpeedCalculator.getSpeed();
state.progress.value = sent / total;
},
);
Expand Down Expand Up @@ -209,15 +208,15 @@ class LocalSendClientLogic extends GetxController {
// 添加 JSON 数据
formData.files.add(MapEntry('file', await dio.MultipartFile.fromFile(filePath)));

final startTime = DateTime.now();
final uploadSpeedCalculator = UploadSpeedCalculator();
// 发送请求并监听进度
var response = await HttpUtil().upload(
'http://${state.serverIp}:${state.serverPort}',
data: formData,
onSendProgress: (int sent, int total) {
final currentTime = DateTime.now();
final timeElapsed = currentTime.difference(startTime).inMilliseconds / 1000;
state.speed.value = sent / timeElapsed;
uploadSpeedCalculator.updateSpeed(sent);
final speed = uploadSpeedCalculator.getSpeed();
state.speed.value = speed;
state.progress.value = sent / total;
},
);
Expand Down
6 changes: 4 additions & 2 deletions lib/utils/log_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ class FileOutput extends LogOutput {
this.encoding = utf8,
});

/// 初始化文件输出流
Future<void> _initializeSink() async {
if (_sink == null) {
file = File(FileUtil.getErrorLogPath());
if (!(await file!.exists())) {
await file!.create(recursive: true);
}
_sink = file!.openWrite(
mode: overrideExisting ? FileMode.write : FileMode.append,
encoding: encoding,
Expand All @@ -30,7 +32,7 @@ class FileOutput extends LogOutput {
@override
void output(OutputEvent event) async {
await _initializeSink();
if (_sink != null && event.level.index >= Level.info.index) {
if (event.level.value >= Level.warning.value) {
_sink?.writeAll(event.lines, '\n');
}
}
Expand Down
27 changes: 27 additions & 0 deletions lib/utils/send_util.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class UploadSpeedCalculator {
final int updateIntervalInMilliseconds;
DateTime _lastUpdateTime = DateTime.now();
double _speed = 0.0;
int _previousSentBytes = 0;

UploadSpeedCalculator({this.updateIntervalInMilliseconds = 500});

void updateSpeed(int sent) {
final currentTime = DateTime.now();
final timeElapsed = currentTime.difference(_lastUpdateTime).inMilliseconds / 1000;
if (timeElapsed >= (updateIntervalInMilliseconds / 1000)) {
final sentSinceLastUpdate = sent - _previousSentBytes;
_speed = sentSinceLastUpdate / timeElapsed;
const maxSpeed = 1.0 * 1024 * 1024 * 1024;
if (_speed > maxSpeed) {
_speed = maxSpeed;
}
_previousSentBytes = sent;
_lastUpdateTime = currentTime;
}
}

double getSpeed() {
return _speed;
}
}
Loading

0 comments on commit 703d780

Please sign in to comment.