-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf20b45
commit e6e236d
Showing
22 changed files
with
345 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
iosHyperskillApp/iosHyperskillApp/Assets.xcassets/ShareStreak/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...pp/iosHyperskillApp/Assets.xcassets/ShareStreak/share-streak-day-1.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "share-streak-day-1.png", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+83.3 KB
.../Assets.xcassets/ShareStreak/share-streak-day-1.imageset/share-streak-day-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
...p/iosHyperskillApp/Assets.xcassets/ShareStreak/share-streak-day-10.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "share-streak-day-10.png", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+86.3 KB
...ssets.xcassets/ShareStreak/share-streak-day-10.imageset/share-streak-day-10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
.../iosHyperskillApp/Assets.xcassets/ShareStreak/share-streak-day-100.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "share-streak-day-100.png", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+87.5 KB
...ets.xcassets/ShareStreak/share-streak-day-100.imageset/share-streak-day-100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
...p/iosHyperskillApp/Assets.xcassets/ShareStreak/share-streak-day-25.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "share-streak-day-25.png", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+87.4 KB
...ssets.xcassets/ShareStreak/share-streak-day-25.imageset/share-streak-day-25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
...pp/iosHyperskillApp/Assets.xcassets/ShareStreak/share-streak-day-5.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "share-streak-day-5.png", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+86.1 KB
.../Assets.xcassets/ShareStreak/share-streak-day-5.imageset/share-streak-day-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
...p/iosHyperskillApp/Assets.xcassets/ShareStreak/share-streak-day-50.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "share-streak-day-50.png", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+87.6 KB
...ssets.xcassets/ShareStreak/share-streak-day-50.imageset/share-streak-day-50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...osHyperskillApp/Sources/Modules/StepQuiz/Views/Modals/ShareStreak/ShareStreakAction.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import Foundation | ||
import UIKit | ||
|
||
enum ShareStreakAction { | ||
static func image(for streak: Int) -> UIImage? { | ||
let imageName = "share-streak-day-\(streak)" | ||
let image = UIImage(named: imageName) | ||
|
||
#if DEBUG | ||
if image == nil { | ||
assertionFailure("ShareStreakAction: image for \(imageName) not found") | ||
} | ||
#endif | ||
|
||
return image | ||
} | ||
|
||
static func makeActivityViewController(for streak: Int) -> UIActivityViewController { | ||
var items: [Any] = [ | ||
ShareStreakActivityItemSource() | ||
] | ||
if let image = image(for: streak) { | ||
items.append(image) | ||
} | ||
|
||
let activityViewController = UIActivityViewController( | ||
activityItems: items, | ||
applicationActivities: nil | ||
) | ||
activityViewController.excludedActivityTypes = [.airDrop] | ||
|
||
return activityViewController | ||
} | ||
} | ||
|
||
private final class ShareStreakActivityItemSource: NSObject, UIActivityItemSource { | ||
func activityViewControllerPlaceholderItem(_ activityViewController: UIActivityViewController) -> Any { | ||
let urlString = Strings.StepQuiz.ShareStreakModal.sharingURL | ||
return URL(string: urlString) ?? urlString | ||
} | ||
|
||
func activityViewController( | ||
_ activityViewController: UIActivityViewController, | ||
itemForActivityType activityType: UIActivity.ActivityType? | ||
) -> Any? { | ||
guard activityType?.rawValue != "com.burbn.instagram.shareextension" else { | ||
return nil | ||
} | ||
|
||
return "\(Strings.StepQuiz.ShareStreakModal.sharingText)\n\(Strings.StepQuiz.ShareStreakModal.sharingURL)" | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...yperskillApp/Sources/Modules/StepQuiz/Views/Modals/ShareStreak/ShareStreakModalView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import SwiftUI | ||
|
||
extension ShareStreakModalView { | ||
struct Appearance { | ||
let spacing = LayoutInsets.defaultInset * 2 | ||
let actionButtonsSpacing = LayoutInsets.defaultInset | ||
} | ||
} | ||
|
||
struct ShareStreakModalView: View { | ||
private(set) var appearance = Appearance() | ||
|
||
let streak: Int | ||
|
||
var onShareButtonTap: (() -> Void)? | ||
var onNoThanksButtonTap: (() -> Void)? | ||
|
||
var body: some View { | ||
VStack(alignment: .leading, spacing: appearance.spacing) { | ||
Text(Strings.StepQuiz.ShareStreakModal.title) | ||
.foregroundColor(.primaryText) | ||
.font(.title2) | ||
.bold() | ||
|
||
Image(uiImage: ShareStreakAction.image(for: streak)) | ||
.renderingMode(.original) | ||
.resizable() | ||
.aspectRatio(contentMode: .fit) | ||
.frame(maxWidth: .infinity) | ||
|
||
VStack(spacing: appearance.actionButtonsSpacing) { | ||
Button( | ||
Strings.StepQuiz.ShareStreakModal.shareButton, | ||
action: { onShareButtonTap?() } | ||
) | ||
.buttonStyle(RoundedRectangleButtonStyle(style: .violet)) | ||
|
||
Button( | ||
Strings.StepQuiz.ShareStreakModal.noThanksButton, | ||
action: { onNoThanksButtonTap?() } | ||
) | ||
.buttonStyle(OutlineButtonStyle(style: .violet)) | ||
} | ||
} | ||
.padding() | ||
} | ||
} | ||
|
||
#Preview { | ||
ShareStreakModalView(streak: 1) | ||
} |
Oops, something went wrong.