v5.2.5 Quick fix for widgets

This commit is contained in:
Zbigniew Cisiński 2024-01-25 19:43:37 +01:00
parent a93bcdd875
commit c15921242e
33 changed files with 1367 additions and 287 deletions

30
TwoFAS/Common/Common.h Normal file
View File

@ -0,0 +1,30 @@
//
// This file is part of the 2FAS iOS app (https://github.com/twofas/2fas-ios)
// Copyright © 2024 Two Factor Authentication Service, Inc.
// Contributed by Zbigniew Cisiński. All rights reserved.
//
// 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 3 of the License, or
// 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, see <https://www.gnu.org/licenses/>
//
#import <Foundation/Foundation.h>
//! Project version number for Common.
FOUNDATION_EXPORT double CommonVersionNumber;
//! Project version string for Common.
FOUNDATION_EXPORT const unsigned char CommonVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <Common/PublicHeader.h>

View File

@ -1,23 +0,0 @@
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Common",
platforms: [.iOS(.v16)],
products: [
.library(
name: "Common",
type: .dynamic,
targets: ["Common"])
],
targets: [
.target(
name: "Common",
path: ".",
sources: ["Sources"],
resources: [.process("Assets")]
)
]
)

View File

@ -21,7 +21,7 @@ import UIKit
// swiftlint:disable all
public enum ThemeColor {
private static let bundle = Bundle.module
private static let bundle = Bundle(for: CountdownTimer.self)
public static let backgroundLight = UIColor.white
public static let light = UIColor(red: 0.98, green: 0.98, blue: 0.98, alpha: 1.00)
public static let dark = UIColor(red: 0.14, green: 0.12, blue: 0.13, alpha: 1.00)

View File

@ -109,7 +109,7 @@ public extension TintColor {
}
var color: UIColor {
let bundle = Bundle.module
let bundle = Bundle(for: CountdownTimer.self)
switch self {
case .`default`: return UIColor(named: "tintDefaultColor", in: bundle, compatibleWith: nil)!
case .lightBlue: return UIColor(named: "tintLightBlueColor", in: bundle, compatibleWith: nil)!

Binary file not shown.

30
TwoFAS/Content/Content.h Normal file
View File

@ -0,0 +1,30 @@
//
// This file is part of the 2FAS iOS app (https://github.com/twofas/2fas-ios)
// Copyright © 2024 Two Factor Authentication Service, Inc.
// Contributed by Zbigniew Cisiński. All rights reserved.
//
// 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 3 of the License, or
// 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, see <https://www.gnu.org/licenses/>
//
#import <Foundation/Foundation.h>
//! Project version number for Content.
FOUNDATION_EXPORT double ContentVersionNumber;
//! Project version string for Content.
FOUNDATION_EXPORT const unsigned char ContentVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <Content/PublicHeader.h>

View File

@ -1,29 +0,0 @@
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Content",
platforms: [.iOS(.v16)],
products: [
.library(
name: "Content",
type: .dynamic,
targets: ["Content"])
],
dependencies: [
.package(path: "../Common")
],
targets: [
.target(
name: "Content",
dependencies: [
"Common"
],
path: ".",
sources: ["Sources"],
resources: [.copy("Assets/Assets.car")]
)
]
)

View File

@ -29,7 +29,7 @@ public protocol IconDescriptionDatabase: AnyObject {
public final class IconDescriptionDatabaseImpl {
public static var bundle: Bundle {
Bundle.module
Bundle(for: IconDescriptionDatabaseImpl.self)
}
private let database = IconDescriptionDatabaseGenerated()
public init() {}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1520"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C251EDD42AE87150007722F2"
BuildableName = "Base32.framework"
BlueprintName = "Base32"
ReferencedContainer = "container:TwoFAS.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C251EDD42AE87150007722F2"
BuildableName = "Base32.framework"
BlueprintName = "Base32"
ReferencedContainer = "container:TwoFAS.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1520"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C2E7C3542ADB02FE00478D89"
BuildableName = "CommonUIKit.framework"
BlueprintName = "CommonUIKit"
ReferencedContainer = "container:TwoFAS.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C2E7C3542ADB02FE00478D89"
BuildableName = "CommonUIKit.framework"
BlueprintName = "CommonUIKit"
ReferencedContainer = "container:TwoFAS.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1520"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C2E53B4A2B62DDCB008E1E70"
BuildableName = "Content.framework"
BlueprintName = "Content"
ReferencedContainer = "container:TwoFAS.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C2E53B4A2B62DDCB008E1E70"
BuildableName = "Content.framework"
BlueprintName = "Content"
ReferencedContainer = "container:TwoFAS.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1520"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C2E7C3812ADB19F300478D89"
BuildableName = "Data.framework"
BlueprintName = "Data"
ReferencedContainer = "container:TwoFAS.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C2DF710A2B5DD31200D85D87"
BuildableName = "DataTests.xctest"
BlueprintName = "DataTests"
ReferencedContainer = "container:TwoFAS.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C2E7C3812ADB19F300478D89"
BuildableName = "Data.framework"
BlueprintName = "Data"
ReferencedContainer = "container:TwoFAS.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -28,22 +28,29 @@ struct TwoFASWidgetEntryView: View {
@ViewBuilder
var body: some View {
switch family {
case .systemSmall:
if let first = entry.entries.first {
TwoFASWidgetSquareView(entry: first)
} else {
Group {
switch family {
case .systemSmall:
if let first = entry.entries.first {
TwoFASWidgetSquareView(entry: first)
} else {
Text("widget_size_not_supported")
}
case .systemMedium:
TwoFASWidgetLineView(entries: entry.entries)
case .systemLarge:
TwoFASWidgetLineView(entries: entry.entries)
case .systemExtraLarge:
TwoFASWidgetLineViewGrid(entries: entry.entries)
default:
Text("widget_size_not_supported")
}
case .systemMedium:
TwoFASWidgetLineView(entries: entry.entries)
case .systemLarge:
TwoFASWidgetLineView(entries: entry.entries)
case .systemExtraLarge:
TwoFASWidgetLineViewGrid(entries: entry.entries)
default:
Text("widget_size_not_supported")
}
.widgetBackground(backgroundView: backgroundView)
}
private var backgroundView: some View {
Color.widgetBackground
}
}
@ -63,6 +70,7 @@ struct TwoFASWidget: Widget {
.configurationDisplayName("2FAS")
.description("widget_settings_description")
.supportedFamilies(supportedFamilies)
.contentMarginsDisabled()
}
}
@ -72,3 +80,15 @@ struct TwoFASWidget_Previews: PreviewProvider {
.previewContext(WidgetPreviewContext(family: .systemLarge))
}
}
extension View {
func widgetBackground(backgroundView: some View) -> some View {
if #available(iOSApplicationExtension 17.0, *) {
return containerBackground(for: .widget) {
backgroundView
}
} else {
return background(backgroundView)
}
}
}

Binary file not shown.