Skip to content
Snippets Groups Projects
Commit 68743f57 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Add HUDFeature library with SwiftUI HUDView

parent 8dcf6a2f
No related branches found
No related tags found
1 merge request!88HUD feature
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "HUDFeature"
BuildableName = "HUDFeature"
BlueprintName = "HUDFeature"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</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 = "HUDFeature"
BuildableName = "HUDFeature"
BlueprintName = "HUDFeature"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
......@@ -52,6 +52,7 @@ let package = Package(
.library(name: "PermissionsFeature", targets: ["PermissionsFeature"]),
.library(name: "ContactListFeature", targets: ["ContactListFeature"]),
.library(name: "RequestPermissionFeature", targets: ["RequestPermissionFeature"]),
.library(name: "HUDFeature", targets: ["HUDFeature"]),
],
dependencies: [
.package(
......@@ -659,5 +660,13 @@ let package = Package(
],
swiftSettings: swiftSettings
),
.target(
name: "HUDFeature",
dependencies: [
.target(name: "AppResources"),
.target(name: "Shared"),
],
swiftSettings: swiftSettings
),
]
)
import AppResources
public struct HUDModel {
var title: String?
var content: String?
var actionTitle: String?
var hasDotAnimation: Bool
var isAutoDismissable: Bool
var onTapClosure: (() -> Void)?
public init(
title: String? = nil,
content: String? = nil,
actionTitle: String? = nil,
hasDotAnimation: Bool = false,
isAutoDismissable: Bool = false,
onTapClosure: (() -> Void)? = nil
) {
self.title = title
self.content = content
self.actionTitle = actionTitle
self.onTapClosure = onTapClosure
self.hasDotAnimation = hasDotAnimation
self.isAutoDismissable = isAutoDismissable
}
public init(
error: Error,
actionTitle: String? = Localized.Hud.Error.action,
onTapClosure: (() -> Void)? = nil
) {
self.hasDotAnimation = false
self.actionTitle = actionTitle
self.onTapClosure = onTapClosure
self.title = Localized.Hud.Error.title
self.isAutoDismissable = onTapClosure == nil
self.content = error.localizedDescription
}
}
import AppResources
import Shared
import SwiftUI
struct HUDView: View {
var model: HUDModel
var body: some View {
ZStack {
Color(Asset.neutralDark.color.withAlphaComponent(0.9))
.ignoresSafeArea()
VStack(spacing: 20) {
Spacer()
if let title = model.title {
Text(title)
.foregroundColor(Color(Asset.neutralWhite.color))
.font(Font(Fonts.Mulish.bold.font(size: 30.0)))
}
if let content = model.content {
Text(content)
.foregroundColor(Color(Asset.neutralWhite.color))
.font(Font(Fonts.Mulish.regular.font(size: 15.0)))
}
if model.hasDotAnimation {
DotAnimation.SwiftUIView(
color: Asset.neutralWhite.color
)
.fixedSize()
.frame(height: 20)
}
Spacer()
if let actionTitle = model.actionTitle,
let onTapClosure = model.onTapClosure {
CapsuleButton.SwiftUIView(
style: .seeThroughWhite,
title: actionTitle,
action: onTapClosure
)
.fixedSize(horizontal: false, vertical: true)
}
}
.padding(.horizontal, 15)
.padding(.bottom, 20)
}
}
}
#if DEBUG
struct HUDView_Previews: PreviewProvider {
struct Preview: View {
var hud: HUDView
var body: some View {
ZStack {
LinearGradient(
colors: [
Color(UIColor(red: 122/255, green: 235/255, blue: 239/255, alpha: 1)),
Color(UIColor(red: 56/255, green: 204/255, blue: 232/255, alpha: 1)),
Color(UIColor(red: 63/255, green: 186/255, blue: 253/255, alpha: 1)),
Color(UIColor(red: 98/255, green: 163/255, blue: 255/255, alpha: 1)),
],
startPoint: .topTrailing,
endPoint: .bottomLeading
)
.ignoresSafeArea()
Image(uiImage: Asset.splash.image)
hud
}
}
}
static var previews: some View {
Preview(hud: HUDView(model: HUDModel(
title: "Title",
content: "Content",
actionTitle: "Action title",
hasDotAnimation: true,
isAutoDismissable: true,
onTapClosure: {}
)))
}
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment