refactor: update Notification and Live Activity Views for Improved UI Consistency
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
AA000001000030 /* MaydayLiveActivityBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA000002000030 /* MaydayLiveActivityBundle.swift */; };
|
AA000001000030 /* MaydayLiveActivityBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA000002000030 /* MaydayLiveActivityBundle.swift */; };
|
||||||
AA000001000031 /* MaydayLiveActivityLiveActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA000002000031 /* MaydayLiveActivityLiveActivity.swift */; };
|
AA000001000031 /* MaydayLiveActivityLiveActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA000002000031 /* MaydayLiveActivityLiveActivity.swift */; };
|
||||||
AA000001000032 /* AlertAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA000002000008 /* AlertAttributes.swift */; };
|
AA000001000032 /* AlertAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA000002000008 /* AlertAttributes.swift */; };
|
||||||
|
AA000001000033 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = AA000002000027 /* Localizable.xcstrings */; };
|
||||||
AA000007000001 /* MaydayLiveActivity.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = AA000008000001 /* MaydayLiveActivity.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
AA000007000001 /* MaydayLiveActivity.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = AA000008000001 /* MaydayLiveActivity.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
@@ -332,6 +333,7 @@
|
|||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
AA000001000033 /* Localizable.xcstrings in Resources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -446,7 +448,7 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_TEAM = "";
|
DEVELOPMENT_TEAM = WA8SWY233K;
|
||||||
GENERATE_INFOPLIST_FILE = NO;
|
GENERATE_INFOPLIST_FILE = NO;
|
||||||
INFOPLIST_FILE = MaydayLiveActivity/Info.plist;
|
INFOPLIST_FILE = MaydayLiveActivity/Info.plist;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
|
||||||
@@ -470,7 +472,7 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_TEAM = "";
|
DEVELOPMENT_TEAM = WA8SWY233K;
|
||||||
GENERATE_INFOPLIST_FILE = NO;
|
GENERATE_INFOPLIST_FILE = NO;
|
||||||
INFOPLIST_FILE = MaydayLiveActivity/Info.plist;
|
INFOPLIST_FILE = MaydayLiveActivity/Info.plist;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "1540"
|
||||||
|
version = "1.7">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES"
|
||||||
|
buildArchitectures = "Automatic">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "AA000005000001"
|
||||||
|
BuildableName = "Mayday.app"
|
||||||
|
BlueprintName = "Mayday"
|
||||||
|
ReferencedContainer = "container:Mayday.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
shouldAutocreateTestPlan = "YES">
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "AA000005000001"
|
||||||
|
BuildableName = "Mayday.app"
|
||||||
|
BlueprintName = "Mayday"
|
||||||
|
ReferencedContainer = "container:Mayday.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "AA000005000001"
|
||||||
|
BuildableName = "Mayday.app"
|
||||||
|
BlueprintName = "Mayday"
|
||||||
|
ReferencedContainer = "container:Mayday.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "2620"
|
||||||
|
wasCreatedForAppExtension = "YES"
|
||||||
|
version = "2.0">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES"
|
||||||
|
buildArchitectures = "Automatic">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "AA000005000002"
|
||||||
|
BuildableName = "MaydayLiveActivity.appex"
|
||||||
|
BlueprintName = "MaydayLiveActivity"
|
||||||
|
ReferencedContainer = "container:Mayday.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "AA000005000001"
|
||||||
|
BuildableName = "Mayday.app"
|
||||||
|
BlueprintName = "Mayday"
|
||||||
|
ReferencedContainer = "container:Mayday.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
shouldAutocreateTestPlan = "YES">
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = ""
|
||||||
|
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||||
|
launchStyle = "0"
|
||||||
|
askForAppToLaunch = "Yes"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES"
|
||||||
|
launchAutomaticallySubstyle = "2">
|
||||||
|
<RemoteRunnable
|
||||||
|
runnableDebuggingMode = "2"
|
||||||
|
BundleIdentifier = "com.apple.springboard">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "AA000005000002"
|
||||||
|
BuildableName = "MaydayLiveActivity.appex"
|
||||||
|
BlueprintName = "MaydayLiveActivity"
|
||||||
|
ReferencedContainer = "container:Mayday.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</RemoteRunnable>
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "AA000005000001"
|
||||||
|
BuildableName = "Mayday.app"
|
||||||
|
BlueprintName = "Mayday"
|
||||||
|
ReferencedContainer = "container:Mayday.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
<EnvironmentVariables>
|
||||||
|
<EnvironmentVariable
|
||||||
|
key = "_XCWidgetKind"
|
||||||
|
value = ""
|
||||||
|
isEnabled = "YES">
|
||||||
|
</EnvironmentVariable>
|
||||||
|
<EnvironmentVariable
|
||||||
|
key = "_XCWidgetDefaultView"
|
||||||
|
value = "timeline"
|
||||||
|
isEnabled = "YES">
|
||||||
|
</EnvironmentVariable>
|
||||||
|
<EnvironmentVariable
|
||||||
|
key = "_XCWidgetFamily"
|
||||||
|
value = "systemMedium"
|
||||||
|
isEnabled = "YES">
|
||||||
|
</EnvironmentVariable>
|
||||||
|
</EnvironmentVariables>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
askForAppToLaunch = "Yes"
|
||||||
|
launchAutomaticallySubstyle = "2">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "AA000005000001"
|
||||||
|
BuildableName = "Mayday.app"
|
||||||
|
BlueprintName = "Mayday"
|
||||||
|
ReferencedContainer = "container:Mayday.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"colors" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +1,32 @@
|
|||||||
{
|
{
|
||||||
"sourceLanguage" : "ru",
|
"sourceLanguage" : "ru",
|
||||||
"strings" : {
|
"strings" : {
|
||||||
"NSUserNotificationsUsageDescription" : {
|
"CFBundleName" : {
|
||||||
|
"comment" : "Bundle name",
|
||||||
|
"extractionState" : "extracted_with_value",
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"ru" : {
|
"ru" : {
|
||||||
"stringUnit" : {
|
"stringUnit" : {
|
||||||
"state" : "translated",
|
"state" : "new",
|
||||||
"value" : "Mayday использует уведомления для оповещения о критических событиях."
|
"value" : "Mayday"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"NSUserNotificationsUsageDescription" : {
|
||||||
|
"extractionState" : "stale",
|
||||||
|
"localizations" : {
|
||||||
"en" : {
|
"en" : {
|
||||||
"stringUnit" : {
|
"stringUnit" : {
|
||||||
"state" : "translated",
|
"state" : "translated",
|
||||||
"value" : "Mayday uses notifications to alert you about critical events."
|
"value" : "Mayday uses notifications to alert you about critical events."
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"ru" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Mayday использует уведомления для оповещения о критических событиях."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+911
-878
File diff suppressed because it is too large
Load Diff
@@ -58,7 +58,7 @@ struct NotificationDetailView: View {
|
|||||||
VStack(spacing: 16) {
|
VStack(spacing: 16) {
|
||||||
ZStack {
|
ZStack {
|
||||||
Circle()
|
Circle()
|
||||||
.fill(.white)
|
.fill(Color(.secondarySystemGroupedBackground))
|
||||||
.frame(width: 88, height: 88)
|
.frame(width: 88, height: 88)
|
||||||
.shadow(color: topicColor.opacity(0.3), radius: 12, y: 4)
|
.shadow(color: topicColor.opacity(0.3), radius: 12, y: 4)
|
||||||
Circle()
|
Circle()
|
||||||
@@ -115,7 +115,7 @@ struct NotificationDetailView: View {
|
|||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
.padding(16)
|
.padding(16)
|
||||||
.background(.white)
|
.background(Color(.secondarySystemGroupedBackground))
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 16))
|
.clipShape(RoundedRectangle(cornerRadius: 16))
|
||||||
.shadow(color: .black.opacity(0.04), radius: 6, y: 2)
|
.shadow(color: .black.opacity(0.04), radius: 6, y: 2)
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ struct NotificationDetailView: View {
|
|||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
.padding(16)
|
.padding(16)
|
||||||
.background(.white)
|
.background(Color(.secondarySystemGroupedBackground))
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 16))
|
.clipShape(RoundedRectangle(cornerRadius: 16))
|
||||||
.shadow(color: .black.opacity(0.04), radius: 6, y: 2)
|
.shadow(color: .black.opacity(0.04), radius: 6, y: 2)
|
||||||
}
|
}
|
||||||
@@ -186,7 +186,7 @@ struct NotificationDetailView: View {
|
|||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
.padding(16)
|
.padding(16)
|
||||||
.background(.white)
|
.background(Color(.secondarySystemGroupedBackground))
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 16))
|
.clipShape(RoundedRectangle(cornerRadius: 16))
|
||||||
.shadow(color: .black.opacity(0.04), radius: 6, y: 2)
|
.shadow(color: .black.opacity(0.04), radius: 6, y: 2)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,13 +40,14 @@ struct NotificationsView: View {
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
if PreviewData.isPreviewMode {
|
if PreviewData.isPreviewMode {
|
||||||
ToolbarItem(placement: .topBarLeading) {
|
ToolbarItem(placement: .topBarLeading) {
|
||||||
|
Button(action: {}) {
|
||||||
Text("demo_badge")
|
Text("demo_badge")
|
||||||
.font(.caption2.bold())
|
.font(.caption2.bold())
|
||||||
.foregroundStyle(.white)
|
}
|
||||||
.padding(.horizontal, 8)
|
.buttonStyle(.borderedProminent)
|
||||||
.padding(.vertical, 3)
|
.tint(.orange)
|
||||||
.background(.orange)
|
.controlSize(.mini)
|
||||||
.clipShape(Capsule())
|
.allowsHitTesting(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -177,7 +178,7 @@ struct ActiveNotificationCard: View {
|
|||||||
.foregroundStyle(Color.red)
|
.foregroundStyle(Color.red)
|
||||||
.padding(.horizontal, 32)
|
.padding(.horizontal, 32)
|
||||||
.padding(.vertical, 10)
|
.padding(.vertical, 10)
|
||||||
.background(.white)
|
.background(Color(.systemBackground))
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 12))
|
.clipShape(RoundedRectangle(cornerRadius: 12))
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
@@ -245,7 +246,7 @@ struct ResolvedNotificationCard: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(16)
|
.padding(16)
|
||||||
.background(.white)
|
.background(Color(.secondarySystemGroupedBackground))
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 20))
|
.clipShape(RoundedRectangle(cornerRadius: 20))
|
||||||
.shadow(color: .black.opacity(0.06), radius: 8, y: 2)
|
.shadow(color: .black.opacity(0.06), radius: 8, y: 2)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,153 +1,218 @@
|
|||||||
import ActivityKit
|
import ActivityKit
|
||||||
import WidgetKit
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import WidgetKit
|
||||||
|
|
||||||
struct MaydayLiveActivityLiveActivity: Widget {
|
struct MaydayLiveActivityLiveActivity: Widget {
|
||||||
var body: some WidgetConfiguration {
|
var body: some WidgetConfiguration {
|
||||||
ActivityConfiguration(for: AlertAttributes.self) { context in
|
ActivityConfiguration(for: AlertAttributes.self) { context in
|
||||||
lockScreenView(context: context)
|
// MARK: - Lock Screen / Banner / StandBy
|
||||||
|
|
||||||
|
HStack(spacing: 12) {
|
||||||
|
RoundedRectangle(cornerRadius: 4)
|
||||||
|
.fill(severityColor(context.attributes.severity))
|
||||||
|
.frame(width: 4)
|
||||||
|
|
||||||
|
VStack(alignment: .leading, spacing: 6) {
|
||||||
|
HStack(alignment: .firstTextBaseline) {
|
||||||
|
Text(context.attributes.topic)
|
||||||
|
.font(.caption)
|
||||||
|
.fontWeight(.medium)
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
Text(context.state.startedAt, style: .relative)
|
||||||
|
.font(.caption2)
|
||||||
|
.monospacedDigit()
|
||||||
|
.foregroundStyle(.tertiary)
|
||||||
|
.contentTransition(.numericText(countsDown: false))
|
||||||
|
}
|
||||||
|
|
||||||
|
Text(context.state.title)
|
||||||
|
.font(.subheadline)
|
||||||
|
.fontWeight(.semibold)
|
||||||
|
.lineLimit(2)
|
||||||
|
|
||||||
|
HStack(alignment: .firstTextBaseline) {
|
||||||
|
if let value = context.state.value {
|
||||||
|
Text(value)
|
||||||
|
.font(.footnote)
|
||||||
|
.fontWeight(.medium)
|
||||||
|
.foregroundStyle(severityColor(context.attributes.severity))
|
||||||
|
.contentTransition(.numericText())
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
statusLabel(context.state.status)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding(14)
|
||||||
.activityBackgroundTint(severityColor(context.attributes.severity).opacity(0.12))
|
.activityBackgroundTint(severityColor(context.attributes.severity).opacity(0.12))
|
||||||
.activitySystemActionForegroundColor(.primary)
|
.activitySystemActionForegroundColor(severityColor(context.attributes.severity))
|
||||||
|
.accessibilityElement(children: .combine)
|
||||||
|
.accessibilityLabel("\(context.attributes.severity.rawValue) alert: \(context.state.title)")
|
||||||
|
|
||||||
} dynamicIsland: { context in
|
} dynamicIsland: { context in
|
||||||
DynamicIsland {
|
DynamicIsland {
|
||||||
|
// MARK: - Expanded
|
||||||
|
|
||||||
DynamicIslandExpandedRegion(.leading) {
|
DynamicIslandExpandedRegion(.leading) {
|
||||||
HStack(spacing: 6) {
|
HStack(spacing: 5) {
|
||||||
Image(systemName: severityIcon(context.attributes.severity))
|
Image(systemName: severityIcon(context.attributes.severity))
|
||||||
.font(.caption)
|
.font(.subheadline)
|
||||||
Text(context.attributes.topic)
|
.fontWeight(.semibold)
|
||||||
.font(.caption.bold())
|
|
||||||
}
|
|
||||||
.foregroundStyle(severityColor(context.attributes.severity))
|
.foregroundStyle(severityColor(context.attributes.severity))
|
||||||
|
.fixedSize()
|
||||||
|
|
||||||
|
Text(context.attributes.topic)
|
||||||
|
.font(.caption)
|
||||||
|
.fontWeight(.medium)
|
||||||
|
.foregroundStyle(.white.opacity(0.7))
|
||||||
|
.lineLimit(1)
|
||||||
|
.truncationMode(.tail)
|
||||||
|
.frame(maxWidth: 90, alignment: .leading)
|
||||||
}
|
}
|
||||||
|
.padding(.leading, 4)
|
||||||
|
}
|
||||||
|
|
||||||
DynamicIslandExpandedRegion(.trailing) {
|
DynamicIslandExpandedRegion(.trailing) {
|
||||||
statusBadge(context.state.status)
|
Text(context.state.startedAt, style: .relative)
|
||||||
|
.font(.caption)
|
||||||
|
.fontWeight(.medium)
|
||||||
|
.monospacedDigit()
|
||||||
|
.foregroundStyle(.white.opacity(0.6))
|
||||||
|
.contentTransition(.numericText(countsDown: false))
|
||||||
|
.lineLimit(1)
|
||||||
|
.multilineTextAlignment(.trailing)
|
||||||
|
.padding(.trailing, 4)
|
||||||
}
|
}
|
||||||
DynamicIslandExpandedRegion(.bottom) {
|
|
||||||
VStack(spacing: 8) {
|
DynamicIslandExpandedRegion(.bottom, priority: 1) {
|
||||||
HStack {
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
VStack(alignment: .leading, spacing: 3) {
|
|
||||||
Text(context.state.title)
|
Text(context.state.title)
|
||||||
.font(.subheadline.bold())
|
.font(.subheadline)
|
||||||
|
.fontWeight(.semibold)
|
||||||
|
.foregroundStyle(.white)
|
||||||
|
.lineLimit(2)
|
||||||
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
|
|
||||||
|
HStack {
|
||||||
if let value = context.state.value {
|
if let value = context.state.value {
|
||||||
Text(value)
|
Text(value)
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
|
.fontWeight(.semibold)
|
||||||
.foregroundStyle(severityColor(context.attributes.severity))
|
.foregroundStyle(severityColor(context.attributes.severity))
|
||||||
|
.padding(.horizontal, 10)
|
||||||
|
.padding(.vertical, 4)
|
||||||
|
.background(
|
||||||
|
severityColor(context.attributes.severity).opacity(0.2),
|
||||||
|
in: ContainerRelativeShape()
|
||||||
|
)
|
||||||
|
.contentTransition(.numericText())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Spacer()
|
Spacer()
|
||||||
VStack(alignment: .trailing, spacing: 3) {
|
|
||||||
HStack(spacing: 3) {
|
statusLabel(context.state.status)
|
||||||
Image(systemName: "clock")
|
|
||||||
.font(.caption2)
|
|
||||||
Text(context.state.startedAt, style: .timer)
|
|
||||||
.font(.caption.monospacedDigit())
|
|
||||||
}
|
|
||||||
.foregroundStyle(.secondary)
|
|
||||||
Text(context.state.startedAt.formatted(date: .omitted, time: .shortened))
|
|
||||||
.font(.caption2)
|
|
||||||
.foregroundStyle(.tertiary)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.horizontal, 4)
|
.padding(.horizontal, 4)
|
||||||
|
.padding(.bottom, 8)
|
||||||
}
|
}
|
||||||
|
|
||||||
} compactLeading: {
|
} compactLeading: {
|
||||||
|
// MARK: - Compact
|
||||||
|
HStack(spacing: 4) {
|
||||||
Image(systemName: severityIcon(context.attributes.severity))
|
Image(systemName: severityIcon(context.attributes.severity))
|
||||||
|
.font(.caption)
|
||||||
|
.fontWeight(.bold)
|
||||||
.foregroundStyle(severityColor(context.attributes.severity))
|
.foregroundStyle(severityColor(context.attributes.severity))
|
||||||
} compactTrailing: {
|
.fixedSize()
|
||||||
let shortTopic = context.attributes.topic.components(separatedBy: "/").last ?? context.attributes.topic
|
|
||||||
let valueText = context.state.value.map { " · \($0)" } ?? ""
|
Text(context.attributes.topic)
|
||||||
Text("\(shortTopic)\(valueText)")
|
|
||||||
.font(.caption2)
|
.font(.caption2)
|
||||||
|
.fontWeight(.medium)
|
||||||
|
.foregroundStyle(.white.opacity(0.7))
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
|
.truncationMode(.tail)
|
||||||
|
.frame(maxWidth: 70, alignment: .leading)
|
||||||
|
}
|
||||||
|
.padding(.leading, 4)
|
||||||
|
|
||||||
|
} compactTrailing: {
|
||||||
|
Text(context.state.startedAt, style: .timer)
|
||||||
|
.font(.caption2)
|
||||||
|
.fontWeight(.medium)
|
||||||
|
.monospacedDigit()
|
||||||
|
.foregroundStyle(.white.opacity(0.8))
|
||||||
|
.contentTransition(.numericText(countsDown: false))
|
||||||
|
.frame(maxWidth: 40, alignment: .trailing)
|
||||||
|
.padding(.trailing, 4)
|
||||||
|
|
||||||
} minimal: {
|
} minimal: {
|
||||||
Image(systemName: severityIcon(context.attributes.severity))
|
Image(systemName: severityIcon(context.attributes.severity))
|
||||||
|
.font(.caption2)
|
||||||
|
.fontWeight(.bold)
|
||||||
.foregroundStyle(severityColor(context.attributes.severity))
|
.foregroundStyle(severityColor(context.attributes.severity))
|
||||||
}
|
}
|
||||||
.keylineTint(severityColor(context.attributes.severity))
|
.keylineTint(severityColor(context.attributes.severity))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
// MARK: - Helpers
|
||||||
func lockScreenView(context: ActivityViewContext<AlertAttributes>) -> some View {
|
|
||||||
VStack(spacing: 12) {
|
|
||||||
HStack(spacing: 12) {
|
|
||||||
ZStack {
|
|
||||||
Circle()
|
|
||||||
.fill(severityColor(context.attributes.severity).opacity(0.15))
|
|
||||||
.frame(width: 44, height: 44)
|
|
||||||
Image(systemName: severityIcon(context.attributes.severity))
|
|
||||||
.font(.title3)
|
|
||||||
.foregroundStyle(severityColor(context.attributes.severity))
|
|
||||||
}
|
|
||||||
|
|
||||||
VStack(alignment: .leading, spacing: 3) {
|
private func severityColor(_ severity: Severity) -> Color {
|
||||||
Text(context.state.title)
|
|
||||||
.font(.subheadline.bold())
|
|
||||||
Text(context.attributes.topic)
|
|
||||||
.font(.caption)
|
|
||||||
.foregroundStyle(.secondary)
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer()
|
|
||||||
|
|
||||||
statusBadge(context.state.status)
|
|
||||||
}
|
|
||||||
|
|
||||||
HStack(spacing: 16) {
|
|
||||||
if let value = context.state.value {
|
|
||||||
HStack(spacing: 4) {
|
|
||||||
Circle()
|
|
||||||
.fill(severityColor(context.attributes.severity))
|
|
||||||
.frame(width: 6, height: 6)
|
|
||||||
Text(value)
|
|
||||||
.font(.caption.bold())
|
|
||||||
.foregroundStyle(severityColor(context.attributes.severity))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer()
|
|
||||||
|
|
||||||
HStack(spacing: 4) {
|
|
||||||
Image(systemName: "clock")
|
|
||||||
.font(.caption2)
|
|
||||||
Text(context.state.startedAt, style: .relative)
|
|
||||||
.font(.caption)
|
|
||||||
}
|
|
||||||
.foregroundStyle(.secondary)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.padding(16)
|
|
||||||
}
|
|
||||||
|
|
||||||
@ViewBuilder
|
|
||||||
func statusBadge(_ status: AlertStatus) -> some View {
|
|
||||||
let (text, color): (String, Color) = status == .active
|
|
||||||
? (String(localized: "alert_status_active"), .red)
|
|
||||||
: (String(localized: "alert_status_resolved"), .green)
|
|
||||||
Text(text)
|
|
||||||
.font(.caption2.bold())
|
|
||||||
.textCase(.uppercase)
|
|
||||||
.padding(.horizontal, 8)
|
|
||||||
.padding(.vertical, 3)
|
|
||||||
.background(color.opacity(0.15))
|
|
||||||
.foregroundStyle(color)
|
|
||||||
.clipShape(Capsule())
|
|
||||||
}
|
|
||||||
|
|
||||||
func severityColor(_ severity: Severity) -> Color {
|
|
||||||
switch severity {
|
switch severity {
|
||||||
case .critical: return .red
|
case .critical: .red
|
||||||
case .warning: return .orange
|
case .warning: .orange
|
||||||
case .info: return .blue
|
case .info: .cyan
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func severityIcon(_ severity: Severity) -> String {
|
|
||||||
switch severity {
|
|
||||||
case .critical: return "flame.fill"
|
|
||||||
case .warning: return "exclamationmark.triangle.fill"
|
|
||||||
case .info: return "info.circle.fill"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func severityIcon(_ severity: Severity) -> String {
|
||||||
|
switch severity {
|
||||||
|
case .critical: "exclamationmark.triangle.fill"
|
||||||
|
case .warning: "exclamationmark.circle.fill"
|
||||||
|
case .info: "info.circle.fill"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
private func statusLabel(_ status: AlertStatus) -> some View {
|
||||||
|
HStack(spacing: 4) {
|
||||||
|
Circle()
|
||||||
|
.fill(status == .active ? Color.red : Color.green)
|
||||||
|
.frame(width: 5, height: 5)
|
||||||
|
|
||||||
|
Text(status == .active ? "Active" : "Resolved")
|
||||||
|
.font(.caption2)
|
||||||
|
.fontWeight(.semibold)
|
||||||
|
.foregroundStyle(status == .active ? .red : .green)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#Preview("Live Activity", as: .content, using: AlertAttributes(
|
||||||
|
topic: "server-health",
|
||||||
|
alertId: "alert-001",
|
||||||
|
severity: .critical
|
||||||
|
)) {
|
||||||
|
MaydayLiveActivityLiveActivity()
|
||||||
|
} contentStates: {
|
||||||
|
AlertAttributes.ContentState(
|
||||||
|
title: "CPU Usage Exceeded 95%",
|
||||||
|
value: "Current: 97.3%",
|
||||||
|
status: .active,
|
||||||
|
startedAt: .now.addingTimeInterval(-300),
|
||||||
|
updatedAt: .now
|
||||||
|
)
|
||||||
|
AlertAttributes.ContentState(
|
||||||
|
title: "CPU Usage Normalized",
|
||||||
|
value: "Current: 42.1%",
|
||||||
|
status: .resolved,
|
||||||
|
startedAt: .now.addingTimeInterval(-600),
|
||||||
|
updatedAt: .now
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user