This is a package that I made that has a bunch of qualities of life.
The preferred way of installing Mcrich23 Toolkit is via the Swift Package Manager.
https://github.com/Mcrich23/Mcrich23-Toolkit
) and click Next.CapsuleMultiFilter(menuContent: .constant(AnyView(VStack { //Passes in the view for the plus button menu. Must use .constant() so that the view updates.
if horizantalSizeClass == .regular {
ForEach(filterOpt, id: \.self) { text in
if !filter.contains(text) {
Button {
filter.append(text)
} label: {
Text(text)
}
}
}
} else {
ForEach(filterOpt, id: \.self) { text in
if !filter.contains(text) {
Button {
filter.append(text)
} label: {
Text(text)
}
}
}
}
})), opt: filterOpt, //Use an array that are the same options as in the menu
selected: $filter //An array of currently selected filters
)
A screen for welcoming the user or presenting a What's New screen.
OnboardingScreen(
titleIcon: .systemImage(named: "plus"), // An icon to go next to the title
titleIconColor: .yellow, // Color for the icon next to the title
title: "Hello World", // Title
subtitle: "Lorem Ipsum", // Subtitle (leave blank for it to dissapear)
cells: .individual([
FeatureCell(
image: .systemImage(named: "hand"), // An icon next to the cell
imageColor: .red, // Color for the icon next to the cell
title: "Title", // Title
subtitle: "Subtitle" // Subtitle/Description (leave blank for it to dissapear)
)
])
)
let steps = [ Text(NSLocalizedString("welcome title 1", comment: "")).font(.body),
Text(NSLocalizedString("welcome title 2", comment: "")).font(.body),
Text(NSLocalizedString("welcome title 3", comment: "")).font(.body),
Text(NSLocalizedString("welcome title 4", comment: "")).font(.body)]
let indicationTypes = [
StepperIndicationType
.custom(CircledIconView(image: Image(systemName: "plus"), width: 50)),
.custom(CircledIconView(image: Image(systemName: "hand.draw"), width: 50)),
.custom(CircledIconView(image: Image(systemName: "hand.tap"), width: 50)),
.custom(CircledIconView(image: Image(systemName: "eye"), width: 50))
]
...
OnboardingScreen<Content>(
titleIcon: .systemImage(named: "plus"), // An icon to go next to the title
titleIconColor: .yellow, // Color for the icon next to the title
title: "Hello World", // Title
subtitle: "Lorem Ipsum", // Subtitle (leave blank for it to dissapear)
cells:
.steps(
StepperViewOnboarding(
steps: steps, // All the steps for the onboarding
indicationTypes: indicationTypes, // What goes next to the step text
lineOptions: .custom(1, Colors.blue(.teal).rawValue) // All the different line options
)
)
)
See badrinathvm/StepperView for more info on the Steps function.
Default alerts for SwiftUI
SwiftUIAlert.show(title: "Hello Word!", //Alert Title
message: "Lorem Ipsum", //Alert Message
preferredStyle: .alert, //Style (alert or action sheet)
actions: [UIAlertAction(title: "Done", //Action Title
style: .default, //Action Style (default, destructive, dismiss)
handler: {_ in}) //Handler for choosing that action
]
)
SwiftUIAlert.textfieldShow(title: "Test", //Alert Title
message: "Hello World!", //Alert Message
preferredStyle: .alert, //Style (alert or action sheet)
textfield: AlertTextfield(text: $text, //Textfield Text
placeholder: "", //Textfield Placeholder
clearButtonMode: .whileEditing, //When to show clear butt(always, whileEditing, unlessEditing, or never)
enablesReturnKeyAutomatically: true, //Show return key keyboard
disableAutocorrection: false, //Disable Autocorrection?
autocapitalization: .sentences, //Autocapitalization (nonsentances, allCharacter, or words)
keyboardType: .default, //The type of keyboard
returnKeyType: .default, //Type of return key on keyboard
isSecureTextEntry: .no, //Is Secure Textfield? (.yes(UITextInputPassordRules) or .no)
dismissKeyboardOnReturn: true), //Dismiss keyboard on return?
actions: [UIAlertAction(title: "Done", style: .default)]
)
Watch connection to the internet and use information to modify app behavior.
Start Monitoring: NetworkMonitor.shared.startMonitoring()
(Call in AppDelagate)
Stop Monitoring: NetworkMonitor.shared.stopMonitoring()
Get Connection Type: NetworkMonitor.shared.connectionType
(Unknown can mean disconnected)
Similar to the cards in the App Store.
ZStack {
NavigationView {
CardView(showHeader: true, //Show the title, subtitle and create button
headerTitle: "Home", //Title on the header
headerSubtitle: "Subtitle", //Subtitle on the header
headerSubtitleLocation: .below, //If Subtitle is above or below the Title
cards: .constant(cardData), //All the cards in the view
create: { //Action when create (Plus Button) is tapped
showCreateTicket.toggle()
})
.navigationBarHidden(true) //Removes Navigation Bar
.navigationBarTitle("Tickets") //Sets view title for back buttons
}
}
System ShareSheet for SwiftUI.
Mcrich23_Toolkit.presentShareSheet(
activityItems: ["Hello World"], // Items to share
excludedActivityTypes: [] // Applications to exclude from share sheet
)
Update a variable and your view on rotate.
@State var orientation = UIDevice.current.orientation
...
var body: some view {
VStack {
if orientation == .portrait {
Text("Hello World")
}
}
.onRotate { newOrientation in
orientation = newOrientation
}
}
Get the top view controller to do a uikit function on the current view instead of the root view
Get the top view controller to do a uikit function on the current view instead of the root view
Mcrich23_Toolkit.topVC.present {
EmptyView()
}
link |
Stars: 1 |
Last commit: Yesterday |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics