Skip to content

Commit

Permalink
Issue #387: Support garage door
Browse files Browse the repository at this point in the history
  • Loading branch information
mipolansk committed May 31, 2024
1 parent ea41205 commit a944bc6
Show file tree
Hide file tree
Showing 47 changed files with 680 additions and 38 deletions.
36 changes: 36 additions & 0 deletions SUPLA.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,11 @@
A58A630B2C071ACB00A9D02D /* VerticalBlindsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A58A630A2C071ACB00A9D02D /* VerticalBlindsVC.swift */; };
A58A630E2C071B0600A9D02D /* VerticalBlindsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A58A630D2C071B0600A9D02D /* VerticalBlindsView.swift */; };
A58A63132C09B56000A9D02D /* VerticalBlindsVMTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A58A63122C09B56000A9D02D /* VerticalBlindsVMTests.swift */; };
A58A63172C09BFAF00A9D02D /* GarageDoorVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = A58A63162C09BFAF00A9D02D /* GarageDoorVM.swift */; };
A58A63192C09C03500A9D02D /* GarageDoorState.swift in Sources */ = {isa = PBXBuildFile; fileRef = A58A63182C09C03500A9D02D /* GarageDoorState.swift */; };
A58A631B2C09C09100A9D02D /* GarageDoorVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A58A631A2C09C09100A9D02D /* GarageDoorVC.swift */; };
A58A631D2C09C0D600A9D02D /* GarageDoorColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = A58A631C2C09C0D600A9D02D /* GarageDoorColors.swift */; };
A58A631F2C09C0F200A9D02D /* GarageDoorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A58A631E2C09C0F200A9D02D /* GarageDoorView.swift */; };
A58A9BFA2A9F77BB00D28848 /* BaseCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A58A9BF92A9F77BB00D28848 /* BaseCell.swift */; };
A58A9BFE2AA0A4BD00D28848 /* UIView+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = A58A9BFD2AA0A4BD00D28848 /* UIView+Ext.swift */; };
A58A9C012AA0AD0E00D28848 /* ThermostatCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A58A9C002AA0AD0E00D28848 /* ThermostatCell.swift */; };
Expand Down Expand Up @@ -2045,6 +2050,11 @@
A58A630A2C071ACB00A9D02D /* VerticalBlindsVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VerticalBlindsVC.swift; sourceTree = "<group>"; };
A58A630D2C071B0600A9D02D /* VerticalBlindsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VerticalBlindsView.swift; sourceTree = "<group>"; };
A58A63122C09B56000A9D02D /* VerticalBlindsVMTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerticalBlindsVMTests.swift; sourceTree = "<group>"; };
A58A63162C09BFAF00A9D02D /* GarageDoorVM.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GarageDoorVM.swift; sourceTree = "<group>"; };
A58A63182C09C03500A9D02D /* GarageDoorState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GarageDoorState.swift; sourceTree = "<group>"; };
A58A631A2C09C09100A9D02D /* GarageDoorVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GarageDoorVC.swift; sourceTree = "<group>"; };
A58A631C2C09C0D600A9D02D /* GarageDoorColors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GarageDoorColors.swift; sourceTree = "<group>"; };
A58A631E2C09C0F200A9D02D /* GarageDoorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GarageDoorView.swift; sourceTree = "<group>"; };
A58A9BF92A9F77BB00D28848 /* BaseCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseCell.swift; sourceTree = "<group>"; };
A58A9BFD2AA0A4BD00D28848 /* UIView+Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Ext.swift"; sourceTree = "<group>"; };
A58A9C002AA0AD0E00D28848 /* ThermostatCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThermostatCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3100,6 +3110,7 @@
A5074BBB2BCE5CBF0081B6B1 /* UI */ = {
isa = PBXGroup;
children = (
A58A63142C09BCCE00A9D02D /* GarageDoor */,
A58A630C2C071AF400A9D02D /* VerticalBlind */,
A5AD70192C00B1C300A36318 /* Controls */,
A50E5D782BFF551B00303BAE /* Curtain */,
Expand Down Expand Up @@ -3957,6 +3968,7 @@
A55A8D6C2BA831AD00C540D4 /* WindowDetail */ = {
isa = PBXGroup;
children = (
A58A63152C09BCE600A9D02D /* GarageDoor */,
A58A63032C07154700A9D02D /* VerticalBlind */,
A50E5D712BFF540700303BAE /* Curtain */,
A50B5D342BFB6BDB00918D18 /* ProjectorScreen */,
Expand Down Expand Up @@ -4032,6 +4044,7 @@
A58A63082C07168400A9D02D /* VerticalBlindMarker.swift */,
A50B5D2C2BF49F7700918D18 /* TerraceAwningWindowState.swift */,
A50B5D372BFB6D1400918D18 /* ProjectorScreenState.swift */,
A58A63182C09C03500A9D02D /* GarageDoorState.swift */,
A50E5D762BFF548200303BAE /* CurtainWindowState.swift */,
);
path = Model;
Expand Down Expand Up @@ -4368,6 +4381,24 @@
path = VerticalBlind;
sourceTree = "<group>";
};
A58A63142C09BCCE00A9D02D /* GarageDoor */ = {
isa = PBXGroup;
children = (
A58A631C2C09C0D600A9D02D /* GarageDoorColors.swift */,
A58A631E2C09C0F200A9D02D /* GarageDoorView.swift */,
);
path = GarageDoor;
sourceTree = "<group>";
};
A58A63152C09BCE600A9D02D /* GarageDoor */ = {
isa = PBXGroup;
children = (
A58A63162C09BFAF00A9D02D /* GarageDoorVM.swift */,
A58A631A2C09C09100A9D02D /* GarageDoorVC.swift */,
);
path = GarageDoor;
sourceTree = "<group>";
};
A58A9BF82A9F77A400D28848 /* Cells */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -5967,6 +5998,7 @@
A5F29BC22A24E30100ED700A /* ChangeChannelsVisibilityUseCase.swift in Sources */,
A57C4AB72AAF4F7600D9C695 /* FilteredTapGestureDelegate.swift in Sources */,
AE7452912827F49100A3AFAD /* ProfilesNavigationCoordinator.swift in Sources */,
A58A631F2C09C0F200A9D02D /* GarageDoorView.swift in Sources */,
A55A8DAF2BAC64A700C540D4 /* SADialogTitleLabel.swift in Sources */,
0172677D234FAF78000F1CFB /* SADownloadImpulseCounterMeasurements.m in Sources */,
A56233FF2ABAC488001CB948 /* ThermostatIconNameProducer.swift in Sources */,
Expand Down Expand Up @@ -6088,6 +6120,7 @@
A5074BE42BD251590081B6B1 /* ExecuteFacadeBlindActionUseCase.swift in Sources */,
A51BE9032AA746C100718F2F /* RoundedControlButtonView.swift in Sources */,
401CA1C21BA067DB00117AF4 /* AppDelegate.m in Sources */,
A58A63192C09C03500A9D02D /* GarageDoorState.swift in Sources */,
A5E490632A4019E6006801FE /* UpdateGroupIconRelationsUseCase.swift in Sources */,
A5F29BAE2A24BA5800ED700A /* LegacyWrapper.swift in Sources */,
A5F29B9A2A20C26900ED700A /* BaseTableViewController.swift in Sources */,
Expand Down Expand Up @@ -6151,6 +6184,7 @@
A5F29B9D2A20D2F300ED700A /* CreateProfileGroupsListUseCase.swift in Sources */,
A566398D2ABADFD700BA51D7 /* LoadingScrimView.swift in Sources */,
40B9ED3A1FAC79FC00403B1A /* SUPLA.xcdatamodeld in Sources */,
A58A63172C09BFAF00A9D02D /* GarageDoorVM.swift in Sources */,
40B610CC20C7E263002B762A /* SAUIChannelStatus.m in Sources */,
AECB1BE727109EA3001A9714 /* CheckBox.swift in Sources */,
A5A14A3D2B6134C4004B1598 /* InsertChannelConfigUseCase.swift in Sources */,
Expand Down Expand Up @@ -6229,6 +6263,7 @@
A5B3A4B52BB558B70001D006 /* RoofWindowView.swift in Sources */,
A5AE7A7F2A3998260097FA8B /* NewGestureInfoView.swift in Sources */,
A57777CD29E6907C004513E6 /* RuntimeConfig.swift in Sources */,
A58A631B2C09C09100A9D02D /* GarageDoorVC.swift in Sources */,
A57668DD2AE995590025509D /* GeneralError.swift in Sources */,
A55A8D882BAAFFE700C540D4 /* ChannelIssueItem.swift in Sources */,
A5074BB52BCCFD2B0081B6B1 /* IconCell.swift in Sources */,
Expand Down Expand Up @@ -6313,6 +6348,7 @@
A58A63052C0715E500A9D02D /* VerticalBlindsVM.swift in Sources */,
40A6757F1BA1A5B6004A51C4 /* SuplaApp.m in Sources */,
A50B5D502BFCBDFB00918D18 /* OpenedClosedGroupActivePercentageProvider.swift in Sources */,
A58A631D2C09C0D600A9D02D /* GarageDoorColors.swift in Sources */,
018CFD2023281A5900888CB7 /* SAElectricityMeterExtendedValue.m in Sources */,
A5FE67632A65D56300147D1F /* UpdateServerHostNameUseCase.swift in Sources */,
A5074BC52BCE66070081B6B1 /* DefaultWindowDimens.swift in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions SUPLA/ChannelCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ -(void) updateCellView {
case SUPLA_CHANNELFNC_PROJECTOR_SCREEN:
case SUPLA_CHANNELFNC_CURTAIN:
case SUPLA_CHANNELFNC_VERTICAL_BLIND:
case SUPLA_CHANNELFNC_ROLLER_GARAGE_DOOR:
self.left_OnlineStatus.hidden = YES;
self.right_OnlineStatus.hidden = NO;
break;
Expand Down Expand Up @@ -394,6 +395,7 @@ -(void) updateCellView {
case SUPLA_CHANNELFNC_PROJECTOR_SCREEN:
case SUPLA_CHANNELFNC_CURTAIN:
case SUPLA_CHANNELFNC_VERTICAL_BLIND:
case SUPLA_CHANNELFNC_ROLLER_GARAGE_DOOR:
br = [MGSwipeButton buttonWithTitle:NSLocalizedString(@"Open", nil) icon:nil backgroundColor:[UIColor blackColor]];
bl = [MGSwipeButton buttonWithTitle:NSLocalizedString(@"Close", nil) icon:nil backgroundColor:[UIColor blackColor]];
break;
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 @@ -97,6 +97,8 @@ class StandardDetailVC<S : ViewState, E : ViewEvent, VM : StandardDetailVM<S, E>
viewControllers.append(curtainDetail())
case .verticalBlind:
viewControllers.append(verticalBlindDetail())
case .garageDoor:
viewControllers.append(garageDoorDetail())
}
}

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

private func garageDoorDetail() -> GarageDoorVC {
let vc = GarageDoorVC(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/BaseTableViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class BaseTableViewModel<S: ViewState, E: ViewEvent>: BaseViewModel<S, E> {
SUPLA_CHANNELFNC_TERRACE_AWNING,
SUPLA_CHANNELFNC_PROJECTOR_SCREEN,
SUPLA_CHANNELFNC_CURTAIN,
SUPLA_CHANNELFNC_VERTICAL_BLIND:
SUPLA_CHANNELFNC_VERTICAL_BLIND,
SUPLA_CHANNELFNC_ROLLER_GARAGE_DOOR:
return true
case SUPLA_CHANNELFNC_LIGHTSWITCH,
SUPLA_CHANNELFNC_POWERSWITCH,
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 @@ -197,7 +197,8 @@ class ChannelBaseTableViewController<S: ViewState, E: ViewEvent, VM: BaseTableVi
SUPLA_CHANNELFNC_TERRACE_AWNING,
SUPLA_CHANNELFNC_PROJECTOR_SCREEN,
SUPLA_CHANNELFNC_CURTAIN,
SUPLA_CHANNELFNC_VERTICAL_BLIND:
SUPLA_CHANNELFNC_VERTICAL_BLIND,
SUPLA_CHANNELFNC_ROLLER_GARAGE_DOOR:
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 @@ -107,7 +107,8 @@ final class IconCell: BaseCell<ChannelWithChildren> {
SUPLA_CHANNELFNC_TERRACE_AWNING,
SUPLA_CHANNELFNC_PROJECTOR_SCREEN,
SUPLA_CHANNELFNC_CURTAIN,
SUPLA_CHANNELFNC_VERTICAL_BLIND: true
SUPLA_CHANNELFNC_VERTICAL_BLIND,
SUPLA_CHANNELFNC_ROLLER_GARAGE_DOOR: true
default: false
}
}
Expand All @@ -120,7 +121,8 @@ final class IconCell: BaseCell<ChannelWithChildren> {
SUPLA_CHANNELFNC_TERRACE_AWNING,
SUPLA_CHANNELFNC_PROJECTOR_SCREEN,
SUPLA_CHANNELFNC_CURTAIN,
SUPLA_CHANNELFNC_VERTICAL_BLIND: true
SUPLA_CHANNELFNC_VERTICAL_BLIND,
SUPLA_CHANNELFNC_ROLLER_GARAGE_DOOR: 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 GarageDoorState: 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
@@ -0,0 +1,48 @@
/*
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 GarageDoorColors {
let building: UIColor
let shadow: UIColor
let slatBackground: UIColor
let slatBorder: UIColor
let markerBorder: UIColor
let markerBackground: UIColor

static func standard(_ traitCollection: UITraitCollection) -> GarageDoorColors {
GarageDoorColors(
building: .rollerShutterWindow.resolvedColor(with: traitCollection),
shadow: .black,
slatBackground: .rollerShutterSlatBackground.resolvedColor(with: traitCollection),
slatBorder: .rollerShutterSlatBorder.resolvedColor(with: traitCollection),
markerBorder: .black,
markerBackground: .primaryVariant
)
}

static func offline(_ traitCollection: UITraitCollection) -> GarageDoorColors {
GarageDoorColors(
building: .surface.resolvedColor(with: traitCollection),
shadow: .black,
slatBackground: .rollerShutterDisabledSlatBackground.resolvedColor(with: traitCollection),
slatBorder: .rollerShutterDisabledSlatBorder.resolvedColor(with: traitCollection),
markerBorder: .black,
markerBackground: UIColor(argb: 0xffb3f1cb)
)
}
}
Loading

0 comments on commit a944bc6

Please sign in to comment.