From c1a433a4696080e430f7cd87834a870d4fb0d027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=95=E6=96=B0=E9=9B=A8?= Date: Wed, 28 Jan 2026 23:41:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=96=B0=E5=A2=9EIOS=E5=B0=8F=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/.gitignore | 6 + client/ios/client.xcodeproj/project.pbxproj | 24 ++-- client/ios/情绪小组件/AppIntent.swift | 18 --- client/ios/情绪小组件/EmotionWidget.swift | 139 +++++++++++++++----- 4 files changed, 128 insertions(+), 59 deletions(-) create mode 100644 client/.gitignore delete mode 100644 client/ios/情绪小组件/AppIntent.swift diff --git a/client/.gitignore b/client/.gitignore new file mode 100644 index 0000000..5873d9a --- /dev/null +++ b/client/.gitignore @@ -0,0 +1,6 @@ + +# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb +# The following patterns were generated by expo-cli + +expo-env.d.ts +# @end expo-cli \ No newline at end of file diff --git a/client/ios/client.xcodeproj/project.pbxproj b/client/ios/client.xcodeproj/project.pbxproj index 14df779..a5c532d 100644 --- a/client/ios/client.xcodeproj/project.pbxproj +++ b/client/ios/client.xcodeproj/project.pbxproj @@ -11,13 +11,12 @@ 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 1A1DE01D4133812B2E2BA692 /* libPods-client.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E3328F0E595C1F4A244DF238 /* libPods-client.a */; }; 3E461D99554A48A4959DE609 /* SplashScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AA286B85B6C04FC6940260E9 /* SplashScreen.storyboard */; }; + A1B2C3D4E5F60718293A4B5C /* 情绪小组件/EmotionWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D4E5F60718293A4B5B /* 情绪小组件/EmotionWidget.swift */; }; B5A7FE9A125F7C79753EC5BF /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7DB40C26E3A46F6D06769EA /* ExpoModulesProvider.swift */; }; BB2F792D24A3F905000567C9 /* Expo.plist in Resources */ = {isa = PBXBuildFile; fileRef = BB2F792C24A3F905000567C9 /* Expo.plist */; }; EB3DAF812F2A4B8E00450593 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EB3DAF802F2A4B8D00450593 /* WidgetKit.framework */; }; EB3DAF832F2A4B8E00450593 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EB3DAF822F2A4B8E00450593 /* SwiftUI.framework */; }; EB3DAF942F2A4B8F00450593 /* 情绪小组件Extension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = EB3DAF7F2F2A4B8D00450593 /* 情绪小组件Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; - EB3DAF9B2F2A4D0A00450593 /* MindfulnessWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB3DAF9A2F2A4D0900450593 /* MindfulnessWidget.swift */; }; - A1B2C3D4E5F60718293A4B5C /* EmotionWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D4E5F60718293A4B5B /* EmotionWidget.swift */; }; F11748422D0307B40044C1D9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F11748412D0307B40044C1D9 /* AppDelegate.swift */; }; /* End PBXBuildFile section */ @@ -51,6 +50,7 @@ 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = client/Info.plist; sourceTree = ""; }; 3C76CA16D0801CBF0D731C7C /* Pods-client.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-client.release.xcconfig"; path = "Target Support Files/Pods-client/Pods-client.release.xcconfig"; sourceTree = ""; }; 75F52ADE07CAE9D9736D7671 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = client/PrivacyInfo.xcprivacy; sourceTree = ""; }; + A1B2C3D4E5F60718293A4B5B /* 情绪小组件/EmotionWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "情绪小组件/EmotionWidget.swift"; sourceTree = ""; }; AA286B85B6C04FC6940260E9 /* SplashScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = SplashScreen.storyboard; path = client/SplashScreen.storyboard; sourceTree = ""; }; BB2F792C24A3F905000567C9 /* Expo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Expo.plist; sourceTree = ""; }; C7DB40C26E3A46F6D06769EA /* ExpoModulesProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ExpoModulesProvider.swift; path = "Pods/Target Support Files/Pods-client/ExpoModulesProvider.swift"; sourceTree = ""; }; @@ -59,7 +59,6 @@ EB3DAF802F2A4B8D00450593 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; EB3DAF822F2A4B8E00450593 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; EB3DAF9A2F2A4D0900450593 /* MindfulnessWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MindfulnessWidget.swift; sourceTree = ""; }; - A1B2C3D4E5F60718293A4B5B /* EmotionWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "情绪小组件/EmotionWidget.swift"; sourceTree = ""; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; F11748412D0307B40044C1D9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = client/AppDelegate.swift; sourceTree = ""; }; F11748442D0722820044C1D9 /* client-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "client-Bridging-Header.h"; path = "client/client-Bridging-Header.h"; sourceTree = ""; }; @@ -153,6 +152,7 @@ 2D16E6871FA4F8E400B85C8A /* Frameworks */, 9BE464729A978E7F7FF8BB61 /* Pods */, F7A1EA0ECA728F3AC6EE9C33 /* ExpoModulesProviders */, + EB3DAFD42F2A5FC100450593 /* Recovered References */, ); indentWidth = 2; sourceTree = ""; @@ -186,6 +186,14 @@ path = client/Supporting; sourceTree = ""; }; + EB3DAFD42F2A5FC100450593 /* Recovered References */ = { + isa = PBXGroup; + children = ( + A1B2C3D4E5F60718293A4B5B /* 情绪小组件/EmotionWidget.swift */, + ); + name = "Recovered References"; + sourceTree = ""; + }; F7A1EA0ECA728F3AC6EE9C33 /* ExpoModulesProviders */ = { isa = PBXGroup; children = ( @@ -436,7 +444,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - A1B2C3D4E5F60718293A4B5C /* EmotionWidget.swift in Sources */, + A1B2C3D4E5F60718293A4B5C /* 情绪小组件/EmotionWidget.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -665,7 +673,7 @@ INFOPLIST_FILE = "情绪小组件/Info.plist"; INFOPLIST_KEY_CFBundleDisplayName = "情绪小组件"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 17.6; + IPHONEOS_DEPLOYMENT_TARGET = 15.1; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -675,7 +683,7 @@ MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "com.anonymous.client.-----"; + PRODUCT_BUNDLE_IDENTIFIER = com.anonymous.client.emotionwidget; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; STRING_CATALOG_GENERATE_SYMBOLS = YES; @@ -716,7 +724,7 @@ INFOPLIST_FILE = "情绪小组件/Info.plist"; INFOPLIST_KEY_CFBundleDisplayName = "情绪小组件"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 17.6; + IPHONEOS_DEPLOYMENT_TARGET = 15.1; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -725,7 +733,7 @@ LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MARKETING_VERSION = 1.0.0; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "com.anonymous.client.-----"; + PRODUCT_BUNDLE_IDENTIFIER = com.anonymous.client.emotionwidget; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; STRING_CATALOG_GENERATE_SYMBOLS = YES; diff --git a/client/ios/情绪小组件/AppIntent.swift b/client/ios/情绪小组件/AppIntent.swift deleted file mode 100644 index 3a3419a..0000000 --- a/client/ios/情绪小组件/AppIntent.swift +++ /dev/null @@ -1,18 +0,0 @@ -// -// AppIntent.swift -// 情绪小组件 -// -// Created by jojo on 2026/1/28. -// - -import WidgetKit -import AppIntents - -struct ConfigurationAppIntent: WidgetConfigurationIntent { - static var title: LocalizedStringResource { "Configuration" } - static var description: IntentDescription { "This is an example widget." } - - // An example configurable parameter. - @Parameter(title: "Favorite Emoji", default: "😃") - var favoriteEmoji: String -} diff --git a/client/ios/情绪小组件/EmotionWidget.swift b/client/ios/情绪小组件/EmotionWidget.swift index 594d4bb..3376cfa 100644 --- a/client/ios/情绪小组件/EmotionWidget.swift +++ b/client/ios/情绪小组件/EmotionWidget.swift @@ -46,20 +46,63 @@ struct EmotionWidgetView: View { } } - private func smallView() -> some View { + // 统一的“卡片背景”风格(iOS 15 兼容) + private func cardBackground(colors: [Color]) -> some View { ZStack { LinearGradient( - colors: [Color(red: 0.07, green: 0.09, blue: 0.13), Color(red: 0.15, green: 0.18, blue: 0.26)], + colors: colors, startPoint: .topLeading, endPoint: .bottomTrailing ) - VStack(alignment: .leading, spacing: 8) { - Text(title).font(.headline).foregroundStyle(.white) + // 轻微光斑,增加层次 + RadialGradient( + gradient: Gradient(colors: [Color.white.opacity(0.16), Color.white.opacity(0.0)]), + center: .topTrailing, + startRadius: 10, + endRadius: 180 + ) + } + .overlay( + RoundedRectangle(cornerRadius: 18, style: .continuous) + .stroke(Color.white.opacity(0.14), lineWidth: 1) + ) + .cornerRadius(18) + } + + private func chip(_ text: String) -> some View { + Text(text) + .font(.system(size: 12, weight: .semibold)) + .foregroundColor(Color.white.opacity(0.9)) + .padding(.horizontal, 10) + .padding(.vertical, 6) + .background(Color.white.opacity(0.14)) + .cornerRadius(999) + } + + private func smallView() -> some View { + ZStack { + cardBackground(colors: [ + Color(red: 0.06, green: 0.08, blue: 0.12), + Color(red: 0.13, green: 0.16, blue: 0.22), + ]) + + VStack(alignment: .leading, spacing: 10) { + HStack { + chip(title) + Spacer(minLength: 0) + } + Text(text) - .font(.system(size: 14, weight: .semibold)) - .foregroundStyle(Color.white.opacity(0.92)) + .font(.system(size: 15, weight: .semibold)) + .foregroundColor(Color.white.opacity(0.92)) + .lineSpacing(2) .lineLimit(4) + Spacer(minLength: 0) + + Text("点我回到 App") + .font(.system(size: 11, weight: .medium)) + .foregroundColor(Color.white.opacity(0.65)) } .padding(14) } @@ -68,21 +111,37 @@ struct EmotionWidgetView: View { private func mediumView() -> some View { ZStack { - LinearGradient( - colors: [Color(red: 0.07, green: 0.09, blue: 0.13), Color(red: 0.10, green: 0.12, blue: 0.18)], - startPoint: .topLeading, - endPoint: .bottomTrailing - ) - HStack(spacing: 14) { - VStack(alignment: .leading, spacing: 8) { - Text(title).font(.headline).foregroundStyle(.white) + cardBackground(colors: [ + Color(red: 0.06, green: 0.08, blue: 0.12), + Color(red: 0.09, green: 0.11, blue: 0.17), + ]) + + HStack(alignment: .top, spacing: 14) { + VStack(alignment: .leading, spacing: 10) { + chip(title) Text(text) - .font(.system(size: 16, weight: .semibold)) - .foregroundStyle(Color.white.opacity(0.92)) + .font(.system(size: 17, weight: .semibold)) + .foregroundColor(Color.white.opacity(0.92)) + .lineSpacing(3) .lineLimit(5) + Spacer(minLength: 0) + + Text("轻轻呼吸,回到当下") + .font(.system(size: 12, weight: .medium)) + .foregroundColor(Color.white.opacity(0.7)) + } + + // 右侧装饰区:让版面更饱满 + VStack(alignment: .trailing, spacing: 8) { + Text(entry.date, style: .time) + .font(.system(size: 12, weight: .semibold)) + .foregroundColor(Color.white.opacity(0.8)) + Spacer(minLength: 0) + Text("今日") + .font(.system(size: 28, weight: .bold)) + .foregroundColor(Color.white.opacity(0.12)) } - Spacer(minLength: 0) } .padding(16) } @@ -91,24 +150,37 @@ struct EmotionWidgetView: View { private func largeView() -> some View { ZStack { - LinearGradient( - colors: [Color(red: 0.07, green: 0.09, blue: 0.13), Color(red: 0.17, green: 0.22, blue: 0.32)], - startPoint: .topLeading, - endPoint: .bottomTrailing - ) - VStack(alignment: .leading, spacing: 12) { - Text(title) - .font(.title3) - .foregroundStyle(.white) - .bold() + cardBackground(colors: [ + Color(red: 0.06, green: 0.08, blue: 0.12), + Color(red: 0.14, green: 0.18, blue: 0.28), + ]) + + VStack(alignment: .leading, spacing: 14) { + HStack { + chip(title) + Spacer(minLength: 0) + Text(entry.date, style: .time) + .font(.system(size: 12, weight: .semibold)) + .foregroundColor(Color.white.opacity(0.78)) + } + Text(text) - .font(.system(size: 18, weight: .semibold)) - .foregroundStyle(Color.white.opacity(0.92)) - .lineLimit(7) + .font(.system(size: 20, weight: .semibold)) + .foregroundColor(Color.white.opacity(0.92)) + .lineSpacing(4) + .lineLimit(8) + Spacer(minLength: 0) - Text("轻轻呼吸,回到当下") - .font(.footnote) - .foregroundStyle(Color.white.opacity(0.7)) + + HStack { + Text("点我回到 Home") + .font(.system(size: 12, weight: .medium)) + .foregroundColor(Color.white.opacity(0.7)) + Spacer(minLength: 0) + Text("🌿") + .font(.system(size: 18)) + .opacity(0.9) + } } .padding(18) } @@ -116,6 +188,7 @@ struct EmotionWidgetView: View { } } +@main struct EmotionWidget: Widget { let kind: String = "EmotionWidget"