Skip to content

Commit

Permalink
Issue #416: Add support for master thermostat.
Browse files Browse the repository at this point in the history
  • Loading branch information
mipolansk committed Sep 24, 2024
1 parent 268e9cc commit 9efdd7d
Show file tree
Hide file tree
Showing 141 changed files with 3,052 additions and 381 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.
98 changes: 93 additions & 5 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 @@ -100,7 +100,7 @@ extension SuplaCore {
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
}
6 changes: 3 additions & 3 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 Down
13 changes: 13 additions & 0 deletions SUPLA/Core/UI/Details/StandardDetailVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class StandardDetailVC<S : ViewState, E : ViewEvent, VM : StandardDetailVM<S, E>
viewControllers.append(legacyDetail(type: .ic))
case .thermostatGeneral:
viewControllers.append(thermostatGeneral())
case .thermostatList:
viewControllers.append(thermostatList())
case .schedule:
viewControllers.append(scheduleDetail())
case .thermostatHistory:
Expand Down Expand Up @@ -159,6 +161,16 @@ class StandardDetailVC<S : ViewState, E : ViewEvent, VM : StandardDetailVM<S, E>
return vc
}

private func thermostatList() -> UIViewController {
let vc = ThermostatSlavesFeature.ViewController.create(item: item)
vc.tabBarItem = UITabBarItem(
title: "List",
image: UIImage(named: "list"),
tag: DetailTabTag.List.rawValue
)
return vc
}

private func scheduleDetail() -> ScheduleDetailVC {
let vc = ScheduleDetailVC(item: item)
vc.tabBarItem = UITabBarItem(
Expand Down Expand Up @@ -315,4 +327,5 @@ fileprivate enum DetailTabTag: Int {
case Schedule = 5
case ThermostatHistory = 6
case Window = 7
case List = 8
}
Loading

0 comments on commit 9efdd7d

Please sign in to comment.