308 lines
8.6 KiB
C++
308 lines
8.6 KiB
C++
#ifndef TJDUIAPP_ALARM_VIEW
|
|
#define TJDUIAPP_ALARM_VIEW
|
|
|
|
#include "TjdUiAppAlarmPresenter.h"
|
|
#include "View.h"
|
|
#include "components/tjd_ui_time_picker.h"
|
|
#include "components/ui_button.h"
|
|
#include "components/ui_image_view.h"
|
|
#include "components/ui_label.h"
|
|
#include "components/ui_list.h"
|
|
#include "components/ui_scroll_view.h"
|
|
#include "components/ui_scroll_view_nested.h"
|
|
#include "graphic_timer.h"
|
|
#include "ui_label_ext.h"
|
|
#include <list>
|
|
#include <map>
|
|
|
|
|
|
namespace TJD {
|
|
class TjdAlarmAdapter;
|
|
class TjdAlarmItemView;
|
|
|
|
class AlarmUIScrollView : public OHOS::UIScrollViewNested
|
|
{
|
|
public:
|
|
AlarmUIScrollView() {}
|
|
~AlarmUIScrollView() {}
|
|
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 AlarmViewBase : public OHOS::UIScrollView
|
|
{
|
|
public:
|
|
AlarmViewBase() { SetHorizontalScrollState(false); }
|
|
virtual ~AlarmViewBase() {}
|
|
virtual void ShowView()
|
|
{
|
|
SetVisible(true);
|
|
firstShow_ = false;
|
|
};
|
|
virtual void HideView() { SetVisible(false); };
|
|
|
|
protected:
|
|
bool firstShow_{true};
|
|
};
|
|
|
|
class AlarmAddAnimatorCallback : public OHOS::AnimatorCallback
|
|
{
|
|
public:
|
|
AlarmAddAnimatorCallback(OHOS::UIView *view) : view_(view) {}
|
|
void Callback(OHOS::UIView *view) override;
|
|
void SetAnimator(OHOS::Animator *animator) { animator_ = animator; }
|
|
|
|
private:
|
|
OHOS::Animator *animator_{nullptr};
|
|
OHOS::UIView *view_{nullptr};
|
|
uint32_t lastTime_ = 0;
|
|
bool needHide_{true};
|
|
};
|
|
|
|
class AlarmHomeView : public AlarmViewBase
|
|
{
|
|
public:
|
|
AlarmHomeView(AlarmHomeView **container);
|
|
~AlarmHomeView();
|
|
void ShowView() override;
|
|
void SwitchHomeType(bool isFirst);
|
|
TjdAlarmAdapter *GetAdapter() { return adapter_; }
|
|
class HomeList : public OHOS::UIList, public OHOS::ListScrollListener
|
|
{
|
|
public:
|
|
bool OnDragStartEvent(const OHOS::DragEvent &event) override;
|
|
bool OnDragEvent(const OHOS::DragEvent &event) override;
|
|
// void OnScrollStart(int16_t index, UIView* view) override;
|
|
bool OnDragEndEvent(const OHOS::DragEvent &event) override;
|
|
void OnScrollEnd(int16_t index, OHOS::UIView *view) override;
|
|
void OnItemSelected(int16_t index, OHOS::UIView *view) override;
|
|
void InteractiveProcessing(OHOS::UIView *view);
|
|
|
|
private:
|
|
bool scrollEnable{true};
|
|
TjdAlarmItemView *itemViewSele{nullptr};
|
|
TjdAlarmItemView *preItemViewSele{nullptr};
|
|
};
|
|
|
|
OHOS::UILabelExt label_;
|
|
OHOS::UIButton add_;
|
|
OHOS::UIButton firstAdd_;
|
|
HomeList list_;
|
|
TjdAlarmAdapter *adapter_{nullptr};
|
|
OHOS::Animator *AlarmAddAnimator_{nullptr};
|
|
AlarmAddAnimatorCallback *callback_{nullptr};
|
|
};
|
|
|
|
class AlarmSetTimeView : public AlarmViewBase
|
|
{
|
|
public:
|
|
AlarmSetTimeView(AlarmSetTimeView **container);
|
|
~AlarmSetTimeView() { RemoveAll(); }
|
|
void ShowView() override;
|
|
void HideView() override;
|
|
|
|
// class AlarmTimeSetting : public TjdUITimePicker
|
|
// {
|
|
// public:
|
|
// void EnterCallback(int32_t hour, int32_t minute) override;
|
|
// void SelectPickerCallback(OHOS::UIPicker &view);
|
|
// };
|
|
// AlarmTimeSetting timePick;
|
|
|
|
TjdUITimePicker timePick;
|
|
AlarmView enterView_;
|
|
|
|
uint8_t hour_ = 0;
|
|
uint8_t minute_ = 0;
|
|
};
|
|
|
|
class AlarmCycleSetView : public AlarmViewBase
|
|
{
|
|
public:
|
|
AlarmCycleSetView(AlarmCycleSetView **container);
|
|
~AlarmCycleSetView() { RemoveAll(); }
|
|
void ShowView() override;
|
|
|
|
uint8_t GetCycle();
|
|
void UpdateLabelBackgroundColor(uint8_t cycle_mode);
|
|
void ConfirmCallback();
|
|
|
|
class WeekLabel : public OHOS::UILabelExt, public OHOS::UIView::OnClickListener
|
|
{
|
|
public:
|
|
void InitWeekLabel(uint8_t id);
|
|
bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) override;
|
|
uint8_t GetId() { return id_; }
|
|
void SetIsOn(bool isOn);
|
|
bool GetIsOn() { return isOn_; }
|
|
|
|
private:
|
|
uint8_t id_{0};
|
|
bool isOn_{false};
|
|
};
|
|
|
|
AlarmView enterView_;
|
|
OHOS::UILabelExt label_;
|
|
WeekLabel weekLabels[7];
|
|
OHOS::UIButton confirm_;
|
|
};
|
|
|
|
class AlarmEditView : public AlarmViewBase
|
|
{
|
|
public:
|
|
AlarmEditView(AlarmEditView **container);
|
|
~AlarmEditView() { RemoveAll(); }
|
|
|
|
struct TimeStruct
|
|
{
|
|
uint8_t hour;
|
|
uint8_t minute;
|
|
};
|
|
|
|
union EditUnion
|
|
{
|
|
uint8_t cycle_mode;
|
|
TimeStruct time;
|
|
};
|
|
|
|
class AlarmEditItemView : public OHOS::UIViewGroup, public OHOS::UIView::OnClickListener
|
|
{
|
|
public:
|
|
AlarmEditItemView();
|
|
~AlarmEditItemView() { RemoveAll(); }
|
|
bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) override;
|
|
|
|
void SetIndex(uint8_t index) { index_ = index; }
|
|
void SetEditItemData(EditUnion data) { data_ = data; }
|
|
void SetEditItemLabelText();
|
|
void SetMainLabelText(const char *text) { mainLabel_.SetText(text); }
|
|
void SetMinorLabelText(const char *text) { minorLabel_.SetText(text); }
|
|
void SetMainLabelTextId(uint16_t textId) { mainLabel_.SetTextId(textId); }
|
|
void SetMinorLabelTextId(uint16_t textId) { minorLabel_.SetTextId(textId); }
|
|
|
|
private:
|
|
uint8_t index_ = 0;
|
|
EditUnion data_;
|
|
OHOS::UILabelExt mainLabel_;
|
|
OHOS::UILabelExt minorLabel_;
|
|
OHOS::UIImageView image_;
|
|
};
|
|
|
|
class EditAdapter : public OHOS::AbstractAdapter
|
|
{
|
|
public:
|
|
uint16_t GetCount() override { return 2; }
|
|
UIView *GetView(UIView *inView, int16_t index) override;
|
|
|
|
void SetEditItem(uint8_t index, EditUnion data);
|
|
AlarmEditItemView *GetEditItem(uint8_t index) { return &(item_[index]); }
|
|
|
|
private:
|
|
AlarmEditItemView item_[2];
|
|
};
|
|
|
|
class EditList : public OHOS::UIList, public OHOS::ListScrollListener
|
|
{
|
|
public:
|
|
bool OnDragStartEvent(const OHOS::DragEvent &event) override;
|
|
bool OnDragEvent(const OHOS::DragEvent &event) override;
|
|
bool OnDragEndEvent(const OHOS::DragEvent &event) override;
|
|
void OnScrollEnd(int16_t index, UIView *view) override;
|
|
|
|
void SetStartItem(UIViewGroup *item) { startItem_ = item; }
|
|
|
|
private:
|
|
bool scrollEnable_{true};
|
|
UIViewGroup *startItem_ = nullptr;
|
|
UIViewGroup *endItem_ = nullptr;
|
|
};
|
|
|
|
void SelectedCallback(AlarmItem selectedItemInfo);
|
|
|
|
OHOS::UILabelExt label_;
|
|
EditList list_;
|
|
EditAdapter adapter_;
|
|
OHOS::UIButton delete_;
|
|
|
|
AlarmItem selectedItemInfo_{0, false, 0, 0, 0};
|
|
};
|
|
|
|
class AlarmSetFailView : public AlarmViewBase
|
|
{
|
|
public:
|
|
AlarmSetFailView(AlarmSetFailView **container);
|
|
~AlarmSetFailView()
|
|
{
|
|
if (timer_ != nullptr) {
|
|
timer_->Stop();
|
|
delete timer_;
|
|
timer_ = nullptr;
|
|
}
|
|
}
|
|
void ShowView() override
|
|
{
|
|
timer_->Start();
|
|
SetVisible(true);
|
|
}
|
|
|
|
private:
|
|
OHOS::UILabelExt label_;
|
|
OHOS::UIImageView firstAdd_;
|
|
OHOS::GraphicTimer *timer_;
|
|
};
|
|
|
|
class AlarmDeleteRemindView : public AlarmViewBase
|
|
{
|
|
public:
|
|
AlarmDeleteRemindView(AlarmDeleteRemindView **container);
|
|
~AlarmDeleteRemindView() { RemoveAll(); }
|
|
void ShowView() override;
|
|
void HideView() override;
|
|
void UpdateView();
|
|
OHOS::UIImageView imgCancel_;
|
|
OHOS::UIImageView imgConfirm_;
|
|
|
|
private:
|
|
OHOS::UILabelExt lbTip_;
|
|
OHOS::UILabelExt lbFormat_;
|
|
OHOS::UILabel lbTimeStamp_;
|
|
OHOS::UILabelExt lbRepeat_;
|
|
};
|
|
|
|
class TjdUiAppAlarmPresenter;
|
|
class TjdUiAppAlarmView : public OHOS::View<TjdUiAppAlarmPresenter>
|
|
{
|
|
public:
|
|
TjdUiAppAlarmView();
|
|
~TjdUiAppAlarmView();
|
|
static TjdUiAppAlarmView *GetInstance(void);
|
|
|
|
void OnStart() override;
|
|
void OnStop() override;
|
|
|
|
void ShowView(AlarmView showIndex);
|
|
TjdAlarmAdapter *GetAdapter() { return homeContainer_->adapter_; }
|
|
|
|
TjdAlarmItemView *itemView_{nullptr};
|
|
AlarmHomeView *homeContainer_{nullptr};
|
|
AlarmEditView *editContainer_{nullptr};
|
|
AlarmSetTimeView *setTimeContainer_{nullptr};
|
|
AlarmCycleSetView *setCycleContainer_{nullptr};
|
|
AlarmSetFailView *setFailContainer_{nullptr};
|
|
AlarmDeleteRemindView *deleteRemindContainer_{nullptr};
|
|
static uint8_t MaxAlarmCount;
|
|
|
|
private:
|
|
void InitTargetView(AlarmView index);
|
|
|
|
AlarmViewBase *viewManager_[ALARM_VIEW_MAX]{nullptr};
|
|
AlarmUIScrollView *containerAll_{nullptr};
|
|
};
|
|
|
|
} // namespace TJD
|
|
|
|
#endif |