Badge SwiftUI - admiral-team/admiralui-ios GitHub Wiki

Struct

The component that shows a quantitative value, usually complements other components, for example, to show the number of alerts in the Bottom navigation or Toolbar section


Declaration

public struct BadgeView<Content>: View where Content: View

Overview

Badge is a component that usually complements other components and shows quantitative scores. For example, a tabs component can show the number of items in a bookmark. Or show the number of notifications in the notification panel.

Configure a BadgeView

For configuration badge view need set text.

BadgeView(
   badgeStyle: .error,
   value: 1
)

Also you can set style for background presentation. For example, if you want show badge with error, we recommend use style error.

BadgeView(
   badgeStyle: .error,
   value: nil
)

Also you can set an image by passing content property in the initializer.

 BadgeView(
     badgeStyle: .default,
     value: nil,
     content: {
            Image("Your image")
             .resizable()
             .aspectRatio(contentMode: .fit)
             .frame(width: 50.0, height: 50.0, alignment: .center)
     }
 )

Contribution

You can help us to find bugs or ask us to add features.

  • To start issue please use ready-made templates.
  • To make changes to the repository, you need to create a fork of the project, make changes to the code and create a pull request in our project. You can read more about this in the Github documentation.
⚠️ **GitHub.com Fallback** ⚠️