Skip to content

Commit

Permalink
Merge pull request #420 from SUPLA/develop
Browse files Browse the repository at this point in the history
v24.09.01
  • Loading branch information
przemyslawzygmunt authored Sep 27, 2024
2 parents 103e491 + 843c959 commit 388f664
Show file tree
Hide file tree
Showing 152 changed files with 3,328 additions and 502 deletions.
303 changes: 270 additions & 33 deletions LibSuplaClient.xcframework/ios-arm64_armv7_armv7s/Headers/proto.h

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,13 @@ _supla_int_t srpc_evtool_value_get(TSuplaChannelExtendedValue *ev,
unsigned short index,
TSuplaChannelExtendedValue *dest);

_supla_int_t srpc_evtool_v2_extended2emextended(
_supla_int_t srpc_evtool_v3_extended2emextended(
const TSuplaChannelExtendedValue *ev,
TElectricityMeter_ExtendedValue_V2 *em_ev);
TElectricityMeter_ExtendedValue_V3 *em_ev);

_supla_int_t srpc_evtool_extended2emextended(
const TSuplaChannelExtendedValue *ev,
TElectricityMeter_ExtendedValue_V3 *em_ev);

_supla_int_t srpc_evtool_v1_extended2icextended(
const TSuplaChannelExtendedValue *ev,
Expand Down
Binary file not shown.
303 changes: 270 additions & 33 deletions LibSuplaClient.xcframework/ios-arm64_x86_64-simulator/Headers/proto.h

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,13 @@ _supla_int_t srpc_evtool_value_get(TSuplaChannelExtendedValue *ev,
unsigned short index,
TSuplaChannelExtendedValue *dest);

_supla_int_t srpc_evtool_v2_extended2emextended(
_supla_int_t srpc_evtool_v3_extended2emextended(
const TSuplaChannelExtendedValue *ev,
TElectricityMeter_ExtendedValue_V2 *em_ev);
TElectricityMeter_ExtendedValue_V3 *em_ev);

_supla_int_t srpc_evtool_extended2emextended(
const TSuplaChannelExtendedValue *ev,
TElectricityMeter_ExtendedValue_V3 *em_ev);

_supla_int_t srpc_evtool_v1_extended2icextended(
const TSuplaChannelExtendedValue *ev,
Expand Down
Binary file not shown.
106 changes: 97 additions & 9 deletions SUPLA.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions SUPLA/ChannelCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ -(void) updateCellView {
case SUPLA_CHANNELFNC_OPENINGSENSOR_WINDOW:
case SUPLA_CHANNELFNC_MAILSENSOR:
case SUPLA_CHANNELFNC_THERMOMETER:
case SUPLA_CHANNELFNC_PUMPSWITCH:
case SUPLA_CHANNELFNC_HEATORCOLDSOURCESWITCH:
self.left_OnlineStatus.hidden = NO;
self.right_OnlineStatus.hidden = NO;
self.right_OnlineStatus.shapeType = stRing;
Expand Down
4 changes: 3 additions & 1 deletion SUPLA/Core/DI/DiContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ extension DiContainer {
register(CreateProfileChannelsListUseCase.self, CreateProfileChannelsListUseCaseImpl())
register(ReadChannelByRemoteIdUseCase.self, ReadChannelByRemoteIdUseCaseImpl())
register(ReadChannelWithChildrenUseCase.self, ReadChannelWithChildrenUseCaseImpl())
register(ReadChannelWithChildrenTreeUseCase.self, ReadChannelWithChildrenTreeUseCaseImpl())
register(CreateTemperaturesListUseCase.self, CreateTemperaturesListUseCaseImpl())
register(DownloadChannelMeasurementsUseCase.self, DownloadChannelMeasurementsUseCaseImpl())
register(DownloadTemperatureLogUseCase.self,
Expand Down Expand Up @@ -176,7 +177,8 @@ extension DiContainer {
register(DisconnectUseCase.self, DisconnectUseCaseImpl())
register(ReconnectUseCase.self, ReconnectUseCaseImpl())
// Usecases - Detail
register(ProvideDetailTypeUseCase.self, ProvideDetailTypeUseCaseImpl())
register(ProvideChannelDetailTypeUseCase.self, ProvideChannelDetailTypeUseCaseImpl())
register(ProvideGroupDetailTypeUseCase.self, ProvideGroupDetailTypeUseCaseImpl())
// Usecases - Group
register(SwapGroupPositionsUseCase.self, SwapGroupPositionsUseCaseImpl())
register(CreateProfileGroupsListUseCase.self, CreateProfileGroupsListUseCaseImpl())
Expand Down
27 changes: 27 additions & 0 deletions SUPLA/Core/Extensions/Bool+Ext.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Copyright (C) AC SOFTWARE SP. Z O.O.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

extension Bool {
func ifTrue<T>(_ valueProvider: () -> T) -> T? {
if (self) {
return valueProvider()
}

return nil
}
}
4 changes: 4 additions & 0 deletions SUPLA/Core/Extensions/Float+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ extension Float {
func toSuplaTemperature() -> Int16 {
return Int16(self * 100)
}

func also<T>(_ transformation: (Float) -> T) -> T {
return transformation(self)
}
}

extension CGFloat: ScopeFunctions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,23 @@ extension SuplaCore {

NotificationCenter.default.removeObserver(self, name: UIApplication.willEnterForegroundNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: UIApplication.didEnterBackgroundNotification, object: nil)
NotificationCenter.default.removeObserver(self)
}

override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
onViewDisappeared()
}

func observeNotification(name: NSNotification.Name?, selector: Selector) {
NotificationCenter.default.addObserver(self, selector: selector, name: name, object: nil)
}

private func setupConstraints() {
NSLayoutConstraint.activate([
hostingController.view.topAnchor.constraint(equalTo: view.topAnchor),
hostingController.view.rightAnchor.constraint(equalTo: view.rightAnchor),
hostingController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
hostingController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 8),
hostingController.view.leftAnchor.constraint(equalTo: view.leftAnchor)
])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@
import SwiftUI

struct BackgroundStack<Content: View>: View {
var alignment: Alignment = .center
var color: Color = .Supla.background
var content: () -> Content

init(color: Color = .Supla.background, @ViewBuilder content: @escaping () -> Content) {
init(
alignment: Alignment = .center,
color: Color = .Supla.background,
@ViewBuilder content: @escaping () -> Content
) {
self.color = color
self.content = content
}

var body: some View {
ZStack {
ZStack(alignment: alignment) {
if #available(iOS 14.0, *) {
Color.Supla.background.ignoresSafeArea()
} else {
Expand Down
45 changes: 45 additions & 0 deletions SUPLA/Core/SwiftUiComponents/LazyList.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright (C) AC SOFTWARE SP. Z O.O.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

import SwiftUI

struct LazyList<Content: View, Item: Identifiable>: View {
var items: [Item]
var content: (Item) -> Content

var body: some View {
ScrollView(.vertical) {
if #available(iOS 14.0, *) {
LazyVStack(spacing: 1) {
ForEach(items) { item in
content(item)
.listRowInsets(EdgeInsets())
.listRowSeparatorInvisible()
}
}
} else {
SwiftUI.List(items) { item in
content(item)
.padding([.bottom], 1)
.listRowInsets(EdgeInsets())
.listRowSeparatorInvisible()
}.listStyle(.plain)
}
}
}
}
56 changes: 56 additions & 0 deletions SUPLA/Core/SwiftUiComponents/Text.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,60 @@ struct Text {
}
}
}

struct CellValue: SuplaText {
@Environment(\.scaleFactor) var scaleFactor: CGFloat

var text: String

var body: some View {
if #available(iOS 15.0, *) {
SwiftUI.Text(text)
.font(Font.Supla.cellValue(scaleFactor, limit: .lower(1)))
.foregroundStyle(Color.Supla.onBackground)
} else {
SwiftUI.Text(text)
.font(Font.Supla.cellValue(scaleFactor, limit: .lower(1)))
.foregroundColor(Color.Supla.onBackground)
}
}
}

struct CellCaption: SuplaText {
@Environment(\.scaleFactor) var scaleFactor: CGFloat

var text: String

var body: some View {
if #available(iOS 15.0, *) {
SwiftUI.Text(text)
.lineLimit(1)
.font(Font.Supla.cellCaption(scaleFactor, limit: .lower(1)))
.foregroundStyle(Color.Supla.onBackground)
} else {
SwiftUI.Text(text)
.lineLimit(1)
.font(Font.Supla.cellCaption(scaleFactor, limit: .lower(1)))
.foregroundColor(Color.Supla.onBackground)
}
}
}

struct CellSubValue: SuplaText {
@Environment(\.scaleFactor) var scaleFactor: CGFloat

var text: String

var body: some View {
if #available(iOS 15.0, *) {
SwiftUI.Text(text)
.font(Font.Supla.cellSubValue(scaleFactor, limit: .lower(1)))
.foregroundStyle(Color.Supla.onBackground)
} else {
SwiftUI.Text(text)
.font(Font.Supla.cellSubValue(scaleFactor, limit: .lower(1)))
.foregroundColor(Color.Supla.onBackground)
}
}
}
}
24 changes: 24 additions & 0 deletions SUPLA/Core/SwiftUiComponents/UiSettings.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
/*
Copyright (C) AC SOFTWARE SP. Z O.O.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

import SwiftUI

final class UiSettings: ObservableObject {
@Published var scale: CGFloat = 1.0
}
59 changes: 59 additions & 0 deletions SUPLA/Core/SwiftUiComponents/View+ScaleFactor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Copyright (C) AC SOFTWARE SP. Z O.O.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

import SwiftUI

extension EnvironmentValues {
@Entry var scaleFactor: CGFloat = 1.0
}

extension View {
func scale(
_ scaleFactor: CGFloat,
_ value: CGFloat,
limit: CellScalingLimit = .none
) -> CGFloat {
SUPLA.scale(scaleFactor, value, limit: limit)
}
}

extension CGFloat {
func scale(
_ value: CGFloat,
limit: CellScalingLimit = .none
) -> CGFloat {
return SUPLA.scale(self, value, limit: limit)
}
}

private func scale(
_ scaleFactor: CGFloat,
_ value: CGFloat,
limit: CellScalingLimit = .none
) -> CGFloat {
var scale = scaleFactor
switch (limit) {
case .lower(let val):
if (scaleFactor < val) { scale = val }
case .upper(let val):
if (scaleFactor > val) { scale = val }
default: break
}

return value * scale
}
18 changes: 10 additions & 8 deletions SUPLA/Core/UI/Buttons/BaseControlButtonView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ class BaseControlButtonView: UIView {
didSet {
switch (icon) {
case .suplaIcon(let icon):
iconView.image = icon?.withRenderingMode(.alwaysTemplate)
iconView.image = .init(named: icon)?.withRenderingMode(.alwaysTemplate)
iconView.tintColor = iconColor
case .userIcon(let icon):
iconView.image = icon
default:
iconView.image = icon?.icon
iconView.image = icon?.uiImage
}

iconView.isHidden = icon?.icon == nil
iconView.isHidden = icon == nil
setupLayout()
}
}
Expand All @@ -82,10 +82,12 @@ class BaseControlButtonView: UIView {

var active: Bool = false {
didSet {
layer.shadowColor = active ? type.pressedColor.cgColor : UIColor.black.cgColor
layer.borderColor = active ? type.pressedColor.cgColor : UIColor.disabled.cgColor
textView.textColor = active ? type.textColor : type.inactiveColor
iconView.tintColor = active ? type.textColor : iconColor
traitCollection.performAsCurrent {
layer.shadowColor = active ? type.pressedColor.cgColor : UIColor.black.cgColor
layer.borderColor = active ? type.pressedColor.cgColor : UIColor.disabled.cgColor
textView.textColor = active ? type.textColor : type.inactiveColor
iconView.tintColor = active ? type.textColor : iconColor
}
innerShadowView.isHidden = !active

setNeedsLayout()
Expand Down Expand Up @@ -255,7 +257,7 @@ class BaseControlButtonView: UIView {
switch (self) {
case .positive: return .green
case .negative: return .negativeBorder
case .neutral: return .black
case .neutral: return .onBackground
}
}

Expand Down
Loading

0 comments on commit 388f664

Please sign in to comment.