~aleteoryx/muditaos

734df05ba10077fb884964a2fce3145778c21465 — Pawel Olejniczak 5 years ago a33c18f
[EGD-3333] Add handling for NumberWithIconsWidget
M module-apps/application-phonebook/widgets/NumberWithIconsWidget.cpp => module-apps/application-phonebook/widgets/NumberWithIconsWidget.cpp +20 -1
@@ 1,12 1,15 @@
#include "NumberWithIconsWidget.hpp"

#include "application-phonebook/data/PhonebookStyle.hpp"
#include "UiCommonActions.hpp"

#include <BottomBar.hpp>

namespace gui
{
    NumberWithIconsWidget::NumberWithIconsWidget(gui::Item *parent, const std::string &number)
    NumberWithIconsWidget::NumberWithIconsWidget(app::Application *app,
                                                 gui::Item *parent,
                                                 const utils::PhoneNumber::View &number)
    {
        hBox = new HBox(parent, 0, 0, style::window::default_body_width, 0);
        hBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);


@@ 22,8 25,24 @@ namespace gui
        numberText->setPenWidth(style::window::default_border_no_focus_w);

        phoneImage = new Image(hBox, 0, 0, 32, 32, "phonebook_phone_ringing");
        phoneImage->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM | RectangleEdgeFlags::GUI_RECT_EDGE_TOP);
        phoneImage->inputCallback = [&](Item &item, const InputEvent &input) {
            if (input.keyCode == KeyCode::KEY_ENTER && input.state == InputEvent::State::keyReleasedShort) {
                return app::call(app, number);
            }
            LOG_ERROR("Call operation failed");
            return false;
        };

        smsImage = new Image(hBox, 0, 0, 32, 32, "mail");
        smsImage->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM | RectangleEdgeFlags::GUI_RECT_EDGE_TOP);
        smsImage->inputCallback = [&](Item &item, const InputEvent &input) {
            if (input.keyCode == KeyCode::KEY_ENTER && input.state == InputEvent::State::keyReleasedShort) {
                return app::sms(app, app::SmsOperation::New, number);
            }
            LOG_ERROR("SMS operation failed");
            return false;
        };
    }

} /* namespace gui */

M module-apps/application-phonebook/widgets/NumberWithIconsWidget.hpp => module-apps/application-phonebook/widgets/NumberWithIconsWidget.hpp +4 -2
@@ 1,5 1,7 @@
#pragma once

#include "Application.hpp"

#include <BoxLayout.hpp>
#include <Image.hpp>
#include <Text.hpp>


@@ 9,8 11,8 @@ namespace gui
    class NumberWithIconsWidget
    {
      public:
        NumberWithIconsWidget(gui::Item *parent, const std::string &number);
        ~NumberWithIconsWidget()  = default;
        NumberWithIconsWidget(app::Application *app, gui::Item *parent, const utils::PhoneNumber::View &number);
        ~NumberWithIconsWidget() = default;

        HBox *hBox        = nullptr;
        Text *numberText  = nullptr;