Skip to content

Commit eca63cb

Browse files
committed
Updating docs with API changes
1 parent 5d838f6 commit eca63cb

File tree

4 files changed

+67
-19
lines changed

4 files changed

+67
-19
lines changed

Sources/GravatarUI/GravatarUI.docc/QuickEditorArticle.md

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,24 @@
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+
![](about-editor)
21+
22+
## Quick Editor - SwiftUI
1323

1424
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.
1525

@@ -30,16 +40,23 @@ var body: some View {
3040
.gravatarQuickEditorSheet(
3141
isPresented: $isPresenting,
3242
email: "email@domain.com",
33-
scope: .avatarPicker(.init(contentLayout: .horizontal)),
34-
avatarUpdatedHandler: {
35-
// informs that the avatar has changed
43+
scopeOption: .avatarPicker(.horizontalInstrinsicHeight),
44+
updateHandler: { updateType in
45+
switch updateType {
46+
case is QuickEditorUpdate.Avatar:
47+
// Selected avatar has changed
48+
case let update as QuickEditorUpdate.AboutInfo:
49+
// About profile info has been updated
50+
// `update.profile` contains the updated profile
51+
default: break
52+
}
3653
},
3754
onDismiss: {
3855
// sheet was dismissed
3956
}
4057
)
58+
.preferredColorScheme(.light) // Sets a preferred color scheme; omit to use the system default.
4159
}
42-
.preferredColorScheme(.light) //set the preferred color scheme if you like, or omit this line to let the system settings apply.
4360
}
4461

4562
// [...]
@@ -66,23 +83,30 @@ var body: some View {
6683
.gravatarQuickEditorSheet(
6784
isPresented: $isPresenting,
6885
email: "email@domain.com",
69-
authToken: authToken, // Pass the auth token
70-
scope: .avatarPicker(.init(contentLayout: .horizontal)),
71-
avatarUpdatedHandler: {
72-
// informs that the avatar has changed
86+
authToken: authToken, // Passes the authentication token
87+
scopeOption: .avatarPicker(.horizontalInstrinsicHeight),
88+
updateHandler: { updateType in
89+
switch updateType {
90+
case is QuickEditorUpdate.Avatar:
91+
// Selected avatar has changed
92+
case let update as QuickEditorUpdate.AboutInfo:
93+
// About profile info has been updated
94+
// `update.profile` contains the updated profile
95+
default: break
96+
}
7397
},
7498
onDismiss: {
7599
// sheet was dismissed
76100
}
77101
)
102+
.preferredColorScheme(.light) // Sets a preferred color scheme; omit to use the system default.
78103
}
79-
.preferredColorScheme(.light) //set the preferred color scheme if you like, or omit this line to let the system settings apply.
80104
}
81105
```
82106

83107
Refer to ``AvatarPickerContentLayout`` to see all the content layout options.
84108

85-
### Quick Editor - UIKit
109+
## Quick Editor - UIKit
86110

87111
Similarly, ``QuickEditorPresenter`` can be used to display the QuickEditor in UIKit.
88112

@@ -91,19 +115,30 @@ import GravatarUI
91115

92116
// [...]
93117

118+
// Example with About editor scope
94119
let presenter = QuickEditorPresenter(
95120
email: Email("email@domain.com"),
96-
scope: .avatarPicker(AvatarPickerConfiguration(contentLayout: .horizontal)),
121+
scopeOption: .aboutEditor(),
97122
configuration: .init(
98123
interfaceStyle: colorScheme
99124
)
100125
)
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-
})
126+
presenter.present(
127+
in: self,
128+
onUpdate: { [weak self] updateType in
129+
switch updateType {
130+
case is QuickEditorUpdate.Avatar:
131+
// Selected avatar has changed
132+
case let update as QuickEditorUpdate.AboutInfo:
133+
// About profile info has been updated
134+
default:
135+
break
136+
}
137+
},
138+
onDismiss: { [weak self] in
139+
// sheet was dismissed
140+
}
141+
)
107142
```
108143

109144
### Delete the OAuth token
155 KB
Loading
185 KB
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)