Skip to content

Commit

Permalink
Issue #375: Support terrace awning
Browse files Browse the repository at this point in the history
  • Loading branch information
mipolansk committed May 15, 2024
1 parent 8165e8f commit e0586f3
Show file tree
Hide file tree
Showing 32 changed files with 824 additions and 23 deletions.
44 changes: 44 additions & 0 deletions SUPLA.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,11 @@
A50B5D222BEE167300918D18 /* DeleteChannelMeasurementsUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50B5D212BEE167300918D18 /* DeleteChannelMeasurementsUseCase.swift */; };
A50B5D242BEE4CE600918D18 /* UIViewController+Toast.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50B5D232BEE4CE600918D18 /* UIViewController+Toast.swift */; };
A50B5D262BEE59B700918D18 /* DeleteChannelMeasurementsUseCaseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50B5D252BEE59B700918D18 /* DeleteChannelMeasurementsUseCaseTests.swift */; };
A50B5D292BF49F2700918D18 /* TerraceAwningVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50B5D282BF49F2700918D18 /* TerraceAwningVM.swift */; };
A50B5D2B2BF49F3000918D18 /* TerraceAwningVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50B5D2A2BF49F3000918D18 /* TerraceAwningVC.swift */; };
A50B5D2D2BF49F7700918D18 /* TerraceAwningWindowState.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50B5D2C2BF49F7700918D18 /* TerraceAwningWindowState.swift */; };
A50B5D302BF4A10200918D18 /* TerraceAwningView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50B5D2F2BF4A10200918D18 /* TerraceAwningView.swift */; };
A50B5D332BF54FF300918D18 /* TerraceAwningVMTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50B5D322BF54FF300918D18 /* TerraceAwningVMTests.swift */; };
A50CD3D12A4D78610012DD9B /* libc++abi.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = A50CD3D02A4D78610012DD9B /* libc++abi.tbd */; };
A50CD3D32A4D82ED0012DD9B /* DateProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50CD3D22A4D82ED0012DD9B /* DateProvider.swift */; };
A50CD3D62A4D99E60012DD9B /* UpdateTokenTaskTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50CD3D52A4D99E60012DD9B /* UpdateTokenTaskTests.swift */; };
Expand Down Expand Up @@ -1626,6 +1631,11 @@
A50B5D212BEE167300918D18 /* DeleteChannelMeasurementsUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeleteChannelMeasurementsUseCase.swift; sourceTree = "<group>"; };
A50B5D232BEE4CE600918D18 /* UIViewController+Toast.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Toast.swift"; sourceTree = "<group>"; };
A50B5D252BEE59B700918D18 /* DeleteChannelMeasurementsUseCaseTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeleteChannelMeasurementsUseCaseTests.swift; sourceTree = "<group>"; };
A50B5D282BF49F2700918D18 /* TerraceAwningVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerraceAwningVM.swift; sourceTree = "<group>"; };
A50B5D2A2BF49F3000918D18 /* TerraceAwningVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerraceAwningVC.swift; sourceTree = "<group>"; };
A50B5D2C2BF49F7700918D18 /* TerraceAwningWindowState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerraceAwningWindowState.swift; sourceTree = "<group>"; };
A50B5D2F2BF4A10200918D18 /* TerraceAwningView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerraceAwningView.swift; sourceTree = "<group>"; };
A50B5D322BF54FF300918D18 /* TerraceAwningVMTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerraceAwningVMTests.swift; sourceTree = "<group>"; };
A50CD3D02A4D78610012DD9B /* libc++abi.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++abi.tbd"; path = "usr/lib/libc++abi.tbd"; sourceTree = SDKROOT; };
A50CD3D22A4D82ED0012DD9B /* DateProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateProvider.swift; sourceTree = "<group>"; };
A50CD3D52A4D99E60012DD9B /* UpdateTokenTaskTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateTokenTaskTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3010,6 +3020,7 @@
A5074BBB2BCE5CBF0081B6B1 /* UI */ = {
isa = PBXGroup;
children = (
A50B5D2E2BF4A02B00918D18 /* TerraceAwning */,
A5074BCA2BCE6F2C0081B6B1 /* FacadeBlinds */,
A5074BC32BCE64A30081B6B1 /* WindowView */,
A5B3A4B72BB57B4D0001D006 /* RoofWindow */,
Expand Down Expand Up @@ -3121,6 +3132,7 @@
A50B5D102BECC58800918D18 /* WindowDetail */ = {
isa = PBXGroup;
children = (
A50B5D312BF54FE600918D18 /* TerraceAwning */,
A50B5D1E2BECE8B100918D18 /* FacadeBlinds */,
A50B5D1B2BECDAA100918D18 /* RollerShutter */,
A50B5D112BECC59100918D18 /* RoofWindow */,
Expand Down Expand Up @@ -3177,6 +3189,31 @@
path = FacadeBlinds;
sourceTree = "<group>";
};
A50B5D272BF49F0D00918D18 /* TerraceAwning */ = {
isa = PBXGroup;
children = (
A50B5D282BF49F2700918D18 /* TerraceAwningVM.swift */,
A50B5D2A2BF49F3000918D18 /* TerraceAwningVC.swift */,
);
path = TerraceAwning;
sourceTree = "<group>";
};
A50B5D2E2BF4A02B00918D18 /* TerraceAwning */ = {
isa = PBXGroup;
children = (
A50B5D2F2BF4A10200918D18 /* TerraceAwningView.swift */,
);
path = TerraceAwning;
sourceTree = "<group>";
};
A50B5D312BF54FE600918D18 /* TerraceAwning */ = {
isa = PBXGroup;
children = (
A50B5D322BF54FF300918D18 /* TerraceAwningVMTests.swift */,
);
path = TerraceAwning;
sourceTree = "<group>";
};
A50CD3D42A4D99CF0012DD9B /* UpdateToken */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -3780,6 +3817,7 @@
A55A8D6C2BA831AD00C540D4 /* WindowDetail */ = {
isa = PBXGroup;
children = (
A50B5D272BF49F0D00918D18 /* TerraceAwning */,
A5074BB62BCE58B30081B6B1 /* Base */,
A5074BCD2BCE72110081B6B1 /* FacadeBlinds */,
A5074BBE2BCE609D0081B6B1 /* RoofWindow */,
Expand Down Expand Up @@ -3847,6 +3885,7 @@
A50B5D052BEA4DA700918D18 /* RollerShutterWindowState.swift */,
A50B5D072BEA4E2A00918D18 /* FacadeBlindWindowState.swift */,
A50B5D092BEA4EC700918D18 /* FacadeBlindMarker.swift */,
A50B5D2C2BF49F7700918D18 /* TerraceAwningWindowState.swift */,
);
path = Model;
sourceTree = "<group>";
Expand Down Expand Up @@ -5665,6 +5704,7 @@
A5F29BB22A24C52600ED700A /* UpdateChannelUseCase.swift in Sources */,
A5074BE22BCFE6230081B6B1 /* SuplaTiltControlType.swift in Sources */,
A57C4AB52AAF458F00D9C695 /* SuplaScheduleProgram.swift in Sources */,
A50B5D292BF49F2700918D18 /* TerraceAwningVM.swift in Sources */,
A5F8361F2A2E008C00E5CA71 /* AuthProfileItemInitialMigrationPolicy.swift in Sources */,
40DE1A361BCD1B55004CF43B /* AboutVC.m in Sources */,
A5E4905A2A3FA151006801FE /* GetAllIconsToDownloadUseCase.swift in Sources */,
Expand Down Expand Up @@ -5981,6 +6021,7 @@
A57668E52AEA67E00025509D /* LoadChannelWithChildrenMeasurementsDateRangeUseCase.swift in Sources */,
A50B5D082BEA4E2A00918D18 /* FacadeBlindWindowState.swift in Sources */,
A5A14A422B614242004B1598 /* SuplaChannelGeneralPurposeMeasurementConfig.swift in Sources */,
A50B5D302BF4A10200918D18 /* TerraceAwningView.swift in Sources */,
018CFD2323281ADB00888CB7 /* SAThermostatExtendedValue.m in Sources */,
40BBA35D20AC6E220054CD20 /* SAChannelGroupRelation+CoreDataProperties.m in Sources */,
A5AE7A872A3AD6A10097FA8B /* ChannelHeightCell.swift in Sources */,
Expand Down Expand Up @@ -6125,6 +6166,7 @@
A57669012AEFD4420025509D /* UsetStateHolder.swift in Sources */,
A58A9BFE2AA0A4BD00D28848 /* UIView+Ext.swift in Sources */,
A5477DC92AA5E6EE00220B4A /* ChannelWithChildren.swift in Sources */,
A50B5D2B2BF49F3000918D18 /* TerraceAwningVC.swift in Sources */,
A55A8D772BA84DCE00C540D4 /* RollerShutterVC.swift in Sources */,
A530EE2C2A57E15000F8DAEE /* HeatpolHomeplusIconNameProducer.swift in Sources */,
A54149302B63059200B44BD6 /* GpmHistoryDetailVC.swift in Sources */,
Expand All @@ -6135,6 +6177,7 @@
0111E924263F374800302356 /* UIColor+SUPLA.m in Sources */,
A57785BD29E7FAD0001C631E /* SuplaClientProvider.swift in Sources */,
01D5E0C822DB7FAF00FBE1DC /* SAChartMarkerView.swift in Sources */,
A50B5D2D2BF49F7700918D18 /* TerraceAwningWindowState.swift in Sources */,
A56F15F52A2E6E3C00C2E21B /* Migration12to13ModelMapping.xcmappingmodel in Sources */,
01C1719022C7F3A2005983E1 /* SAIncrementalMeasurementItem+CoreDataProperties.m in Sources */,
A5A1C0A829F2AAFA0083818D /* VibrationService.swift in Sources */,
Expand Down Expand Up @@ -6223,6 +6266,7 @@
A55A8DC72BB3139E00C540D4 /* ExecuteRollerShutterActionUseCaseTests.swift in Sources */,
A54A065D2AF4E58F00C03DBC /* CStructsConstructor.m in Sources */,
A573B0AE2A6022C1001E19D0 /* GetDefaultIconNameUseCaseMock.swift in Sources */,
A50B5D332BF54FF300918D18 /* TerraceAwningVMTests.swift in Sources */,
A59AB8AE2A3071A300D91F1F /* GroupListVMTests.swift in Sources */,
A5E40B5D2B86075500DB6ABE /* ValueProviderMocks.swift in Sources */,
A54A06752AF8D61000C03DBC /* LinkedListTests.swift in Sources */,
Expand Down
18 changes: 18 additions & 0 deletions SUPLA/Core/Extensions/UIView+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,22 @@ extension UIView {
NSLayoutConstraint.deactivate(self.constraints)
self.removeConstraints(self.constraints)
}

func drawPath(_ context: CGContext, fillColor: UIColor? = nil, strokeColor: UIColor? = nil, withShadow: Bool = false, _ pathProducer: () -> CGPath) {
context.beginPath()
context.addPath(pathProducer())
if (withShadow) {
context.setShadow(offset: ShadowValues.offset, blur: ShadowValues.blur)
} else {
context.setShadow(offset: .zero, blur: 0)
}
if let color = fillColor {
context.setFillColor(color.cgColor)
context.drawPath(using: .fill)
}
if let color = strokeColor {
context.setStrokeColor(color.cgColor)
context.drawPath(using: .stroke)
}
}
}
13 changes: 13 additions & 0 deletions SUPLA/Core/UI/Details/StandardDetailVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class StandardDetailVC<S : ViewState, E : ViewEvent, VM : StandardDetailVM<S, E>
viewControllers.append(roofWindowDetail())
case .facadeBlind:
viewControllers.append(facadeBlindDetail())
case .terraceAwning:
viewControllers.append(terraceAwningDetail())
}
}

Expand Down Expand Up @@ -237,6 +239,17 @@ class StandardDetailVC<S : ViewState, E : ViewEvent, VM : StandardDetailVM<S, E>
)
return vc
}

private func terraceAwningDetail() -> TerraceAwningVC {
let vc = TerraceAwningVC(itemBundle: item)
vc.navigationCoordinator = navigationCoordinator
vc.tabBarItem = UITabBarItem(
title: settings.showBottomLabels ? Strings.StandardDetail.tabGeneral : nil,
image: .iconGeneral,
tag: DetailTabTag.Window.rawValue
)
return vc
}
}

protocol NavigationItemProvider: AnyObject {
Expand Down
3 changes: 2 additions & 1 deletion SUPLA/Core/UI/TableView/ChannelBaseTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ class ChannelBaseTableViewController<S: ViewState, E: ViewEvent, VM: BaseTableVi
return cellIdForHvacThermostat
case SUPLA_CHANNELFNC_CONTROLLINGTHEROOFWINDOW,
SUPLA_CHANNELFNC_CONTROLLINGTHEFACADEBLIND,
SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER:
SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER,
SUPLA_CHANNELFNC_TERRACE_AWNING:
return cellIdForIcon
default:
return cellIdForChannel
Expand Down
6 changes: 4 additions & 2 deletions SUPLA/Features/ChannelList/Cells/IconCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ final class IconCell: BaseCell<ChannelWithChildren> {
switch (data?.channel.func) {
case SUPLA_CHANNELFNC_CONTROLLINGTHEROOFWINDOW,
SUPLA_CHANNELFNC_CONTROLLINGTHEFACADEBLIND,
SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER: true
SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER,
SUPLA_CHANNELFNC_TERRACE_AWNING: true
default: false
}
}
Expand All @@ -112,7 +113,8 @@ final class IconCell: BaseCell<ChannelWithChildren> {
switch (data?.channel.func) {
case SUPLA_CHANNELFNC_CONTROLLINGTHEROOFWINDOW,
SUPLA_CHANNELFNC_CONTROLLINGTHEFACADEBLIND,
SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER: true
SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER,
SUPLA_CHANNELFNC_TERRACE_AWNING: true
default: false
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
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.
*/

struct TerraceAwningWindowState: WindowState, Equatable, Changeable {
/**
* The blind roller position in percentage
* 0 - open
* 100 - closed
*/
var position: WindowGroupedValue

var positionTextFormat: WindowGroupedValueFormat = .percentage

/**
* Used for groups - shows positions of single roller shutter
*/
var markers: [CGFloat] = []
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,24 +178,6 @@ final class RoofWindowView: BaseWindowView<RoofWindowState> {
}
}

private func drawPath(_ context: CGContext, fillColor: UIColor? = nil, strokeColor: UIColor? = nil, withShadow: Bool = false, _ pathProducer: () -> CGPath) {
context.beginPath()
context.addPath(pathProducer())
if (withShadow) {
context.setShadow(offset: ShadowValues.offset, blur: ShadowValues.blur)
} else {
context.setShadow(offset: .zero, blur: 0)
}
if let color = fillColor {
context.setFillColor(color.cgColor)
context.drawPath(using: .fill)
}
if let color = strokeColor {
context.setStrokeColor(color.cgColor)
context.drawPath(using: .stroke)
}
}

private func dynamicTransformation(_ offset: CGFloat? = nil) -> CGAffineTransform {
let xOffset = offset == nil ? openedOffset : offset!
let firstTransformation = CATransform3DMakeRotation(degreesToRadians(windowRotationY), 0, 1, 0)
Expand Down
Loading

0 comments on commit e0586f3

Please sign in to comment.