Skip to content

Commit

Permalink
Fix dialog corner radius
Browse files Browse the repository at this point in the history
  • Loading branch information
matgentili committed Feb 17, 2023
1 parent 82cfa04 commit 7ae57fe
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
21 changes: 21 additions & 0 deletions Sources/SirioKitIOS/Component/Base/RoundedCorner.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// RoundedCorner.swift
//
// SPDX-FileCopyrightText: 2022 Istituto Nazionale Previdenza Sociale
//
// SPDX-License-Identifier: BSD-3-Clause
//


import SwiftUI

struct RoundedCorner: Shape {

var radius: CGFloat = .infinity
var corners: UIRectCorner = .allCorners

func path(in rect: CGRect) -> Path {
let path = UIBezierPath(roundedRect: rect, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
return Path(path.cgPath)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public struct DialogModifier: ViewModifier {
actionFirstButton: actionFirstButton,
textSecondButton: textSecondButton,
actionSecondButton: actionSecondButton,
onTapInfo: onTapInfoAction,
onTapClose: onTapCloseAction,
onTapInfoAction: onTapInfoAction,
onTapCloseAction: onTapCloseAction,
isVisibleInfoIcon: isVisibleInfoIcon)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SirioKitIOS/Component/Dialog/View/Dialog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public struct Dialog: View {
.frame(maxHeight: Size.Dialog.maxHeight)
.padding(Size.Dialog.padding)
.background(Color.Dialog.Background.default)
.cornerRadius(Size.Dialog.cornerRadius)
.cornerRadius(Size.Dialog.cornerRadius, corners: [.topLeft, .topRight])
.fixedSize(horizontal: false, vertical: true)

} // Blur View
Expand Down
7 changes: 6 additions & 1 deletion Sources/SirioKitIOS/Extension/View+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,13 @@ extension View {
}
}


private struct SizePreferenceKey: PreferenceKey {
static var defaultValue: CGSize = .zero
static func reduce(value: inout CGSize, nextValue: () -> CGSize) {}
}

extension View {
func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View {
clipShape(RoundedCorner(radius: radius, corners: corners))
}
}

0 comments on commit 7ae57fe

Please sign in to comment.