diff --git a/lib/pages/html/controller.dart b/lib/pages/html/controller.dart index 24cbd9c0..539b3919 100644 --- a/lib/pages/html/controller.dart +++ b/lib/pages/html/controller.dart @@ -52,11 +52,11 @@ class HtmlRenderController extends ReplyController { }); DynamicsHttp.articleInfo(cvId: id.substring(2)).then((res) { if (res['status']) { - favStat.value = { + favStat.addAll({ 'status': true, 'isFav': res['data']?['favorite'] ?? false, 'favNum': res['data']?['stats']?['favorite'] ?? 0, - }; + }); } }); } else { @@ -85,11 +85,11 @@ class HtmlRenderController extends ReplyController { if (res != null) { type = res['commentType']; if (res['favorite'] != null) { - favStat.value = { + favStat.addAll({ 'status': true, 'isFav': res['favorite']['status'] ?? false, 'favNum': res['favorite']['count'] ?? 0, - }; + }); } } } else { diff --git a/lib/pages/login/controller.dart b/lib/pages/login/controller.dart index 68f207c9..c519b453 100644 --- a/lib/pages/login/controller.dart +++ b/lib/pages/login/controller.dart @@ -23,7 +23,7 @@ class LoginPageController extends GetxController final TextEditingController smsCodeTextController = TextEditingController(); final TextEditingController cookieTextController = TextEditingController(); - Rx> codeInfo = Rx>({}); + RxMap codeInfo = RxMap({}); late TabController tabController; @@ -31,7 +31,7 @@ class LoginPageController extends GetxController CaptchaDataModel captchaData = CaptchaDataModel(); RxInt qrCodeLeftTime = 180.obs; - Rx statusQRCode = ''.obs; + RxString statusQRCode = ''.obs; Map selectedCountryCodeId = Constants.internationalDialingPrefix.first; @@ -68,8 +68,7 @@ class LoginPageController extends GetxController LoginHttp.getHDcode().then((res) { if (res['status']) { qrCodeTimer?.cancel(); - codeInfo.value = res; - codeInfo.refresh(); + codeInfo.addAll(res); qrCodeTimer = Timer.periodic(const Duration(milliseconds: 1000), (t) { qrCodeLeftTime.value = 180 - t.tick; if (qrCodeLeftTime <= 0) { @@ -79,8 +78,7 @@ class LoginPageController extends GetxController return; } - LoginHttp.codePoll(codeInfo.value['data']['auth_code']) - .then((value) async { + LoginHttp.codePoll(codeInfo['data']['auth_code']).then((value) async { if (value['status']) { t.cancel(); statusQRCode.value = '扫码成功'; diff --git a/lib/pages/login/view.dart b/lib/pages/login/view.dart index b9878d37..1794d6f4 100644 --- a/lib/pages/login/view.dart +++ b/lib/pages/login/view.dart @@ -80,7 +80,7 @@ class _LoginPageState extends State { RepaintBoundary( key: globalKey, child: Obx(() { - if (_loginPageCtr.codeInfo.value['data']?['url'] == null) { + if (_loginPageCtr.codeInfo['data']?['url'] == null) { return Container( height: 200, width: 200, @@ -96,7 +96,7 @@ class _LoginPageState extends State { color: Colors.white, padding: const EdgeInsets.all(8), child: PrettyQrView.data( - data: _loginPageCtr.codeInfo.value['data']!['url']!, + data: _loginPageCtr.codeInfo['data']!['url']!, decoration: PrettyQrDecoration( shape: PrettyQrRoundedSymbol( color: Colors.black87, @@ -116,14 +116,13 @@ class _LoginPageState extends State { Obx(() => GestureDetector( onTap: () { // 复制到剪贴板 - Utils.copyText( - _loginPageCtr.codeInfo.value['data']?['url'] ?? '', + Utils.copyText(_loginPageCtr.codeInfo['data']?['url'] ?? '', toastText: '已复制到剪贴板,可粘贴至已登录的app私信处发送,然后点击已发送的链接打开'); }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20), - child: Text(_loginPageCtr.codeInfo.value['data']?['url'] ?? "", + child: Text(_loginPageCtr.codeInfo['data']?['url'] ?? "", style: Theme.of(context).textTheme.labelSmall!.copyWith( color: Theme.of(context) .colorScheme diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index 2837311c..8423e7af 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -50,8 +50,7 @@ class VideoIntroController extends GetxController { Rx videoDetail = VideoDetailData().obs; // up主粉丝数 - Rx> userStat = - Rx>({'follower': '-'}); + RxMap userStat = RxMap({'follower': '-'}); dynamic videoTags; @@ -82,8 +81,8 @@ class VideoIntroController extends GetxController { Timer? timer; String heroTag = ''; late ModelResult modelResult; - Rx> queryVideoIntroData = - Rx>({"status": true}); + RxMap queryVideoIntroData = + RxMap({"status": true}); ExpandableController? expandableCtr; @@ -181,7 +180,7 @@ class VideoIntroController extends GetxController { SmartDialog.showToast( "${result['code']} ${result['msg']} ${result['data']}"); } - queryVideoIntroData.value = result; + queryVideoIntroData.addAll(result); if (isLogin) { queryAllStatus(); queryFollowStatus(); @@ -207,10 +206,10 @@ class VideoIntroController extends GetxController { }, ).then((res) { if (res.data['code'] == 0) { - staffRelations.value = { + staffRelations.addAll({ 'status': true, if (res.data['data'] != null) ...res.data['data'], - }; + }); } }); } else { @@ -220,7 +219,7 @@ class VideoIntroController extends GetxController { var result = await MemberHttp.memberCardInfo(mid: videoDetail.value.owner!.mid!); if (result['status']) { - userStat.value = result['data']; + userStat.addAll(result['data']); } } } @@ -349,7 +348,7 @@ class VideoIntroController extends GetxController { } int copyright = - (queryVideoIntroData.value['data'] as VideoDetailData?)?.copyright ?? 1; + (queryVideoIntroData['data'] as VideoDetailData?)?.copyright ?? 1; if ((copyright != 1 && _coinNum.value >= 1) || _coinNum.value >= 2) { SmartDialog.showToast('达到投币上限啦~'); return; diff --git a/lib/pages/video/detail/introduction/view.dart b/lib/pages/video/detail/introduction/view.dart index 154e0949..3dde1b53 100644 --- a/lib/pages/video/detail/introduction/view.dart +++ b/lib/pages/video/detail/introduction/view.dart @@ -298,18 +298,18 @@ class _VideoInfoState extends State { mainAxisSize: MainAxisSize.min, children: [ Obx(() => Avatar( - avatar: videoIntroController.userStat - .value['card']?['face'] ?? + avatar: videoIntroController + .userStat['card']?['face'] ?? '', size: 35, badgeSize: 14, - isVip: (videoIntroController.userStat - .value['card']?['vip'] - ?['status'] ?? + isVip: (videoIntroController + .userStat['card'] + ?['vip']?['status'] ?? -1) > 0, officialType: videoIntroController - .userStat.value['card'] + .userStat['card'] ?['official_verify']?['type'], // garbPendantImage: videoIntroController.userStat.value['card']?['pendant']?['image'], )), @@ -320,23 +320,23 @@ class _VideoInfoState extends State { children: [ Obx( () => Text( - videoIntroController.userStat - .value['card']?['name'] ?? + videoIntroController + .userStat['card'] + ?['name'] ?? "", maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 13, - color: (videoIntroController.userStat - .value[ - 'card']?['vip'] + color: (videoIntroController.userStat[ + 'card'] + ?['vip'] ?['status'] ?? -1) > 0 && videoIntroController - .userStat - .value['card'] - ?[ + .userStat[ + 'card']?[ 'vip']?['type'] == 2 ? context.vipColor @@ -347,7 +347,7 @@ class _VideoInfoState extends State { const SizedBox(height: 0), Obx( () => Text( - '${Utils.numFormat(videoIntroController.userStat.value['follower'])}粉丝 ${videoIntroController.userStat.value['archive_count'] != null ? '${Utils.numFormat(videoIntroController.userStat.value['archive_count'])}视频' : ''}', + '${Utils.numFormat(videoIntroController.userStat['follower'])}粉丝 ${videoIntroController.userStat['archive_count'] != null ? '${Utils.numFormat(videoIntroController.userStat['archive_count'])}视频' : ''}', style: TextStyle( fontSize: 12, color: @@ -741,24 +741,23 @@ class _VideoInfoState extends State { ), ), Obx( - () => - videoIntroController.queryVideoIntroData.value["status"] - ? const SizedBox.shrink() - : Center( - child: TextButton.icon( - icon: const Icon(Icons.refresh), - onPressed: () { - videoIntroController.queryVideoIntroData - .value["status"] = true; - videoIntroController.queryVideoIntro(); - if (videoDetailCtr.videoUrl.isNullOrEmpty && - videoDetailCtr.isQuerying.not) { - videoDetailCtr.queryVideoUrl(); - } - }, - label: const Text("点此重新加载"), - ), - ), + () => videoIntroController.queryVideoIntroData["status"] + ? const SizedBox.shrink() + : Center( + child: TextButton.icon( + icon: const Icon(Icons.refresh), + onPressed: () { + videoIntroController + .queryVideoIntroData["status"] = true; + videoIntroController.queryVideoIntro(); + if (videoDetailCtr.videoUrl.isNullOrEmpty && + videoDetailCtr.isQuerying.not) { + videoDetailCtr.queryVideoUrl(); + } + }, + label: const Text("点此重新加载"), + ), + ), ), // 点赞收藏转发 布局样式2 if (!isHorizontal) ...[ diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 19c96963..b6baa0bf 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -63,40 +63,40 @@ class PlPlayerController { final Rx _buffered = Rx(Duration.zero); final RxInt bufferedSeconds = 0.obs; - final Rx _playerCount = Rx(0); + final RxInt _playerCount = 0.obs; late double lastPlaybackSpeed = 1.0; - final Rx _playbackSpeed = 1.0.obs; - final Rx _longPressSpeed = 2.0.obs; - final Rx _currentVolume = 1.0.obs; - final Rx _currentBrightness = (-1.0).obs; + final RxDouble _playbackSpeed = 1.0.obs; + final RxDouble _longPressSpeed = 2.0.obs; + final RxDouble _currentVolume = 1.0.obs; + final RxDouble _currentBrightness = (-1.0).obs; - final Rx _mute = false.obs; - final Rx _showControls = false.obs; - final Rx _showVolumeStatus = false.obs; - final Rx _showBrightnessStatus = false.obs; - final Rx _longPressStatus = false.obs; - final Rx _controlsLock = false.obs; - final Rx _isFullScreen = false.obs; + final RxBool _mute = false.obs; + final RxBool _showControls = false.obs; + final RxBool _showVolumeStatus = false.obs; + final RxBool _showBrightnessStatus = false.obs; + final RxBool _longPressStatus = false.obs; + final RxBool _controlsLock = false.obs; + final RxBool _isFullScreen = false.obs; // 默认投稿视频格式 - static Rx _videoType = 'archive'.obs; + static RxString _videoType = 'archive'.obs; - final Rx _direction = 'horizontal'.obs; + final RxString _direction = 'horizontal'.obs; final Rx _videoFit = Rx(videoFitType[1]['attr']); - final Rx _videoFitDesc = Rx(videoFitType[1]['desc']); + final RxString _videoFitDesc = videoFitType[1]['desc'].obs; late StreamSubscription _dataListenerForVideoFit; late StreamSubscription _dataListenerForEnterFullscreen; /// 后台播放 - late final Rx _continuePlayInBackground = false.obs; + late final RxBool _continuePlayInBackground = false.obs; - late final Rx _flipX = false.obs; + late final RxBool _flipX = false.obs; - late final Rx _flipY = false.obs; + late final RxBool _flipY = false.obs; /// - final Rx _isSliderMoving = false.obs; + final RxBool _isSliderMoving = false.obs; PlaylistMode _looping = PlaylistMode.none; bool _autoPlay = false; final bool _listenersInitialized = false; @@ -165,7 +165,7 @@ class PlPlayerController { Stream get onBufferedChanged => _buffered.stream; // 视频静音 - Rx get mute => _mute; + RxBool get mute => _mute; Stream get onMuteChanged => _mute.stream; /// [videoPlayerController] instance of Player @@ -174,7 +174,7 @@ class PlPlayerController { /// [videoController] instance of Player VideoController? get videoController => _videoController; - Rx get isSliderMoving => _isSliderMoving; + RxBool get isSliderMoving => _isSliderMoving; /// 进度条位置及监听 Rx get sliderPosition => _sliderPosition; @@ -184,24 +184,24 @@ class PlPlayerController { // Stream get onSliderPositionChanged => _sliderPosition.stream; /// 是否展示控制条及监听 - Rx get showControls => _showControls; + RxBool get showControls => _showControls; Stream get onShowControlsChanged => _showControls.stream; /// 音量控制条展示/隐藏 - Rx get showVolumeStatus => _showVolumeStatus; + RxBool get showVolumeStatus => _showVolumeStatus; Stream get onShowVolumeStatusChanged => _showVolumeStatus.stream; /// 亮度控制条展示/隐藏 - Rx get showBrightnessStatus => _showBrightnessStatus; + RxBool get showBrightnessStatus => _showBrightnessStatus; Stream get onShowBrightnessStatusChanged => _showBrightnessStatus.stream; /// 音量控制条 - Rx get volume => _currentVolume; + RxDouble get volume => _currentVolume; Stream get onVolumeChanged => _currentVolume.stream; /// 亮度控制条 - Rx get brightness => _currentBrightness; + RxDouble get brightness => _currentBrightness; Stream get onBrightnessChanged => _currentBrightness.stream; /// 是否循环 @@ -212,40 +212,40 @@ class PlPlayerController { /// 视频比例 Rx get videoFit => _videoFit; - Rx get videoFitDEsc => _videoFitDesc; + RxString get videoFitDEsc => _videoFitDesc; /// 后台播放 - Rx get continuePlayInBackground => _continuePlayInBackground; + RxBool get continuePlayInBackground => _continuePlayInBackground; /// 听视频 - late final Rx onlyPlayAudio = false.obs; + late final RxBool onlyPlayAudio = false.obs; /// 镜像 - Rx get flipX => _flipX; + RxBool get flipX => _flipX; - Rx get flipY => _flipY; + RxBool get flipY => _flipY; /// 是否长按倍速 - Rx get longPressStatus => _longPressStatus; + RxBool get longPressStatus => _longPressStatus; - Rx isBuffering = true.obs; + RxBool isBuffering = true.obs; /// 屏幕锁 为true时,关闭控制栏 - Rx get controlsLock => _controlsLock; + RxBool get controlsLock => _controlsLock; /// 全屏状态 - Rx get isFullScreen => _isFullScreen; + RxBool get isFullScreen => _isFullScreen; /// 全屏方向 - Rx get direction => _direction; + RxString get direction => _direction; - Rx get playerCount => _playerCount; + RxInt get playerCount => _playerCount; /// - Rx get videoType => _videoType; + RxString get videoType => _videoType; /// 弹幕开关 - Rx isOpenDanmu = false.obs; + RxBool isOpenDanmu = false.obs; late final showFSActionItem = GStorage.showFSActionItem; late final enableShrinkVideoSize = GStorage.enableShrinkVideoSize;