Skip to content

Commit

Permalink
Issue #380: Support curtain
Browse files Browse the repository at this point in the history
  • Loading branch information
mipolansk committed May 27, 2024
1 parent ad389c9 commit fbb1502
Show file tree
Hide file tree
Showing 85 changed files with 2,150 additions and 587 deletions.
106 changes: 99 additions & 7 deletions SUPLA.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions SUPLA/ChannelCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ -(void) updateCellView {
case SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER:
case SUPLA_CHANNELFNC_CONTROLLINGTHEROOFWINDOW:
case SUPLA_CHANNELFNC_CONTROLLINGTHEFACADEBLIND:
case SUPLA_CHANNELFNC_TERRACE_AWNING:
case SUPLA_CHANNELFNC_PROJECTOR_SCREEN:
case SUPLA_CHANNELFNC_CURTAIN:
self.left_OnlineStatus.hidden = YES;
self.right_OnlineStatus.hidden = NO;
break;
Expand Down Expand Up @@ -386,6 +389,9 @@ -(void) updateCellView {
case SUPLA_CHANNELFNC_VALVE_OPENCLOSE:
case SUPLA_CHANNELFNC_CONTROLLINGTHEROOFWINDOW:
case SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER:
case SUPLA_CHANNELFNC_TERRACE_AWNING:
case SUPLA_CHANNELFNC_PROJECTOR_SCREEN:
case SUPLA_CHANNELFNC_CURTAIN:
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
27 changes: 27 additions & 0 deletions SUPLA/Core/Extensions/CGRect+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 CGRect {
func narrowToLeft(by: CGFloat) -> CGRect {
return CGRect(origin: origin, size: CGSize(width: width - by, height: height))
}

func narrowToRight(by: CGFloat) -> CGRect {
return CGRect(x: minX + by, y: minY, width: width - by, height: height)
}
}
6 changes: 3 additions & 3 deletions SUPLA/Core/Extensions/Float+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ extension CGFloat: ScopeFunctions {
get { Float(self) }
}

func toPercentage(max: CGFloat = 1) -> CGFloat {
func limit(min: CGFloat = 0, max: CGFloat = 1) -> CGFloat {
if (self > max) {
return max
} else if (self < 0) {
return 0
} else if (self < min) {
return min
} else {
return self
}
Expand Down
22 changes: 22 additions & 0 deletions SUPLA/Core/Extensions/UIView+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,26 @@ extension UIView {
context.drawPath(using: .stroke)
}
}

func drawGlass(_ context: CGContext, _ glassRect: CGRect, _ colors: [CGColor]) {
context.saveGState()

context.beginPath()
context.addRect(glassRect)
context.closePath()
context.clip()

let colorSpace = CGColorSpaceCreateDeviceRGB()
let colorLocations: [CGFloat] = [0.0, 1.0]

let startPoint = CGPoint(x: 0, y: glassRect.minY)
let endPoint = CGPoint(x: 0, y: glassRect.maxY)

let gradient = CGGradient(colorsSpace: colorSpace, colors: colors as CFArray, locations: colorLocations)!

context.drawLinearGradient(gradient, start: startPoint, end: endPoint, options: [])
context.fillPath()

context.restoreGState()
}
}
14 changes: 14 additions & 0 deletions SUPLA/Core/UI/Details/StandardDetailVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ class StandardDetailVC<S : ViewState, E : ViewEvent, VM : StandardDetailVM<S, E>
viewControllers.append(terraceAwningDetail())
case .projectorScreen:
viewControllers.append(projectorScreenDetail())
case .curtain:
viewControllers.append(curtainDetail())

}
}

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

private func curtainDetail() -> CurtainVC {
let vc = CurtainVC(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 @@ -62,7 +62,8 @@ class BaseTableViewModel<S: ViewState, E: ViewEvent>: BaseViewModel<S, E> {
SUPLA_CHANNELFNC_CONTROLLINGTHEROOFWINDOW,
SUPLA_CHANNELFNC_CONTROLLINGTHEFACADEBLIND,
SUPLA_CHANNELFNC_TERRACE_AWNING,
SUPLA_CHANNELFNC_PROJECTOR_SCREEN:
SUPLA_CHANNELFNC_PROJECTOR_SCREEN,
SUPLA_CHANNELFNC_CURTAIN:
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 @@ -195,7 +195,8 @@ class ChannelBaseTableViewController<S: ViewState, E: ViewEvent, VM: BaseTableVi
SUPLA_CHANNELFNC_CONTROLLINGTHEFACADEBLIND,
SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER,
SUPLA_CHANNELFNC_TERRACE_AWNING,
SUPLA_CHANNELFNC_PROJECTOR_SCREEN:
SUPLA_CHANNELFNC_PROJECTOR_SCREEN,
SUPLA_CHANNELFNC_CURTAIN:
return cellIdForIcon
default:
return cellIdForChannel
Expand Down
6 changes: 3 additions & 3 deletions SUPLA/Core/UI/Views/ThermostatControlView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class ThermostatControlView: UIView {
var setpointHeatPercentage: CGFloat? {
get { setpointHeat }
set {
setpointHeat = newValue?.toPercentage()
setpointHeat = newValue?.limit()
setpointHeatPoint.isHidden = newValue == nil
setNeedsDisplay()
}
Expand All @@ -48,7 +48,7 @@ final class ThermostatControlView: UIView {
var setpointCoolPercentage: CGFloat? {
get { setpointCool }
set {
setpointCool = newValue?.toPercentage()
setpointCool = newValue?.limit()
setpointCoolPoint.isHidden = newValue == nil
setNeedsDisplay()
}
Expand All @@ -57,7 +57,7 @@ final class ThermostatControlView: UIView {
var temperaturePercentage: CGFloat? {
get { temperature }
set {
temperature = newValue?.toPercentage() ?? 0
temperature = newValue?.limit() ?? 0
currentTemperaturePoint.isHidden = newValue == nil
setNeedsDisplay()
}
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 @@ -105,7 +105,8 @@ final class IconCell: BaseCell<ChannelWithChildren> {
SUPLA_CHANNELFNC_CONTROLLINGTHEFACADEBLIND,
SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER,
SUPLA_CHANNELFNC_TERRACE_AWNING,
SUPLA_CHANNELFNC_PROJECTOR_SCREEN: true
SUPLA_CHANNELFNC_PROJECTOR_SCREEN,
SUPLA_CHANNELFNC_CURTAIN: true
default: false
}
}
Expand All @@ -116,7 +117,8 @@ final class IconCell: BaseCell<ChannelWithChildren> {
SUPLA_CHANNELFNC_CONTROLLINGTHEFACADEBLIND,
SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER,
SUPLA_CHANNELFNC_TERRACE_AWNING,
SUPLA_CHANNELFNC_PROJECTOR_SCREEN: true
SUPLA_CHANNELFNC_PROJECTOR_SCREEN,
SUPLA_CHANNELFNC_CURTAIN: true
default: false
}
}
Expand Down
Loading

0 comments on commit fbb1502

Please sign in to comment.