Skip to content

Commit

Permalink
Issue #379: Support projector screen
Browse files Browse the repository at this point in the history
  • Loading branch information
mipolansk committed Jun 5, 2024
1 parent fd65060 commit bf2a02c
Show file tree
Hide file tree
Showing 62 changed files with 1,713 additions and 420 deletions.
94 changes: 93 additions & 1 deletion SUPLA.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion SUPLA/ChannelCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ -(void) updateCellView {
if ( isGroup ) {
self.cint_LeftStatusWidth.constant = 6;
self.cint_RightStatusWidth.constant = 6;
self.right_ActiveStatus.percent = ((SAChannelGroup*)_channelBase).activePercentage;
self.right_ActiveStatus.percent = [UseCaseLegacyWrapper getActivePercentage:(SAChannelGroup*)_channelBase];
self.right_ActiveStatus.singleColor = YES;
self.right_ActiveStatus.hidden = NO;
self.right_OnlineStatus.shapeType = stLinearVertical;
Expand Down
1 change: 1 addition & 0 deletions SUPLA/Core/DI/DiContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ extension DiContainer {
register(ReadGroupByRemoteIdUseCase.self, ReadGroupByRemoteIdUseCaseImpl())
register(GetGroupOnlineSummaryUseCase.self, GetGroupOnlineSummaryUseCaseImpl())
register(UpdateChannelGroupTotalValueUseCase.self, UpdateChannelGroupTotalValueUseCaseImpl())
register(GetGroupActivePercentageUseCase.self, GetGroupActivePercentageUseCaseImpl())
// Usecases - Icon
register(GetDefaultIconNameUseCase.self, GetDefaultIconNameUseCaseImpl())
// Usecases - Location
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 @@ -91,6 +91,8 @@ class StandardDetailVC<S : ViewState, E : ViewEvent, VM : StandardDetailVM<S, E>
viewControllers.append(facadeBlindDetail())
case .terraceAwning:
viewControllers.append(terraceAwningDetail())
case .projectorScreen:
viewControllers.append(projectorScreenDetail())
}
}

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

private func projectorScreenDetail() -> ProjectorScreenVC {
let vc = ProjectorScreenVC(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
4 changes: 3 additions & 1 deletion SUPLA/Core/UI/TableView/BaseTableViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ class BaseTableViewModel<S: ViewState, E: ViewEvent>: BaseViewModel<S, E> {
SUPLA_CHANNELFNC_GENERAL_PURPOSE_MEASUREMENT,
SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER,
SUPLA_CHANNELFNC_CONTROLLINGTHEROOFWINDOW,
SUPLA_CHANNELFNC_CONTROLLINGTHEFACADEBLIND:
SUPLA_CHANNELFNC_CONTROLLINGTHEFACADEBLIND,
SUPLA_CHANNELFNC_TERRACE_AWNING,
SUPLA_CHANNELFNC_PROJECTOR_SCREEN:
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 @@ -194,7 +194,8 @@ class ChannelBaseTableViewController<S: ViewState, E: ViewEvent, VM: BaseTableVi
case SUPLA_CHANNELFNC_CONTROLLINGTHEROOFWINDOW,
SUPLA_CHANNELFNC_CONTROLLINGTHEFACADEBLIND,
SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER,
SUPLA_CHANNELFNC_TERRACE_AWNING:
SUPLA_CHANNELFNC_TERRACE_AWNING,
SUPLA_CHANNELFNC_PROJECTOR_SCREEN:
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 @@ -104,7 +104,8 @@ final class IconCell: BaseCell<ChannelWithChildren> {
case SUPLA_CHANNELFNC_CONTROLLINGTHEROOFWINDOW,
SUPLA_CHANNELFNC_CONTROLLINGTHEFACADEBLIND,
SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER,
SUPLA_CHANNELFNC_TERRACE_AWNING: true
SUPLA_CHANNELFNC_TERRACE_AWNING,
SUPLA_CHANNELFNC_PROJECTOR_SCREEN: true
default: false
}
}
Expand All @@ -114,7 +115,8 @@ final class IconCell: BaseCell<ChannelWithChildren> {
case SUPLA_CHANNELFNC_CONTROLLINGTHEROOFWINDOW,
SUPLA_CHANNELFNC_CONTROLLINGTHEFACADEBLIND,
SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER,
SUPLA_CHANNELFNC_TERRACE_AWNING: true
SUPLA_CHANNELFNC_TERRACE_AWNING,
SUPLA_CHANNELFNC_PROJECTOR_SCREEN: true
default: false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,10 @@ extension DeviceStateHelperVMI {
private func createIconData(_ channel: SAChannelBase) -> IconData {
@Singleton<GetChannelBaseStateUseCase> var getChannelBaseStateUseCase

let online = if let channel = channel as? SAChannel {
channel.value?.online ?? false
} else if let channel = channel as? SAChannelGroup {
channel.isOnline()
} else {
false
}

return IconData(
function: channel.func,
altIcon: channel.alticon,
state: getChannelBaseStateUseCase.invoke(
function: channel.func,
online: online,
activeValue: channel.imgIsActive()
),
state: getChannelBaseStateUseCase.invoke(channelBase: channel),
userIcon: channel.usericon
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
class SwitchGeneralVM: BaseViewModel<SwitchGeneralViewState, SwitchGeneralViewEvent>, DeviceStateHelperVMI {

@Singleton<ReadChannelByRemoteIdUseCase> private var readChannelByRemoteIdUseCase
@Singleton<GetChannelBaseStateUseCase> private var getChannelBaseStateUseCase
@Singleton<ExecuteSimpleActionUseCase> private var executeSimpleActionUseCase
@Singleton<DateProvider> private var dateProvider

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import RxSwift
class SwitchTimerDetailVM: BaseViewModel<SwitchTimerDetailViewState, SwitchTimerDetailViewEvent>, DeviceStateHelperVMI {

@Singleton<ReadChannelByRemoteIdUseCase> private var readChannelByRemoteIdUseCase
@Singleton<GetChannelBaseStateUseCase> private var getChannelBaseStateUseCase
@Singleton<StartTimerUseCase> private var startTimerUseCase
@Singleton<ExecuteSimpleActionUseCase> private var executeSimpleAxtionUseCase
@Singleton<DateProvider> private var dateProvider
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 ProjectorScreenState: 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,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.
*/

struct ProjectorScreenColors {
let screen: UIColor
let shadow: UIColor
let bottomRect: UIColor
let topRect: UIColor
let logoColor: UIColor

static func standard(_ traitCollection: UITraitCollection) -> ProjectorScreenColors {
ProjectorScreenColors(
screen: .rollerShutterWindow.resolvedColor(with: traitCollection),
shadow: .black,
bottomRect: .rollerShutterSlatBackground.resolvedColor(with: traitCollection),
topRect: .gray.resolvedColor(with: traitCollection),
logoColor: .primaryVariant.copy(alpha: 0.2)
)
}

static func offline(_ traitCollection: UITraitCollection) -> ProjectorScreenColors {
ProjectorScreenColors(
screen: .surface.resolvedColor(with: traitCollection),
shadow: .black,
bottomRect: .rollerShutterSlatBackground.resolvedColor(with: traitCollection),
topRect: .disabled.resolvedColor(with: traitCollection),
logoColor: .disabled.copy(alpha: 0.2)
)
}
}
Loading

0 comments on commit bf2a02c

Please sign in to comment.