Skip to content

Commit 71350ef

Browse files
authored
Updating docs with API changes (#769)
1 parent e9012b8 commit 71350ef

File tree

10 files changed

+76
-19
lines changed

10 files changed

+76
-19
lines changed

Sources/GravatarUI/GravatarUI.docc/QuickEditorArticle.md

Lines changed: 63 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,33 @@
22

33
This customizable sheet allows users to update their avatars. Available for both UIKit and SwiftUI.
44

5-
### Quick Editor Preview
5+
## Quick Editor Preview
6+
7+
The Quick Editor offers different scopes that allow users to edit various sections of their Gravatar profile.
8+
9+
See ``QuickEditorScopeOption`` for more info.
10+
11+
#### Avatar Picker scope
612

713
Layout 1 | Layout 2 | Layout 3 |
814
----- | ------ | ----- |
915
![](vertical-large.png) | ![](vertical-medium-expandable.png) | ![](horizontal-intrinsic-height.png) |
1016
Full height sheet | Expandable sheet | Intrinsic height sheet, horizontal scroll |
1117

12-
### Quick Editor - SwiftUI
18+
#### About editor scope
19+
20+
Layout 1 | Layout 2 | Layout 3 |
21+
----- | ------ | ----- |
22+
![](about-editor.png) | ![](about-editor-medium.png) | ![](about-editor-intrinsic.png) |
23+
Full height sheet | Expandable sheet | Intrinsic height sheet |
24+
25+
#### Avatar picker & About editor scope
26+
27+
This scope combines the Avatar picker and the About editor, allowing to switch between them directly in the Quick Editor UI.
28+
29+
![](avatar-and-about.gif)
30+
31+
## Quick Editor - SwiftUI
1332

1433
SDK offers a modifier function to display the QuickEditor sheet. QuickEditor starts the OAuth flow internally to capture an access token. Please refer to <doc:GravatarOAuth> about how to configure the SDK about this.
1534

@@ -30,16 +49,23 @@ var body: some View {
3049
.gravatarQuickEditorSheet(
3150
isPresented: $isPresenting,
3251
33-
scope: .avatarPicker(.init(contentLayout: .horizontal)),
34-
avatarUpdatedHandler: {
35-
// informs that the avatar has changed
52+
scopeOption: .avatarPicker(.horizontalInstrinsicHeight),
53+
updateHandler: { updateType in
54+
switch updateType {
55+
case is QuickEditorUpdate.Avatar:
56+
// Selected avatar has changed
57+
case let update as QuickEditorUpdate.AboutInfo:
58+
// About profile info has been updated
59+
// `update.profile` contains the updated profile
60+
default: break
61+
}
3662
},
3763
onDismiss: {
3864
// sheet was dismissed
3965
}
4066
)
67+
.preferredColorScheme(.light) // Sets a preferred color scheme; omit to use the system default.
4168
}
42-
.preferredColorScheme(.light) //set the preferred color scheme if you like, or omit this line to let the system settings apply.
4369
}
4470

4571
// [...]
@@ -66,23 +92,30 @@ var body: some View {
6692
.gravatarQuickEditorSheet(
6793
isPresented: $isPresenting,
6894
69-
authToken: authToken, // Pass the auth token
70-
scope: .avatarPicker(.init(contentLayout: .horizontal)),
71-
avatarUpdatedHandler: {
72-
// informs that the avatar has changed
95+
authToken: authToken, // Passes the authentication token
96+
scopeOption: .avatarPicker(.horizontalInstrinsicHeight),
97+
updateHandler: { updateType in
98+
switch updateType {
99+
case is QuickEditorUpdate.Avatar:
100+
// Selected avatar has changed
101+
case let update as QuickEditorUpdate.AboutInfo:
102+
// About profile info has been updated
103+
// `update.profile` contains the updated profile
104+
default: break
105+
}
73106
},
74107
onDismiss: {
75108
// sheet was dismissed
76109
}
77110
)
111+
.preferredColorScheme(.light) // Sets a preferred color scheme; omit to use the system default.
78112
}
79-
.preferredColorScheme(.light) //set the preferred color scheme if you like, or omit this line to let the system settings apply.
80113
}
81114
```
82115

83116
Refer to ``AvatarPickerContentLayout`` to see all the content layout options.
84117

85-
### Quick Editor - UIKit
118+
## Quick Editor - UIKit
86119

87120
Similarly, ``QuickEditorPresenter`` can be used to display the QuickEditor in UIKit.
88121

@@ -91,19 +124,30 @@ import GravatarUI
91124

92125
// [...]
93126

127+
// Example with About editor scope
94128
let presenter = QuickEditorPresenter(
95129
email: Email("[email protected]"),
96-
scope: .avatarPicker(AvatarPickerConfiguration(contentLayout: .horizontal)),
130+
scopeOption: .aboutEditor(),
97131
configuration: .init(
98132
interfaceStyle: colorScheme
99133
)
100134
)
101-
presenter.present(in: self,
102-
onAvatarUpdated: { [weak self] in
103-
// Informs that the avatar has changed
104-
} , onDismiss: { [weak self] in
105-
// sheet was dismissed
106-
})
135+
presenter.present(
136+
in: self,
137+
onUpdate: { [weak self] updateType in
138+
switch updateType {
139+
case is QuickEditorUpdate.Avatar:
140+
// Selected avatar has changed
141+
case let update as QuickEditorUpdate.AboutInfo:
142+
// About profile info has been updated
143+
default:
144+
break
145+
}
146+
},
147+
onDismiss: { [weak self] in
148+
// sheet was dismissed
149+
}
150+
)
107151
```
108152

109153
### Delete the OAuth token
209 KB
Loading
220 KB
Loading
184 KB
Loading
200 KB
Loading
155 KB
Loading
185 KB
Loading
2.03 MB
Loading
2.62 MB
Loading

Sources/GravatarUI/SwiftUI/ProfileEditor/QuickEditorScopeOption.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ public struct QuickEditorScopeOption {
1515
}
1616

1717
/// Creates a `QuickEditorScopeOption` configured for the avatar picker scope.
18+
///
19+
/// Displays the UI for managing user avatars.
20+
///
21+
/// ![](vertical-large)
22+
///
1823
/// - Parameter config: Configuration to apply to the avatar picker.
1924
/// - Returns: A configured instance of `QuickEditorScopeOption` for the avatar picker scope.
2025
public static func avatarPicker(
@@ -26,6 +31,9 @@ public struct QuickEditorScopeOption {
2631
}
2732

2833
/// Creates a `QuickEditorScopeOption` configured for the about info editor scope.
34+
///
35+
/// Displays the UI for editing the "About" section of the Gravatar profile.
36+
/// ![](about-editor)
2937
/// - Parameter config: Configuration to apply to the about editor. Defaults to the standard configuration.
3038
/// - Returns: A configured instance of `QuickEditorScopeOption` for the about info editor scope.
3139
public static func aboutEditor(
@@ -36,6 +44,11 @@ public struct QuickEditorScopeOption {
3644
)
3745
}
3846

47+
/// Creates a `QuickEditorScopeOption` configured for the avatar picker & about info editor scope.
48+
///
49+
/// This scope allows switching between Avatar Picker and About editor from within the Quick Editor.
50+
/// - Parameter avatarPickerAndAboutEditorConfig: Configuration to apply to the avatar picker and about editor. Defaults to the standard configuration.
51+
/// - Returns: A configured instance of `QuickEditorScopeOption` for the avatar picker & about info editor scope.
3952
public static func avatarPickerAndAboutInfoEditor(
4053
_ avatarPickerAndAboutEditorConfig: AvatarPickerAndAboutEditorConfiguration = .init()
4154
) -> Self {

0 commit comments

Comments
 (0)