Skip to content

Commit

Permalink
feat: update fitted sheet present way
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeonhui committed Mar 12, 2024
1 parent b401a54 commit ea069b1
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
A5DD248C2A8DF27E00EF7364 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5DD248B2A8DF27E00EF7364 /* ContentView.swift */; };
A5DD248E2A8DF27F00EF7364 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A5DD248D2A8DF27F00EF7364 /* Assets.xcassets */; };
A5DD24912A8DF27F00EF7364 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A5DD24902A8DF27F00EF7364 /* Preview Assets.xcassets */; };
A5FA3CCD2BA0C1B9001AE190 /* SecondInlineContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5FA3CCC2BA0C1B9001AE190 /* SecondInlineContentView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -23,6 +24,7 @@
A5DD248B2A8DF27E00EF7364 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
A5DD248D2A8DF27F00EF7364 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
A5DD24902A8DF27F00EF7364 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
A5FA3CCC2BA0C1B9001AE190 /* SecondInlineContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondInlineContentView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -70,6 +72,7 @@
A59174742BA0A41B00ECD2BD /* InlineContentView.swift */,
A5DD248D2A8DF27F00EF7364 /* Assets.xcassets */,
A5DD248F2A8DF27F00EF7364 /* Preview Content */,
A5FA3CCC2BA0C1B9001AE190 /* SecondInlineContentView.swift */,
);
path = "FittedSheet-SwiftUI-Example";
sourceTree = "<group>";
Expand Down Expand Up @@ -158,6 +161,7 @@
buildActionMask = 2147483647;
files = (
A5DD248C2A8DF27E00EF7364 /* ContentView.swift in Sources */,
A5FA3CCD2BA0C1B9001AE190 /* SecondInlineContentView.swift in Sources */,
A5DD248A2A8DF27E00EF7364 /* FittedSheet_SwiftUI_ExampleApp.swift in Sources */,
A59174752BA0A41B00ECD2BD /* InlineContentView.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// SecondInlineContentView.swift
// FittedSheet-SwiftUI-Example
//
// Created by 이전희 on 3/13/24.
//

import SwiftUI
import FittedSheets
import FittedSheetsSwiftUI

struct SecondInlineContentView: View {
@State var showSheet: Bool = false
let sheetConfiguration: SheetConfiguration = .init(sizes: [.intrinsic, .fullscreen], options: .init(useInlineMode: true))

let values: [Int] = Array(Range(0...100))
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
Button {
showSheet.toggle()
} label: {
Text("toggle")
}
VStack {
HStack{Spacer()}
List(values, id: \.self) { value in
Text("\(value)")
}
}
.fittedSheet(isPresented: $showSheet,
configuration: sheetConfiguration) {
Text("asdfhasdflkahsdflkadshflkasdhfl")
}
}
.padding()
}
}

#Preview {
ContentView()
}
19 changes: 0 additions & 19 deletions Sources/FittedSheetsSwiftUI/UIViewController+.swift

This file was deleted.

9 changes: 8 additions & 1 deletion Sources/FittedSheetsSwiftUI/View+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ public extension View {
configuration: configuration,
destination: sheetView(),
animated: animated)
return self.background(fittedSheetPresenter)

return ZStack {
self
Color.clear
.background(fittedSheetPresenter)
.zIndex(isPresented.wrappedValue ? 1 : -1)
}

}
}

0 comments on commit ea069b1

Please sign in to comment.