Skip to content

Commit e7d6b94

Browse files
committed
docs(tutorials): create a basic tutorial on how to setup QuickActionsKit
1 parent 4e03829 commit e7d6b94

10 files changed

Lines changed: 163 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@Tutorial(time: 10) {
2+
@Intro(title: "Defining your QuickActions") {
3+
Learn how to configure the QuickActionsKit library to enhance your application's shortcuts.
4+
}
5+
6+
@Section(title: "Define your application's Quick Actions") {
7+
We'll first start by defining all the possible Quick Actions that your application is gonna
8+
9+
@Steps {
10+
@Step {
11+
First, start by creating an enum corresponding to your quick actions. This enum must conform to `String` and `QuickActionType`.
12+
13+
@Code(name: "MyQuickActions.swift", file: Step1.swift)
14+
}
15+
16+
@Step {
17+
Create a class conforming to `QuickActionsManager`, and define the `actions` property, that contains all your actions.
18+
19+
@Code(name: "MyQuickActions.swift", file: Step2.swift)
20+
}
21+
22+
@Step {
23+
Specify actions availability. You can restrict visibility depending on the user authentication, current date etc.
24+
25+
@Code(name: "MyQuickActions.swift", file: Step3.swift)
26+
}
27+
28+
@Step {
29+
Create the `perform` method, that'll be called with the corresponding type and user information.
30+
31+
@Code(name: "MyQuickActions.swift", file: Step4.swift)
32+
}
33+
}
34+
}
35+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import QuickActionsKit
2+
3+
enum MyQuickActionsType: String, QuickActionType {
4+
case home
5+
case editor
6+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import QuickActionsKit
2+
3+
enum MyQuickActionsType: String, QuickActionType {
4+
case home
5+
case editor
6+
}
7+
8+
class MyQuickActions: QuickActions {
9+
var actions: Set<QuickActionsItem<MyQuickActionsType>> = [
10+
QuickActionsItem<MyQuickActionsType>(
11+
type: .home,
12+
title: "Go Home",
13+
subtitle: "Redirect to Home",
14+
icon: nil
15+
)
16+
]
17+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import QuickActionsKit
2+
3+
enum MyQuickActionsType: String, QuickActionType {
4+
case home
5+
case editor
6+
}
7+
8+
class MyQuickActions: QuickActions {
9+
var actions: Set<QuickActionsItem<MyQuickActionsType>> = [
10+
QuickActionsItem<MyQuickActionsType>(
11+
type: .home,
12+
title: "Go Home",
13+
subtitle: "Redirect to Home",
14+
icon: nil
15+
),
16+
QuickActionsItem<MyQuickActionsType>(
17+
type: .home,
18+
title: "Edit",
19+
subtitle: nil,
20+
icon: nil,
21+
isAvailable: MyApplicationSingleton.current.isUserLogged
22+
)
23+
]
24+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import QuickActionsKit
2+
3+
enum MyQuickActionsType: String, QuickActionType {
4+
case home
5+
case editor
6+
}
7+
8+
class MyQuickActions: QuickActions {
9+
var actions: Set<QuickActionsItem<MyQuickActionsType>> = [
10+
QuickActionsItem<MyQuickActionsType>(
11+
type: .home,
12+
title: "Go Home",
13+
subtitle: "Redirect to Home",
14+
icon: nil
15+
),
16+
QuickActionsItem<MyQuickActionsType>(
17+
type: .home,
18+
title: "Edit",
19+
subtitle: nil,
20+
icon: nil,
21+
isAvailable: MyApplicationSingleton.current.isUserLogged
22+
)
23+
]
24+
25+
func perform(for type: MyQuickActionsType, with userInfo: [String:NSSecureCoding]?) -> Bool {
26+
switch type {
27+
case .home:
28+
print("Navigate to Home")
29+
30+
case .editor:
31+
print("Navigate to the editor")
32+
}
33+
}
34+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# ``QuickActionsKit``
2+
3+
A lightweight library, allowing you to easily configure shortcuts (Quick Actions) from the Home Screen.
4+
5+
## Overview
6+
7+
This library can be used in both SwiftUI and UIKit architectures.
8+
Simply define your quick actions based on the current state of the application.
9+
10+
![Cover](Cover.png)
11+
12+
## Tutorials
13+
14+
- <doc:Defining-Your-QuickActions>
15+
- <doc:Setup-QuickActions-for-SwiftUI>
16+
- <doc:Setup-QuickActions-for-UIKit>
37.6 KB
Loading
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@Tutorial(time: 10) {
2+
@Intro(title: "Setup QuickActions for SwiftUI") {
3+
Learn how to configure the QuickActionsKit library to enhance your application's shortcuts.
4+
}
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@Tutorial(time: 10) {
2+
@Intro(title: "Setup QuickActions for UIKit") {
3+
Learn how to configure the QuickActionsKit library to enhance your application's shortcuts.
4+
}
5+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@Tutorials(name: "QuickActionsKit Tutorials") {
2+
@Intro(title: "Learn how to setup QuickActions for your application.") {
3+
Add engaging introduction text here.
4+
5+
@Image(source: Cover, alt: "Cover")
6+
}
7+
8+
9+
@Chapter(name: "Configuration") {
10+
@TutorialReference(tutorial: "doc:Defining-Your-QuickActions")
11+
12+
@Image(source: Cover, alt: "Cover")
13+
}
14+
15+
@Chapter(name: "Setup") {
16+
@TutorialReference(tutorial: "doc:Setup-QuickActions-for-SwiftUI")
17+
@TutorialReference(tutorial: "doc:Setup-QuickActions-for-UIKit")
18+
19+
@Image(source: Cover, alt: "Cover")
20+
}
21+
}

0 commit comments

Comments
 (0)