diff --git a/nymea-app/platformhelper.cpp b/nymea-app/platformhelper.cpp index ae1749ef..0cb06832 100644 --- a/nymea-app/platformhelper.cpp +++ b/nymea-app/platformhelper.cpp @@ -29,3 +29,29 @@ void PlatformHelper::setScreenBrightness(int percent) { Q_UNUSED(percent) } + +QColor PlatformHelper::topPanelColor() const +{ + return m_topPanelColor; +} + +void PlatformHelper::setTopPanelColor(const QColor &color) +{ + if (m_topPanelColor != color) { + m_topPanelColor = color; + emit topPanelColorChanged(); + } +} + +QColor PlatformHelper::bottomPanelColor() const +{ + return m_bottomPanelColor; +} + +void PlatformHelper::setBottomPanelColor(const QColor &color) +{ + if (m_bottomPanelColor != color) { + m_bottomPanelColor = color; + emit bottomPanelColorChanged(); + } +} diff --git a/nymea-app/platformhelper.h b/nymea-app/platformhelper.h index 5f6fe2ae..1f27c568 100644 --- a/nymea-app/platformhelper.h +++ b/nymea-app/platformhelper.h @@ -2,6 +2,7 @@ #define PLATFORMHELPER_H #include +#include class PlatformHelper : public QObject { @@ -15,6 +16,8 @@ class PlatformHelper : public QObject Q_PROPERTY(bool canControlScreen READ canControlScreen CONSTANT) Q_PROPERTY(int screenTimeout READ screenTimeout WRITE setScreenTimeout NOTIFY screenTimeoutChanged) Q_PROPERTY(int screenBrightness READ screenBrightness WRITE setScreenBrightness NOTIFY screenBrightnessChanged) + Q_PROPERTY(QColor topPanelColor READ topPanelColor WRITE setTopPanelColor NOTIFY topPanelColorChanged) + Q_PROPERTY(QColor bottomPanelColor READ bottomPanelColor WRITE setBottomPanelColor NOTIFY bottomPanelColorChanged) public: enum HapticsFeedback { @@ -44,6 +47,11 @@ public: virtual int screenBrightness() const; virtual void setScreenBrightness(int percent); + virtual QColor topPanelColor() const; + virtual void setTopPanelColor(const QColor &color); + virtual QColor bottomPanelColor() const; + virtual void setBottomPanelColor(const QColor &color); + Q_INVOKABLE virtual void vibrate(HapticsFeedback feedbackType) = 0; @@ -51,6 +59,12 @@ signals: void permissionsRequestFinished(); void screenTimeoutChanged(); void screenBrightnessChanged(); + void topPanelColorChanged(); + void bottomPanelColorChanged(); + +private: + QColor m_topPanelColor = QColor("black"); + QColor m_bottomPanelColor = QColor("black"); }; #endif // PLATFORMHELPER_H diff --git a/nymea-app/platformintegration/ios/platformhelperios.cpp b/nymea-app/platformintegration/ios/platformhelperios.cpp index 13e4a669..d0fc8945 100644 --- a/nymea-app/platformintegration/ios/platformhelperios.cpp +++ b/nymea-app/platformintegration/ios/platformhelperios.cpp @@ -2,6 +2,7 @@ #include #include + PlatformHelperIOS::PlatformHelperIOS(QObject *parent) : PlatformHelper(parent) { @@ -73,3 +74,15 @@ void PlatformHelperIOS::vibrate(PlatformHelper::HapticsFeedback feedbackType) } } +void PlatformHelperIOS::setTopPanelColor(const QColor &color) +{ + PlatformHelper::setTopPanelColor(color); + setTopPanelColorInternal(color); +} + +void PlatformHelperIOS::setBottomPanelColor(const QColor &color) +{ + PlatformHelper::setBottomPanelColor(color); + setBottomPanelColorInternal(color); +} + diff --git a/nymea-app/platformintegration/ios/platformhelperios.h b/nymea-app/platformintegration/ios/platformhelperios.h index ca0aed10..f498ea2e 100644 --- a/nymea-app/platformintegration/ios/platformhelperios.h +++ b/nymea-app/platformintegration/ios/platformhelperios.h @@ -24,11 +24,17 @@ public: Q_INVOKABLE virtual void vibrate(HapticsFeedback feedbackType) override; + void setTopPanelColor(const QColor &color) override; + void setBottomPanelColor(const QColor &color) override; + private: // defined in platformhelperios.mm QString readKeyChainEntry(const QString &service, const QString &key); void writeKeyChainEntry(const QString &service, const QString &key, const QString &value); + void setTopPanelColorInternal(const QColor &color); + void setBottomPanelColorInternal(const QColor &color); + void generateSelectionFeedback(); void generateImpactFeedback(); void generateNotificationFeedback(); diff --git a/nymea-app/styles/noir/ApplicationWindow.qml b/nymea-app/styles/noir/ApplicationWindow.qml index 49098ae2..ca133af2 100644 --- a/nymea-app/styles/noir/ApplicationWindow.qml +++ b/nymea-app/styles/noir/ApplicationWindow.qml @@ -21,7 +21,7 @@ ApplicationWindow { property string appName: "nymea:app" // The header background color - property color primaryColor: Qt.darker("#50514f", 1.1) + property color primaryColor: "#494948" // Header font color diff --git a/nymea-app/ui/MainPage.qml b/nymea-app/ui/MainPage.qml index 40ffa07e..f9dc09cf 100644 --- a/nymea-app/ui/MainPage.qml +++ b/nymea-app/ui/MainPage.qml @@ -187,8 +187,6 @@ Page { SwipeView { id: swipeView anchors.fill: parent - anchors.leftMargin: (systemProductType === "ios" && Screen.width === 812) ? 25 : 0 - anchors.rightMargin: anchors.leftMargin currentIndex: root.currentViewIndex onCurrentIndexChanged: { @@ -308,9 +306,7 @@ Page { id: tabBar Material.elevation: 3 position: TabBar.Footer - implicitHeight: 70 + (app.landscape ? - ((systemProductType === "ios" && Screen.height === 375) ? -10 : -20) : - (systemProductType === "ios" && Screen.height === 812) ? 14 : 0) + implicitHeight: 70 + (app.landscape ? -20 : 0) Component { id: tabEntryComponent diff --git a/nymea-app/ui/RootItem.qml b/nymea-app/ui/RootItem.qml index c96e5340..f60d5d28 100644 --- a/nymea-app/ui/RootItem.qml +++ b/nymea-app/ui/RootItem.qml @@ -14,6 +14,11 @@ Item { Rectangle { anchors.fill: parent color: Material.background + + Component.onCompleted: { + PlatformHelper.topPanelColor = app.primaryColor + PlatformHelper.bottomPanelColor = color + } } function handleAndroidBackButton() { diff --git a/packaging/ios/Info.plist.in b/packaging/ios/Info.plist.in index ee1b7f0f..ea0dafc5 100644 --- a/packaging/ios/Info.plist.in +++ b/packaging/ios/Info.plist.in @@ -37,5 +37,7 @@ NSBluetoothPeripheralUsageDescription Nymea boxes can be connected to WiFi using a Bluetooth setup. Also, this app can connect to nymea boxes using Bluetooth only, without requiring WiFi at all. + UIViewControllerBasedStatusBarAppearance + diff --git a/packaging/ios/platformhelperios.mm b/packaging/ios/platformhelperios.mm index f7f5c919..10f1288b 100644 --- a/packaging/ios/platformhelperios.mm +++ b/packaging/ios/platformhelperios.mm @@ -99,3 +99,23 @@ void PlatformHelperIOS::generateNotificationFeedback() [generator notificationOccurred:UINotificationFeedbackTypeSuccess]; generator = nil; } + +void PlatformHelperIOS::setTopPanelColorInternal(const QColor &color) +{ + UIView *statusBar = (UIView *)[[UIApplication sharedApplication] valueForKey:@"statusBar"]; + statusBar.backgroundColor = [UIColor colorWithRed:color.redF() green:color.greenF() blue:color.blueF() alpha:color.alphaF()]; + + if (((color.red() * 299 + color.green() * 587 + color.blue() * 114) / 1000) > 123) { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES]; + } else { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES]; + } +} + +void PlatformHelperIOS::setBottomPanelColorInternal(const QColor &color) +{ + //Bottom + UIApplication *app = [UIApplication sharedApplication]; + app.windows.firstObject.backgroundColor = [UIColor colorWithRed:color.redF() green:color.greenF() blue:color.blueF() alpha:color.alphaF()]; +} +