/*---------------------------------------------------------------------------- * Copyright (c) TJD Technologies Co., Ltd. 2025. All rights reserved. * * Description: TjdUiAppPlayerView.h * * Author: luziquan@ss-tjd.com * * Create: 2024-06-07 *--------------------------------------------------------------------------*/ #ifndef TJD_UI_APP_PLAYER_VIEW_H #define TJD_UI_APP_PLAYER_VIEW_H #include "TjdUiAppPlayerAdapter.h" #include "TjdUiAppPlayerPresenter.h" #include "View.h" #include "components/tjd_ui_transform_list_group.h" #include "components/ui_button.h" #include "components/ui_checkbox.h" #include "components/ui_label_ext.h" #include "components/ui_list.h" #include "components/ui_scroll_view.h" #include "components/ui_scroll_view_nested.h" namespace TJD { class PlayerUIScrollView : public OHOS::UIScrollViewNested { public: PlayerUIScrollView() {} ~PlayerUIScrollView() {} bool OnDragStartEvent(const OHOS::DragEvent &event) override; bool OnDragEvent(const OHOS::DragEvent &event) override; bool OnDragEndEvent(const OHOS::DragEvent &event) override; private: bool isOnStart_{false}; }; class PlayerViewBase : public OHOS::UIScrollView { public: PlayerViewBase() { SetHorizontalScrollState(false); } virtual ~PlayerViewBase() {} virtual void ShowView() { SetVisible(true); }; virtual void HideView() { SetVisible(false); }; void ScrollBy(int16_t xDistance, int16_t yDistance) { SetReboundSize(0); UIScrollView::ScrollBy(xDistance, yDistance); SetReboundSize(200); } }; class PlayerMainView : public PlayerViewBase { public: PlayerMainView(); ~PlayerMainView(); void SetPlayerButtonState(OHOS::UICheckBox::UICheckBoxState state); void ChangedImage(int resId); void SetDeviceType(PlayerSource state); OHOS::UICheckBox::UICheckBoxState GetPlayerButtonState(void) { return btnPlayerState_; }; void SetMusicNameText(const char *musicName) { musicName_.SetText(musicName); } void SetLyricText(const char *lyric) { lyric_.SetText(lyric); }; void SetCurTimeText(const char *curTime) { curTime_.SetText(curTime); } void SetDurationText(const char *duration) { duration_.SetText(duration); } void SetSliderValue(int16_t value) { slider_.SetValue(value); } private: class SliderAnimatorCallback; class CustomSlider : public OHOS::UISlider { public: CustomSlider() : UISlider() {} ~CustomSlider() override; bool OnDragStartEvent(const OHOS::DragEvent &event) override; bool OnDragEndEvent(const OHOS::DragEvent &event) override; bool OnClickEvent(const OHOS::ClickEvent &event) override { return false; } void StartAnimator(uint16_t startSize, uint16_t endSize); private: SliderAnimatorCallback *sliderAnimatorCallback_{nullptr}; OHOS::Animator *animator_{nullptr}; }; OHOS::UICheckBox::UICheckBoxState btnPlayerState_{OHOS::UICheckBox::UICheckBoxState::UNSELECTED}; OHOS::UILabelExt title_; OHOS::UIImageView imgbackGround_; OHOS::UIImageView songPicture_; OHOS::UILabel musicName_; OHOS::UILabel lyric_; OHOS::UILabel curTime_; OHOS::UILabel duration_; OHOS::UIButton btnPlayer_; OHOS::UIImageView musicList_; OHOS::UIImageView left_; OHOS::UIImageView right_; OHOS::UIImageView connect_; OHOS::UIImageView loop_; OHOS::UIImageView volume_; CustomSlider slider_; }; class PlayersCaseView : public OHOS::UIScrollView { public: PlayersCaseView(); ~PlayersCaseView(); void SetPlaying(bool isPlaying); void SetName(const char *name) { name_.SetText(name); } void SetOnClickListener(OHOS::UIView::OnClickListener *clickListener) { mainView_.SetOnClickListener(clickListener); deleteIcon_.SetOnClickListener(clickListener); } void StartAnimator(uint16_t ACCLevel, int16_t dragDistanceX, int16_t dragDistanceY); bool OnDragStartEvent(const OHOS::DragEvent &event) override; bool OnDragEvent(const OHOS::DragEvent &event) override; bool OnDragEndEvent(const OHOS::DragEvent &event) override; private: OHOS::UIView leftHide_; OHOS::UIView rightHide_; PlayerUIScrollView mainView_; OHOS::UIImageView deleteIcon_; OHOS::UIImageAnimatorView imageAnimator_; OHOS::UILabel name_; bool intercept = false; bool startDrag = false; }; class PlayersCaseViewGroup : public OHOS::UIViewGroup { public: PlayersCaseViewGroup(std::list *list); ~PlayersCaseViewGroup(); void RefreshView(void); std::list *GetPlayersItemList() { return playersItemList_; } private: std::list *playerCaseList_{nullptr}; std::list *playersItemList_{nullptr}; PlayerListOnClickListener *clickListener_{nullptr}; }; class PlayerListView : public PlayerViewBase { public: PlayerListView(); ~PlayerListView(); void ShowView() override; void HideView() override; void SetTargetPlaying(int16_t index, bool isPlaying); void RefrashView(); private: OHOS::UILabelExt title_; PlayersCaseViewGroup *listGroup_; OHOS::UIView topLine_; OHOS::UIView bottomLine_; OHOS::UILabelExt desc_; }; class PlayerVolumeView : public PlayerViewBase { public: PlayerVolumeView(); ~PlayerVolumeView() { RemoveAll(); }; void ShowView() override; void HideView() override; void SetVolume(int32_t volume) { sliderVolume_.SetValue(volume); } private: OHOS::UISlider sliderVolume_; OHOS::UIImageView imgVolume_; }; class PlayerDeviceView : public PlayerViewBase { public: PlayerDeviceView(); ~PlayerDeviceView(); void SetHeadsetState(OHOS::UICheckBox::UICheckBoxState state); void SetDeviceType(PlayerSource state); void ShowView() override; void HideView() override; private: DeviceSelectListItemInfo phoneItemInfo = {}; DeviceSelectListItemInfo watchItemInfo = {}; DeviceSelectListItemInfo btItemInfo = {}; TjdUITransformListGroupAdapter> *deviceSelectListAdapter_{nullptr}; TjdUITransformListGroup *deviceSelectList_{nullptr}; std::list deviceSelectInfoList; }; class PlayerSearchView : public PlayerViewBase { public: PlayerSearchView(); ~PlayerSearchView(); void ShowView() override; void HideView() override; private: void RefreshList(); TjdUITransformListGroupAdapter> *headsetListAdapter_{nullptr}; TjdUITransformListGroup *headsetList_{nullptr}; std::list headsetInfoList; OHOS::UIImageView searchBtn_; OHOS::UIImageView listSearchBtn_; OHOS::UILabelExt desc_; OHOS::UILabelExt title_; int imageRes[3]; }; class PlayerLowPowerView : public PlayerViewBase { public: PlayerLowPowerView(); ~PlayerLowPowerView() { RemoveAll(); }; private: OHOS::UILabelExt lowPowerLabel_; OHOS::UILabelExt desc_; }; class PlayerWaitView : public PlayerViewBase { public: PlayerWaitView(); ~PlayerWaitView(); void ShowView() override; void HideView() override; void SetDesc(uint16_t textId); private: OHOS::ImageAnimatorInfo *waitInfo_{nullptr}; OHOS::UIImageAnimatorView animator_; OHOS::UILabelExt desc_; }; class PlayerDeviceConnectView : public PlayerViewBase { public: PlayerDeviceConnectView(); ~PlayerDeviceConnectView() { RemoveAll(); }; void SetDeviceInfo(const char *name, bool connectState); private: OHOS::UILabelExt title_; OHOS::UILabel name_; OHOS::UILabelExt connectState_; OHOS::UIImageView connEnterButton_; OHOS::UIImageView connCancelButton_; OHOS::UIImageView unpairButton_; }; class PlayerConnectSuccessView : public PlayerViewBase { public: PlayerConnectSuccessView(); ~PlayerConnectSuccessView() { RemoveAll(); }; private: OHOS::UILabelExt title_; OHOS::UIImageView bg_; }; class PlayerConnectFailView : public PlayerViewBase { public: PlayerConnectFailView(); ~PlayerConnectFailView() { RemoveAll(); }; private: OHOS::UILabelExt title_; OHOS::UIImageView bg_; }; class PlayerConnectAppFailView : public PlayerViewBase { public: PlayerConnectAppFailView(); ~PlayerConnectAppFailView() { RemoveAll(); }; private: OHOS::UILabelExt title_; OHOS::UIImageView bg_; }; // 确认删除录音条目界面 class PlayerCaseDeleteEntryView : public PlayerViewBase { public: PlayerCaseDeleteEntryView(); ~PlayerCaseDeleteEntryView() { RemoveAll(); }; void SetDesc(const char *date); private: OHOS::UILabelExt title_; OHOS::UILabel name_; OHOS::UILabelExt desc_; OHOS::UIImageView btnCancel_; OHOS::UIImageView btnEntry_; }; class TjdUiAppPlayerPresenter; class TjdUiAppPlayerView : public OHOS::View, public OHOS::UIViewGroup { public: TjdUiAppPlayerView(); ~TjdUiAppPlayerView(); static TjdUiAppPlayerView *GetInstance(void); void OnStart() override; void OnStop() override; void InitTargetView(PlayerViewIndex index); void ShowView(PlayerViewIndex view); void ChangedImage(int resId); void SetDeviceInfo(const char *name, bool connectState); void SetWaitViewInfo(uint16_t textId); void SetPlayingMusic(int16_t index, bool isPlaying); void ChangedVolume(int32_t volume); void SetCurrentMusicName(const char *musicName); void SyncLyric(const char *lyric); void SwitchPlayerButtonState(void); void SetPlayerButtonState(OHOS::UICheckBox::UICheckBoxState state); void SetConnectDevice(OHOS::UICheckBox::UICheckBoxState state); OHOS::UICheckBox::UICheckBoxState GetPlayerButtonState(void); PlayerViewIndex GetCurrentView(void) { return currentViewIndex_; }; void SetDeviceState(PlayerSource state, bool isConnectEarpod = false); OHOS::ImageAnimatorInfo *GetImageAnimatorInfo(void); void SetDeleteEntryDesc(const char *name); void RefrashMusicList(void); void SetTime(int64_t curTime, uint64_t duration, bool dragging = false); private: void InitImageInfo(); OHOS::ImageAnimatorInfo *musicStateAnimator_{nullptr}; PlayerViewIndex currentViewIndex_ = PlayerViewIndex::PLAYER_VIEW; OHOS::UIViewGroup *mainView_{nullptr}; PlayerViewBase *viewManager_[PlayerViewIndex::PLAYER_UNKNOWN]{nullptr}; uint64_t lastDuration_ = 0; }; } // namespace TJD #endif