-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Feature: Added new background enum to change style of background (#…
…56) * New Feature: Added new background enum to change style of background of sheet. Added few extra examples
- Loading branch information
Showing
5 changed files
with
109 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
Example/PartialSheetExample/Examples/BlurredSheetExample.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// BlurredSheetExample.swift | ||
// PartialSheetExample | ||
// | ||
// Created by Rasmus Styrk on 14/08/2020. | ||
// Copyright © 2020 Swift. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct BlurredExample: View { | ||
|
||
// Adding a new sheet manager and style locally - *this is not recommended (it's just for the example sake)* | ||
// - recommended way is adding one global sheet as per the documentation. | ||
let sheetManager: PartialSheetManager = PartialSheetManager() | ||
let sheetStyle = PartialSheetStyle(background: .blur(.systemMaterialDark), | ||
handlerBarColor: Color(UIColor.systemGray2), | ||
enableCover: true, | ||
coverColor: Color.black.opacity(0.4), | ||
blurEffectStyle: nil, | ||
cornerRadius: 10 | ||
) | ||
|
||
var body: some View { | ||
VStack { | ||
Spacer() | ||
Button(action: { | ||
self.sheetManager.showPartialSheet({ | ||
print("BlurredExample sheet dismissed") | ||
}) { | ||
BlurredSheetView() | ||
} | ||
}, label: { | ||
Text("Display the BlurredExample Sheet") | ||
}) | ||
.padding() | ||
Spacer() | ||
HStack { | ||
Rectangle().foregroundColor(Color.blue).frame(width: 75, height: 75) | ||
Rectangle().foregroundColor(Color.green).frame(width: 75, height: 75) | ||
Rectangle().foregroundColor(Color.red).frame(width: 75, height: 75) | ||
Rectangle().foregroundColor(Color.yellow).frame(width: 75, height: 75) | ||
} | ||
} | ||
.navigationBarTitle("BlurredExample Example") | ||
.navigationViewStyle(StackNavigationViewStyle()) | ||
.addPartialSheet(style: self.sheetStyle) | ||
.environmentObject(self.sheetManager) | ||
} | ||
} | ||
|
||
struct BlurredExample_Previews: PreviewProvider { | ||
static var previews: some View { | ||
NavigationView { | ||
BlurredSheetView() | ||
} | ||
.addPartialSheet() | ||
.navigationViewStyle(StackNavigationViewStyle()) | ||
.environmentObject(PartialSheetManager()) | ||
} | ||
} | ||
|
||
struct BlurredSheetView: View { | ||
@State private var selectedStrength = 0 | ||
|
||
var body: some View { | ||
VStack { | ||
Group { | ||
Text("Settings Panel").font(.headline).foregroundColor(Color.white) | ||
Text("The background of the sheet is blurred").font(.subheadline).foregroundColor(Color.white) | ||
} | ||
.padding() | ||
.frame(height: 50) | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters