Merge PR #240: Handle the iPhone notch better
This commit is contained in:
commit
b4598b8303
@ -29,3 +29,29 @@ void PlatformHelper::setScreenBrightness(int percent)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#define PLATFORMHELPER_H
|
#define PLATFORMHELPER_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
class PlatformHelper : public QObject
|
class PlatformHelper : public QObject
|
||||||
{
|
{
|
||||||
@ -15,6 +16,8 @@ class PlatformHelper : public QObject
|
|||||||
Q_PROPERTY(bool canControlScreen READ canControlScreen CONSTANT)
|
Q_PROPERTY(bool canControlScreen READ canControlScreen CONSTANT)
|
||||||
Q_PROPERTY(int screenTimeout READ screenTimeout WRITE setScreenTimeout NOTIFY screenTimeoutChanged)
|
Q_PROPERTY(int screenTimeout READ screenTimeout WRITE setScreenTimeout NOTIFY screenTimeoutChanged)
|
||||||
Q_PROPERTY(int screenBrightness READ screenBrightness WRITE setScreenBrightness NOTIFY screenBrightnessChanged)
|
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:
|
public:
|
||||||
enum HapticsFeedback {
|
enum HapticsFeedback {
|
||||||
@ -44,6 +47,11 @@ public:
|
|||||||
virtual int screenBrightness() const;
|
virtual int screenBrightness() const;
|
||||||
virtual void setScreenBrightness(int percent);
|
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;
|
Q_INVOKABLE virtual void vibrate(HapticsFeedback feedbackType) = 0;
|
||||||
|
|
||||||
@ -51,6 +59,12 @@ signals:
|
|||||||
void permissionsRequestFinished();
|
void permissionsRequestFinished();
|
||||||
void screenTimeoutChanged();
|
void screenTimeoutChanged();
|
||||||
void screenBrightnessChanged();
|
void screenBrightnessChanged();
|
||||||
|
void topPanelColorChanged();
|
||||||
|
void bottomPanelColorChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QColor m_topPanelColor = QColor("black");
|
||||||
|
QColor m_bottomPanelColor = QColor("black");
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PLATFORMHELPER_H
|
#endif // PLATFORMHELPER_H
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
|
|
||||||
PlatformHelperIOS::PlatformHelperIOS(QObject *parent) : PlatformHelper(parent)
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,11 +24,17 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE virtual void vibrate(HapticsFeedback feedbackType) override;
|
Q_INVOKABLE virtual void vibrate(HapticsFeedback feedbackType) override;
|
||||||
|
|
||||||
|
void setTopPanelColor(const QColor &color) override;
|
||||||
|
void setBottomPanelColor(const QColor &color) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// defined in platformhelperios.mm
|
// defined in platformhelperios.mm
|
||||||
QString readKeyChainEntry(const QString &service, const QString &key);
|
QString readKeyChainEntry(const QString &service, const QString &key);
|
||||||
void writeKeyChainEntry(const QString &service, const QString &key, const QString &value);
|
void writeKeyChainEntry(const QString &service, const QString &key, const QString &value);
|
||||||
|
|
||||||
|
void setTopPanelColorInternal(const QColor &color);
|
||||||
|
void setBottomPanelColorInternal(const QColor &color);
|
||||||
|
|
||||||
void generateSelectionFeedback();
|
void generateSelectionFeedback();
|
||||||
void generateImpactFeedback();
|
void generateImpactFeedback();
|
||||||
void generateNotificationFeedback();
|
void generateNotificationFeedback();
|
||||||
|
|||||||
@ -21,7 +21,7 @@ ApplicationWindow {
|
|||||||
property string appName: "nymea:app"
|
property string appName: "nymea:app"
|
||||||
|
|
||||||
// The header background color
|
// The header background color
|
||||||
property color primaryColor: Qt.darker("#50514f", 1.1)
|
property color primaryColor: "#494948"
|
||||||
|
|
||||||
|
|
||||||
// Header font color
|
// Header font color
|
||||||
|
|||||||
@ -187,8 +187,6 @@ Page {
|
|||||||
SwipeView {
|
SwipeView {
|
||||||
id: swipeView
|
id: swipeView
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.leftMargin: (systemProductType === "ios" && Screen.width === 812) ? 25 : 0
|
|
||||||
anchors.rightMargin: anchors.leftMargin
|
|
||||||
currentIndex: root.currentViewIndex
|
currentIndex: root.currentViewIndex
|
||||||
|
|
||||||
onCurrentIndexChanged: {
|
onCurrentIndexChanged: {
|
||||||
@ -308,9 +306,7 @@ Page {
|
|||||||
id: tabBar
|
id: tabBar
|
||||||
Material.elevation: 3
|
Material.elevation: 3
|
||||||
position: TabBar.Footer
|
position: TabBar.Footer
|
||||||
implicitHeight: 70 + (app.landscape ?
|
implicitHeight: 70 + (app.landscape ? -20 : 0)
|
||||||
((systemProductType === "ios" && Screen.height === 375) ? -10 : -20) :
|
|
||||||
(systemProductType === "ios" && Screen.height === 812) ? 14 : 0)
|
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: tabEntryComponent
|
id: tabEntryComponent
|
||||||
|
|||||||
@ -14,6 +14,11 @@ Item {
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: Material.background
|
color: Material.background
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
PlatformHelper.topPanelColor = app.primaryColor
|
||||||
|
PlatformHelper.bottomPanelColor = color
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAndroidBackButton() {
|
function handleAndroidBackButton() {
|
||||||
|
|||||||
@ -37,5 +37,7 @@
|
|||||||
</array>
|
</array>
|
||||||
<key>NSBluetoothPeripheralUsageDescription</key>
|
<key>NSBluetoothPeripheralUsageDescription</key>
|
||||||
<string>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.</string>
|
<string>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.</string>
|
||||||
|
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||||
|
<false/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@ -99,3 +99,23 @@ void PlatformHelperIOS::generateNotificationFeedback()
|
|||||||
[generator notificationOccurred:UINotificationFeedbackTypeSuccess];
|
[generator notificationOccurred:UINotificationFeedbackTypeSuccess];
|
||||||
generator = nil;
|
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()];
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user