Skip to content

Commit

Permalink
Fix requested changes
Browse files Browse the repository at this point in the history
Rename background to backgroundColor
Remove new option in the deprecated initializer
  • Loading branch information
viere1234 committed May 18, 2022
1 parent 7559134 commit cad72b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Sources/SlideOverCard/Modifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
import SwiftUI

extension View {
public func slideOverCard<Content: View>(isPresented: Binding<Bool>, onDismiss: (() -> Void)? = nil, options: SOCOptions = [], background: Color = Color(.systemGray6), @ViewBuilder content: @escaping () -> Content) -> some View {
public func slideOverCard<Content: View>(isPresented: Binding<Bool>, onDismiss: (() -> Void)? = nil, options: SOCOptions = [], backgroundColor: Color = Color(.systemGray6), @ViewBuilder content: @escaping () -> Content) -> some View {
return ZStack {
self
SlideOverCard(isPresented: isPresented,
onDismiss: onDismiss,
options: options,
background: background) {
backgroundColor: backgroundColor) {
content()
}
}
}

public func slideOverCard<Item: Identifiable, Content: View>(item: Binding<Item?>, onDismiss: (() -> Void)? = nil, options: SOCOptions = [], background: Color = Color(.systemGray6), @ViewBuilder content: @escaping (Item) -> Content) -> some View {
public func slideOverCard<Item: Identifiable, Content: View>(item: Binding<Item?>, onDismiss: (() -> Void)? = nil, options: SOCOptions = [], backgroundColor: Color = Color(.systemGray6), @ViewBuilder content: @escaping (Item) -> Content) -> some View {
let binding = Binding(get: { item.wrappedValue != nil }, set: { if !$0 { item.wrappedValue = nil } })
return self.slideOverCard(isPresented: binding, onDismiss: onDismiss, options: options, background: background, content: {
return self.slideOverCard(isPresented: binding, onDismiss: onDismiss, options: options, backgroundColor: backgroundColor, content: {
if let item = item.wrappedValue {
content(item)
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/SlideOverCard/SlideOverCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ public struct SlideOverCard<Content: View>: View {
let onDismiss: (() -> Void)?
var options: SOCOptions
let content: Content
let background: Color
let backgroundColor: Color

public init(isPresented: Binding<Bool>, onDismiss: (() -> Void)? = nil, options: SOCOptions = [], background: Color = Color(.systemGray6), content: @escaping () -> Content) {
public init(isPresented: Binding<Bool>, onDismiss: (() -> Void)? = nil, options: SOCOptions = [], backgroundColor: Color = Color(.systemGray6), content: @escaping () -> Content) {
self.isPresented = isPresented
self.onDismiss = onDismiss
self.options = options
self.background = background
self.backgroundColor = backgroundColor
self.content = content()
}

@available(*, deprecated, message: "Replace option parameters with the new option set.")
public init(isPresented: Binding<Bool>, onDismiss: (() -> Void)? = nil, dragEnabled: Binding<Bool> = .constant(true), dragToDismiss: Binding<Bool> = .constant(true), displayExitButton: Binding<Bool> = .constant(true), background: Color = Color(.systemGray6), content: @escaping () -> Content) {
public init(isPresented: Binding<Bool>, onDismiss: (() -> Void)? = nil, dragEnabled: Binding<Bool> = .constant(true), dragToDismiss: Binding<Bool> = .constant(true), displayExitButton: Binding<Bool> = .constant(true), content: @escaping () -> Content) {
self.isPresented = isPresented
self.onDismiss = onDismiss

Expand All @@ -33,7 +33,7 @@ public struct SlideOverCard<Content: View>: View {
if !displayExitButton.wrappedValue { options.insert(.hideExitButton) }

self.options = options
self.background = background
self.backgroundColor = Color(.systemGray6)
self.content = content()
}

Expand Down Expand Up @@ -90,7 +90,7 @@ public struct SlideOverCard<Content: View>: View {
.padding([.horizontal, options.contains(.hideExitButton) ? .vertical : .bottom], 14)
}.padding(20)
.background(RoundedRectangle(cornerRadius: 38.5, style: .continuous)
.fill(background))
.fill(backgroundColor))
.clipShape(RoundedRectangle(cornerRadius: 38.5, style: .continuous))
.offset(x: 0, y: viewOffset/pow(2, abs(viewOffset)/500+1))
.gesture(
Expand Down

0 comments on commit cad72b9

Please sign in to comment.