EXTENSION
extension View
public var hosted: UIHostingController<Self>
Self wrapped in an UIHostingController
public func fillEqual(length: CGFloat, alignment: Alignment = .center) -> some View
Fill frame height and width to the same length
- Parameters:
- length: Length to set
- alignment: Aligment
- Returns: View
Name | Description |
---|---|
length | Length to set |
alignment | Aligment |
public func fillParent(alignment: Alignment = .center) -> some View
Fill parent view
- Parameter alignment: alignment
- Returns: View with filled frame
Name | Description |
---|---|
alignment | alignment |
public func fillFlexible(
_ flexibleAxis: Axis.Set = [.horizontal, .vertical],
alignment: Alignment = .center
) -> some View
Similar to distribuation fill on UIStackView
, take up all availabe space of parent
- Parameters:
- flexibleAxis: Axis to fill
- alignment: Alignment
- Returns: View
Name | Description |
---|---|
flexibleAxis | Axis to fill |
alignment | Alignment |
public func embedInNavigationView() -> some View
Embed Self in NavigationView
- Returns: New view with
NavigationView
parent
public func embedInScrollView(
_ axis: Axis.Set = .vertical,
showsIndicators: Bool = false
) -> some View
Embed Self in ScrollView
- Returns: New view with
ScrollView
parent
public func embedInVerticalPagingTabView<Selection: Hashable>(
_ selection: Binding<Selection>? = nil,
pageIndicators: PageTabViewStyle.IndexDisplayMode = .never
) -> some View
ForEach(0 ..< 5) { item in
Rectangle()
.foregroundColor(.random())
}.embedInVerticalPagingTabView($selection)
public func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View
Round view with specific corners
- Parameters:
- radius: radius
- corners: corners to round
- Returns: new rounded view
Name | Description |
---|---|
radius | radius |
corners | corners to round |
public func center(alignment: Alignment = .center) -> some View
Center a view in parent local coor space
- Parameter alignment: aligment of centered view
- Returns: new view
Name | Description |
---|---|
alignment | aligment of centered view |
public func eraseToAnyView() -> AnyView
Erase view to AnyView
- Returns: new view
public func hide(if hidden: Bool) -> some View
Hides the view conditionally
- Parameter hidden: is hidden
- Returns: hidden view but not drawn on screen
Name | Description |
---|---|
hidden | is hidden |
public func shimmer(
isActive: Bool = true,
speed: Double = 0.15,
angle: Angle = .init(degrees: 70)
) -> some View
Loading shimmer animation on view
- Parameters:
- isActive: is shimmer animation active
- speed: speed, default: 0.15
- angle: angle of animation, default: 70º
- Returns: View
Name | Description |
---|---|
isActive | is shimmer animation active |
speed | speed, default: 0.15 |
angle | angle of animation, default: 70º |
public func circleMotion(
isActive: Bool = true,
circleColor: Color = .gray
) -> some View
Add animating circles to view
- Parameters:
- isActive: is animation active
- circleColor: circle foreground color
- Returns: View
Name | Description |
---|---|
isActive | is animation active |
circleColor | circle foreground color |
public func addBorder<S>(_ content: S, width: CGFloat = 1, cornerRadius: CGFloat) -> some View where S: ShapeStyle
Overlay border on view
- Parameters:
- content: ShapeStyle view
- width: border width
- cornerRadius: corner radius
- Returns: view
Name | Description |
---|---|
content | ShapeStyle view |
width | border width |
cornerRadius | corner radius |
public func gradientOverlay(
colors: Color...,
start: UnitPoint = .top,
end: UnitPoint = .bottom
) -> some View
Addd a LinearGradient
overlayed on View
- Parameters:
- colors: Colors
- start: Start, default top
- end: End, default bottom
- Returns: View
Name | Description |
---|---|
colors | Colors |
start | Start, default top |
end | End, default bottom |
public func gradientBackground(
colors: Color...,
start: UnitPoint = .top,
end: UnitPoint = .bottom
) -> some View
Addd a LinearGradient
background on View
- Parameters:
- colors: Colors
- start: Start, default top
- end: End, default bottom
- Returns: View
Name | Description |
---|---|
colors | Colors |
start | Start, default top |
end | End, default bottom |
public func safeArea<Background: View>(
withBackground backgroundView: Background,
safeAreaRegions: SafeAreaRegions = .all,
edges: Edge.Set = .all
) -> some View
Expand safe area on the background of the view
- Parameters:
- backgroundView: view to ignore safe area
- safeAreaRegions: safe area regions
- edges: edges
- Returns: View
Name | Description |
---|---|
backgroundView | view to ignore safe area |
safeAreaRegions | safe area regions |
edges | edges |
public func navigationBarColors(background: UIColor, text: UIColor) -> some View
Set Navigation bar background color and text
- Parameters:
- background: background color
- text: text color
- Returns: View
Name | Description |
---|---|
background | background color |
text | text color |
public func background<Content: View>(
alignment: Alignment = .center,
@ViewBuilder content: () -> Content
) -> some View
Container that doesn’t leak outside the safe area, only the elements in its background
- Parameters:
- alignment: alignment
- content: content
- Returns: View
Name | Description |
---|---|
alignment | alignment |
content | content |
public func hideKeyboard()
Hide keyboard
public func keyboardState(info: Binding<KeyboardInfo>) -> some View
Receive keyboard status updates
- Parameter isVisible: is keyboard visible
- Returns: View
Name | Description |
---|---|
isVisible | is keyboard visible |
public func debugPrint(_ vars: Any...) -> some View
Debug print
- Parameter vars: item to print
- Returns: View
Name | Description |
---|---|
vars | item to print |
public func debugAction(_ closure: () -> Void) -> Self
Debug action
- Parameter closure: action
- Returns: View
Name | Description |
---|---|
closure | action |
public func debugModifier<T: View>(_ modifier: (Self) -> T) -> some View
Debug visual modifier
- Parameter modifier: View modifier
- Returns: View
Name | Description |
---|---|
modifier | View modifier |
public func debugBorder(_ color: Color = .red, width: CGFloat = 1) -> some View
Debug only border
- Parameters:
- color: color
- width: width
- Returns: View
Name | Description |
---|---|
color | color |
width | width |
public func debugBackground(_ color: Color = .red) -> some View
Debug only background
- Parameter color: color
- Returns: View
Name | Description |
---|---|
color | color |
public func debug() -> Self
Debug print view representation
- Returns: Self after printing
public func times(_ value: UInt) -> some View
Repeat View n times
- Parameter value: repeat upto not including
- Returns: View
Name | Description |
---|---|
value | repeat upto not including |
public func useSize<Content: View>(of content: @autoclosure () -> Content) -> some View
Overlay View on content size
- Parameter content: content size
- Returns: View
Name | Description |
---|---|
content | content size |
public func onReceive<P: Publisher>(_ publisher: P, assignTo binding: Binding<P.Output>) -> some View where P.Failure == Never
Subscribe and blind ouput to View property
- Parameters:
- publisher: publisher
- binding: binding
- Returns: View
Name | Description |
---|---|
publisher | publisher |
binding | binding |
public func onReceive<P: Publisher>(_ publisher: P, assignTo binding: Binding<P.Output?>) -> some View where P.Failure == Never
Subscribe and blind optional ouput to View property
- Parameters:
- publisher: publisher
- binding: binding
- Returns: View
Name | Description |
---|---|
publisher | publisher |
binding | binding |
public func scrollOffset(_ offset: Binding<CGPoint>) -> some View
Get the scroll view content offset X
- Parameter offsetX: Binding for offset
- Returns: View
Name | Description |
---|---|
offsetX | Binding for offset |
public func shadowButton(
titleColor: Color = .white,
background: Color = .blue,
padding: (edges: Edge.Set, length: CGFloat) = (.all, 10),
shadow: (radius: CGFloat, alpha: CGFloat, y: CGFloat) = (10, 0.15, 4),
cornerRadius: CGFloat = 10
) -> some View
Add foreground, background, shadow, cornerRadius to Button
content
- Parameters:
- titleColor: foreground color
- background: background color
- padding: padding
- shadow: shadow
- cornerRadius: corner radius
- Returns: View
Name | Description |
---|---|
titleColor | foreground color |
background | background color |
padding | padding |
shadow | shadow |
cornerRadius | corner radius |
public func onNotification(
_ name: Notification.Name,
object: AnyObject? = nil,
perform action: @escaping (Notification) -> Void
) -> some View
Subscribe to the given notification
- Parameters:
- name: Notification name
- object: Object posting the notification
- action: Action to run when received
- Returns: View
Name | Description |
---|---|
name | Notification name |
object | Object posting the notification |
action | Action to run when received |
bottomSheet(isPresented:height:animation:thumbHidden:content:)
public func bottomSheet<Content: View>(
isPresented: Binding<Bool>,
height: Height = .mid,
animation: Animation = .easeInOut(duration: 0.3),
thumbHidden: Bool = false,
@ViewBuilder content: @escaping () -> Content
) -> some View
Adds a bottom sheet to View
- Parameters:
- isPresented: Binding for presenting the View
- height: Height, default .mid
- animation: Animation
- content: modal content
- Returns: View
Name | Description |
---|---|
isPresented | Binding for presenting the View |
height | Height, default .mid |
animation | Animation |
content | modal content |
public func getRect(binding: Binding<CGRect>) -> some View
Get the views frame in the global coordinate space
- Parameter binding: Rect binding
- Returns: View
Name | Description |
---|---|
binding | Rect binding |