File tree Expand file tree Collapse file tree 3 files changed +17
-15
lines changed
Sources/OpenTDS/Component Expand file tree Collapse file tree 3 files changed +17
-15
lines changed Original file line number Diff line number Diff line change 1
- //
2
- // File.swift
3
- //
4
- //
5
- // Created by Mercen on 2023/07/14.
6
- //
7
-
8
1
import Foundation
Original file line number Diff line number Diff line change 1
1
import SwiftUI
2
2
3
3
extension TossScrollView {
4
+
5
+ @available ( * , deprecated, renamed: " backButton " )
4
6
public func showDismiss( ) -> TossScrollView {
5
- TossScrollView ( self . title, showsIndicators: self . showsIndicators, showsDismiss: true ) {
7
+ self . backButton ( )
8
+ }
9
+
10
+ public func backButton( action: @escaping ( ) -> ( ) = {
11
+ let presentationMode = Environment ( \. presentationMode) . wrappedValue
12
+ presentationMode. wrappedValue. dismiss ( )
13
+ } ) -> TossScrollView {
14
+ TossScrollView ( self . title,
15
+ showsIndicators: self . showsIndicators,
16
+ backButtonAction: action) {
6
17
self . content
7
18
}
8
19
}
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ public struct TossScrollView<Content: View>: View {
15
15
16
16
let title : String
17
17
let showsIndicators : Bool
18
- let showsDismiss : Bool
18
+ let backButtonAction : ( ( ) -> ( ) ) ?
19
19
let content : Content
20
20
21
21
/**
@@ -25,22 +25,20 @@ public struct TossScrollView<Content: View>: View {
25
25
*/
26
26
public init ( _ title: String ,
27
27
showsIndicators: Bool = true ,
28
- showsDismiss : Bool = false ,
28
+ backButtonAction : ( ( ) -> ( ) ) ? = nil ,
29
29
@ViewBuilder content: @escaping ( ) -> Content ) {
30
30
self . title = title
31
31
self . showsIndicators = showsIndicators
32
- self . showsDismiss = showsDismiss
32
+ self . backButtonAction = backButtonAction
33
33
self . content = content ( )
34
34
}
35
35
36
36
public var body : some View {
37
37
VStack {
38
38
ZStack {
39
39
HStack {
40
- if showsDismiss {
41
- Button ( action: {
42
- presentationMode. wrappedValue. dismiss ( )
43
- } ) {
40
+ if let backButtonAction = backButtonAction {
41
+ Button ( action: backButtonAction) {
44
42
TossIcon . chevron
45
43
. resizable ( )
46
44
. frame ( width: 10.14 , height: 17.77 )
You can’t perform that action at this time.
0 commit comments