-
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.
Shared, iOS: Add notification request widget (#1190)
^ALTAPPS-1348
- Loading branch information
1 parent
4353d4f
commit 8c04adb
Showing
41 changed files
with
1,119 additions
and
36 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
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
88 changes: 88 additions & 0 deletions
88
...dules/NotificationDailyStudyReminderWidget/NotificationDailyStudyReminderWidgetView.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,88 @@ | ||
import SwiftUI | ||
|
||
extension NotificationDailyStudyReminderWidgetView { | ||
struct Appearance { | ||
let illustrationSize = CGSize(width: 89, height: 86) | ||
|
||
let spacing = LayoutInsets.defaultInset | ||
let interitemSpacing = LayoutInsets.smallInset | ||
} | ||
} | ||
|
||
struct NotificationDailyStudyReminderWidgetView: View { | ||
private(set) var appearance = Appearance() | ||
|
||
var onCallToAction: () -> Void | ||
var onClose: () -> Void | ||
var onViewedEvent: () -> Void | ||
|
||
var body: some View { | ||
ZStack { | ||
UIViewControllerEventsWrapper(onViewDidAppear: onViewedEvent) | ||
|
||
Button( | ||
action: onCallToAction, | ||
label: { | ||
ZStack(alignment: Alignment(horizontal: .trailing, vertical: .top)) { | ||
HStack(alignment: .center, spacing: appearance.spacing) { | ||
textConent | ||
illustration | ||
} | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
.padding([.leading, .vertical]) | ||
|
||
closeButton | ||
} | ||
.foregroundColor(.white) | ||
.background(backgroundGradient) | ||
} | ||
) | ||
.buttonStyle(BounceButtonStyle()) | ||
} | ||
} | ||
|
||
private var textConent: some View { | ||
VStack(alignment: .leading, spacing: appearance.interitemSpacing) { | ||
Text(Strings.NotificationDailyStudyReminderWidget.title) | ||
.font(.headline) | ||
Text(Strings.NotificationDailyStudyReminderWidget.subtitle) | ||
.font(.subheadline) | ||
} | ||
} | ||
|
||
private var illustration: some View { | ||
Image(.usersInterviewWidgetIllustration) | ||
.renderingMode(.original) | ||
.resizable() | ||
.aspectRatio(contentMode: .fit) | ||
.frame(size: appearance.illustrationSize) | ||
} | ||
|
||
private var closeButton: some View { | ||
Button( | ||
action: onClose, | ||
label: { | ||
Image(systemName: "xmark.circle.fill") | ||
.padding(.all, appearance.interitemSpacing) | ||
} | ||
) | ||
} | ||
|
||
private var backgroundGradient: some View { | ||
Image(.usersInterviewWidgetGradient) | ||
.renderingMode(.original) | ||
.resizable() | ||
.addBorder(color: .clear, width: 0) | ||
} | ||
} | ||
|
||
#if DEBUG | ||
#Preview { | ||
NotificationDailyStudyReminderWidgetView( | ||
onCallToAction: {}, | ||
onClose: {}, | ||
onViewedEvent: {} | ||
) | ||
.padding() | ||
} | ||
#endif |
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
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
Oops, something went wrong.