forked from CoretechR/OMOTE
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Wifi Settings Ability to enter password and attempt connection
- Loading branch information
MatthewColvin
committed
Oct 17, 2023
1 parent
73b9e7d
commit cf646f2
Showing
7 changed files
with
138 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ class ID { | |
Label, | ||
List, | ||
DropDown, | ||
Keyboard, | ||
BrightnessSlider, | ||
INVALID_WIDGET_ID | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include "Keyboard.hpp" | ||
#include "BackgroundScreen.hpp" | ||
#include <cmath> | ||
|
||
using namespace UI; | ||
using namespace UI::Widget; | ||
|
||
Keyboard::Keyboard(std::function<void(std::string)> aOnUserCompletedTextEntry) | ||
: Base(ID::Widgets::Keyboard), | ||
mKeyboard(AddElement<Base>(std::make_unique<Base>( | ||
lv_keyboard_create(LvglSelf()), ID::Widgets::INVALID_WIDGET_ID))), | ||
mTextArea(AddElement<Base>(std::make_unique<Base>( | ||
lv_textarea_create(LvglSelf()), ID::Widgets::INVALID_WIDGET_ID))), | ||
mOnUserCompleteTextEntry(aOnUserCompletedTextEntry) { | ||
lv_keyboard_set_textarea(mKeyboard->LvglSelf(), mTextArea->LvglSelf()); | ||
|
||
mKeyboard->HandleLvglEvent([this](auto aEvent) { | ||
if (aEvent->code == LV_EVENT_READY) { | ||
std::string userEnteredText = | ||
std::string(lv_textarea_get_text(mTextArea->LvglSelf())); | ||
mOnUserCompleteTextEntry(userEnteredText); | ||
} | ||
}); | ||
} | ||
|
||
void Keyboard::OnAdded(UIElement *aNewParent) { | ||
auto selfHeight = ceil(aNewParent->GetContentHeight() * 0.60f); | ||
// Align to final position and get Y for end of animation | ||
SetHeight(selfHeight); | ||
AlignTo(aNewParent, LV_ALIGN_BOTTOM_MID); | ||
auto endAnimationY = GetY(); | ||
auto startAnimationY = aNewParent->GetBottom(); | ||
|
||
mAnimateIn = std::make_unique<Animation>([this](auto aY) { SetY(aY); }, 500, | ||
startAnimationY, endAnimationY); | ||
mAnimateIn->Start(); | ||
} | ||
|
||
void Keyboard::AnimateOut() { | ||
if (mOnKeyboardAnimatedOut) { | ||
mAnimateIn->HandleAnimationComplete(mOnKeyboardAnimatedOut); | ||
} | ||
mAnimateIn->Reverse(); | ||
}; | ||
|
||
void Keyboard::SetHeight(lv_coord_t aHeight) { | ||
Base::SetHeight(aHeight); | ||
auto txtAreaHight = 33; | ||
mTextArea->SetHeight(txtAreaHight); | ||
mKeyboard->SetHeight(GetContentHeight() - txtAreaHight); | ||
mTextArea->AlignTo(this, LV_ALIGN_TOP_MID); | ||
mKeyboard->AlignTo(mTextArea, LV_ALIGN_OUT_BOTTOM_MID); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
#include "Animation.hpp" | ||
#include "WidgetBase.hpp" | ||
#include <memory> | ||
#include <string> | ||
|
||
namespace UI::Widget { | ||
|
||
class Keyboard : public Base { | ||
public: | ||
Keyboard(std::function<void(std::string)> aOnUserCompletedTextEntry); | ||
|
||
void OnAdded(UIElement *aNewParent) override; | ||
|
||
void SetHeight(lv_coord_t aHeight) override; | ||
|
||
void AnimateOut(); | ||
void OnKeyboardAnimatedOut(std::function<void()> aOnKeyboardAnimatedOut) { | ||
mOnKeyboardAnimatedOut = aOnKeyboardAnimatedOut; | ||
} | ||
|
||
private: | ||
std::function<void()> mOnKeyboardAnimatedOut; | ||
std::function<void(std::string)> mOnUserCompleteTextEntry; | ||
std::unique_ptr<Animation> mAnimateIn; | ||
|
||
Base *mKeyboard; | ||
Base *mTextArea; | ||
}; | ||
|
||
} // namespace UI::Widget |