Compare commits
85 Commits
5321277cec
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a525c763e | |||
| a0dffdc715 | |||
| 4765d48021 | |||
| f888e28d15 | |||
| c934dbad84 | |||
| 4088db8ec0 | |||
| 255f171aa8 | |||
| 70870e1ec2 | |||
| f1a380d105 | |||
| 01ad237af3 | |||
| 7d49f7d5a4 | |||
| 87eb958869 | |||
| 4340fd3635 | |||
| ac2eac5fcd | |||
| a386802a55 | |||
| 1f94b9884c | |||
| 58a8d27315 | |||
| 7f4fc34dbf | |||
| 5af8038ec0 | |||
| 1ff250fa17 | |||
| 42e647c932 | |||
| 080c7f00ce | |||
| 545e023ffc | |||
| 10ba84e349 | |||
| adf13ae47c | |||
| 6c62d4bce4 | |||
| 000a56295f | |||
| bbd4f0e266 | |||
| 423132699e | |||
| 505777a40e | |||
| 3dccd16757 | |||
| e19dba594c | |||
| 73154aad08 | |||
| 28ec64f8e6 | |||
| 99b014190d | |||
| df7e74b10e | |||
| 51fb757143 | |||
| d4783d7438 | |||
| 195483b3e1 | |||
| e01404f18e | |||
| 8d117f7f97 | |||
| 0c14b89125 | |||
| d2aa860bc3 | |||
| e86c5e183c | |||
| 2553894db4 | |||
| 87deb5d9f2 | |||
| b31ffc1c83 | |||
| e55f84dd97 | |||
| 657442249a | |||
| 24b69cf72f | |||
| a76be6e871 | |||
| 4c7d063a94 | |||
| 401a6dafc8 | |||
| 95744da9c7 | |||
| 15fc0f9171 | |||
| 9ee49cea49 | |||
| 53106c8760 | |||
| e7fe4a959f | |||
| 5b3e7f5bae | |||
| 76c3509118 | |||
| 0c202ac284 | |||
| b2e36227b6 | |||
| 230a9ad260 | |||
| ce9d1cff19 | |||
| 7d42eec98c | |||
| 677b860395 | |||
| 849a5e40e4 | |||
| 65aa5980ac | |||
| 87dda2a8aa | |||
| c5b4cff07e | |||
| e4a860db01 | |||
| 0ff7aecfa2 | |||
| 0da31b468c | |||
| 252f8a294f | |||
| 09a202324e | |||
| 44660190da | |||
| eefb7b2f5c | |||
| bf85a2efa8 | |||
| aa45062bd7 | |||
| bfc43964d8 | |||
| fd55082282 | |||
| 78bf2031b8 | |||
| bbff0c238d | |||
| 34b26eedd6 | |||
| 193a44f472 |
@@ -0,0 +1,16 @@
|
|||||||
|
# 项目说明
|
||||||
|
|
||||||
|
## 构建与测试环境
|
||||||
|
|
||||||
|
- 开发设备:macOS
|
||||||
|
- Xcode 版本:26.3
|
||||||
|
- 主 App Deployment Target:iOS 26.0
|
||||||
|
- 可用的 iOS 模拟器:**iPhone 17 Pro**
|
||||||
|
|
||||||
|
## 常用命令
|
||||||
|
|
||||||
|
### 编译主 App(iPhone 17 Pro 模拟器)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
xcodebuild -scheme Note -destination 'platform=iOS Simulator,name=iPhone 17 Pro' build
|
||||||
|
```
|
||||||
+270
-97
@@ -6,20 +6,84 @@
|
|||||||
objectVersion = 77;
|
objectVersion = 77;
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
CFD40B353003C283009C9F2A /* NoteShareExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = CFD40B283003C283009C9F2A /* NoteShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXContainerItemProxy section */
|
||||||
|
CFD40B313003C283009C9F2A /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = CFD40B083003C283009C9F2A /* Project object */;
|
||||||
|
proxyType = 1;
|
||||||
|
remoteGlobalIDString = CFD40B293003C283009C9F2A;
|
||||||
|
remoteInfo = NoteShareExtension;
|
||||||
|
};
|
||||||
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
|
CFD40B2F3003C283009C9F2A /* Embed Foundation Extensions */ = {
|
||||||
|
isa = PBXCopyFilesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
dstPath = "";
|
||||||
|
dstSubfolderSpec = 16;
|
||||||
|
files = (
|
||||||
|
CFD40B353003C283009C9F2A /* NoteShareExtension.appex in Embed Foundation Extensions */,
|
||||||
|
);
|
||||||
|
name = "Embed Foundation Extensions";
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
CFD3A62F30037B20001170B3 /* Note.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Note.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
CFD40B103003C283009C9F2A /* Note.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Note.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
CFD40B283003C283009C9F2A /* NoteShareExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = NoteShareExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||||
|
CFD40B223003C284009C9F2A /* Exceptions for "Note" folder in "Note" target */ = {
|
||||||
|
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||||
|
membershipExceptions = (
|
||||||
|
Info.plist,
|
||||||
|
);
|
||||||
|
target = CFD40B0F3003C283009C9F2A /* Note */;
|
||||||
|
};
|
||||||
|
CFD40B2E3003C283009C9F2A /* Exceptions for "NoteShareExtension" folder in "NoteShareExtension" target */ = {
|
||||||
|
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||||
|
membershipExceptions = (
|
||||||
|
Info.plist,
|
||||||
|
);
|
||||||
|
target = CFD40B293003C283009C9F2A /* NoteShareExtension */;
|
||||||
|
};
|
||||||
|
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||||
|
|
||||||
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
||||||
CFD3A63130037B20001170B3 /* Note */ = {
|
CFD40B123003C283009C9F2A /* Note */ = {
|
||||||
isa = PBXFileSystemSynchronizedRootGroup;
|
isa = PBXFileSystemSynchronizedRootGroup;
|
||||||
|
exceptions = (
|
||||||
|
CFD40B223003C284009C9F2A /* Exceptions for "Note" folder in "Note" target */,
|
||||||
|
);
|
||||||
path = Note;
|
path = Note;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
CFD40B2D3003C283009C9F2A /* NoteShareExtension */ = {
|
||||||
|
isa = PBXFileSystemSynchronizedRootGroup;
|
||||||
|
exceptions = (
|
||||||
|
CFD40B2E3003C283009C9F2A /* Exceptions for "NoteShareExtension" folder in "NoteShareExtension" target */,
|
||||||
|
);
|
||||||
|
path = NoteShareExtension;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
/* End PBXFileSystemSynchronizedRootGroup section */
|
/* End PBXFileSystemSynchronizedRootGroup section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
CFD3A62C30037B20001170B3 /* Frameworks */ = {
|
CFD40B0D3003C283009C9F2A /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
CFD40B323003C283009C9F2A /* Frameworks */ = {
|
||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
@@ -29,18 +93,20 @@
|
|||||||
/* End PBXFrameworksBuildPhase section */
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXGroup section */
|
/* Begin PBXGroup section */
|
||||||
CFD3A62630037B20001170B3 = {
|
CFD40B073003C283009C9F2A = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
CFD3A63130037B20001170B3 /* Note */,
|
CFD40B123003C283009C9F2A /* Note */,
|
||||||
CFD3A63030037B20001170B3 /* Products */,
|
CFD40B2D3003C283009C9F2A /* NoteShareExtension */,
|
||||||
|
CFD40B113003C283009C9F2A /* Products */,
|
||||||
);
|
);
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
CFD3A63030037B20001170B3 /* Products */ = {
|
CFD40B113003C283009C9F2A /* Products */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
CFD3A62F30037B20001170B3 /* Note.app */,
|
CFD40B103003C283009C9F2A /* Note.app */,
|
||||||
|
CFD40B283003C283009C9F2A /* NoteShareExtension.appex */,
|
||||||
);
|
);
|
||||||
name = Products;
|
name = Products;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -48,64 +114,100 @@
|
|||||||
/* End PBXGroup section */
|
/* End PBXGroup section */
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
/* Begin PBXNativeTarget section */
|
||||||
CFD3A62E30037B20001170B3 /* Note */ = {
|
CFD40B0F3003C283009C9F2A /* Note */ = {
|
||||||
isa = PBXNativeTarget;
|
isa = PBXNativeTarget;
|
||||||
buildConfigurationList = CFD3A63A30037B21001170B3 /* Build configuration list for PBXNativeTarget "Note" */;
|
buildConfigurationList = CFD40B233003C284009C9F2A /* Build configuration list for PBXNativeTarget "Note" */;
|
||||||
buildPhases = (
|
buildPhases = (
|
||||||
CFD3A62B30037B20001170B3 /* Sources */,
|
CFD40B0C3003C283009C9F2A /* Sources */,
|
||||||
CFD3A62C30037B20001170B3 /* Frameworks */,
|
CFD40B0D3003C283009C9F2A /* Frameworks */,
|
||||||
CFD3A62D30037B20001170B3 /* Resources */,
|
CFD40B0E3003C283009C9F2A /* Resources */,
|
||||||
|
CFD40B2F3003C283009C9F2A /* Embed Foundation Extensions */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
CFD40B303003C283009C9F2A /* PBXTargetDependency */,
|
||||||
|
);
|
||||||
|
fileSystemSynchronizedGroups = (
|
||||||
|
CFD40B123003C283009C9F2A /* Note */,
|
||||||
|
);
|
||||||
|
name = Note;
|
||||||
|
packageProductDependencies = (
|
||||||
|
);
|
||||||
|
productName = Note;
|
||||||
|
productReference = CFD40B103003C283009C9F2A /* Note.app */;
|
||||||
|
productType = "com.apple.product-type.application";
|
||||||
|
};
|
||||||
|
CFD40B293003C283009C9F2A /* NoteShareExtension */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = CFD40B2A3003C283009C9F2A /* Build configuration list for PBXNativeTarget "NoteShareExtension" */;
|
||||||
|
buildPhases = (
|
||||||
|
CFD40B333003C283009C9F2A /* Sources */,
|
||||||
|
CFD40B343003C283009C9F2A /* Resources */,
|
||||||
|
CFD40B323003C283009C9F2A /* Frameworks */,
|
||||||
);
|
);
|
||||||
buildRules = (
|
buildRules = (
|
||||||
);
|
);
|
||||||
dependencies = (
|
dependencies = (
|
||||||
);
|
);
|
||||||
fileSystemSynchronizedGroups = (
|
fileSystemSynchronizedGroups = (
|
||||||
CFD3A63130037B20001170B3 /* Note */,
|
CFD40B2D3003C283009C9F2A /* NoteShareExtension */,
|
||||||
);
|
);
|
||||||
name = Note;
|
name = NoteShareExtension;
|
||||||
packageProductDependencies = (
|
packageProductDependencies = (
|
||||||
);
|
);
|
||||||
productName = Note;
|
productName = NoteShareExtension;
|
||||||
productReference = CFD3A62F30037B20001170B3 /* Note.app */;
|
productReference = CFD40B283003C283009C9F2A /* NoteShareExtension.appex */;
|
||||||
productType = "com.apple.product-type.application";
|
productType = "com.apple.product-type.app-extension";
|
||||||
};
|
};
|
||||||
/* End PBXNativeTarget section */
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
/* Begin PBXProject section */
|
/* Begin PBXProject section */
|
||||||
CFD3A62730037B20001170B3 /* Project object */ = {
|
CFD40B083003C283009C9F2A /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
BuildIndependentTargetsInParallel = 1;
|
BuildIndependentTargetsInParallel = 1;
|
||||||
LastSwiftUpdateCheck = 2630;
|
LastSwiftUpdateCheck = 2630;
|
||||||
LastUpgradeCheck = 2630;
|
LastUpgradeCheck = 2630;
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
CFD3A62E30037B20001170B3 = {
|
CFD40B0F3003C283009C9F2A = {
|
||||||
|
CreatedOnToolsVersion = 26.3;
|
||||||
|
};
|
||||||
|
CFD40B293003C283009C9F2A = {
|
||||||
CreatedOnToolsVersion = 26.3;
|
CreatedOnToolsVersion = 26.3;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
buildConfigurationList = CFD3A62A30037B20001170B3 /* Build configuration list for PBXProject "Note" */;
|
buildConfigurationList = CFD40B0B3003C283009C9F2A /* Build configuration list for PBXProject "Note" */;
|
||||||
developmentRegion = en;
|
developmentRegion = en;
|
||||||
hasScannedForEncodings = 0;
|
hasScannedForEncodings = 0;
|
||||||
knownRegions = (
|
knownRegions = (
|
||||||
en,
|
en,
|
||||||
Base,
|
Base,
|
||||||
|
"zh-Hans",
|
||||||
);
|
);
|
||||||
mainGroup = CFD3A62630037B20001170B3;
|
mainGroup = CFD40B073003C283009C9F2A;
|
||||||
minimizedProjectReferenceProxies = 1;
|
minimizedProjectReferenceProxies = 1;
|
||||||
preferredProjectObjectVersion = 77;
|
preferredProjectObjectVersion = 77;
|
||||||
productRefGroup = CFD3A63030037B20001170B3 /* Products */;
|
productRefGroup = CFD40B113003C283009C9F2A /* Products */;
|
||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
projectRoot = "";
|
projectRoot = "";
|
||||||
targets = (
|
targets = (
|
||||||
CFD3A62E30037B20001170B3 /* Note */,
|
CFD40B0F3003C283009C9F2A /* Note */,
|
||||||
|
CFD40B293003C283009C9F2A /* NoteShareExtension */,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
/* End PBXProject section */
|
/* End PBXProject section */
|
||||||
|
|
||||||
/* Begin PBXResourcesBuildPhase section */
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
CFD3A62D30037B20001170B3 /* Resources */ = {
|
CFD40B0E3003C283009C9F2A /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
CFD40B343003C283009C9F2A /* Resources */ = {
|
||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
@@ -115,7 +217,14 @@
|
|||||||
/* End PBXResourcesBuildPhase section */
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXSourcesBuildPhase section */
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
CFD3A62B30037B20001170B3 /* Sources */ = {
|
CFD40B0C3003C283009C9F2A /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
CFD40B333003C283009C9F2A /* Sources */ = {
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
@@ -124,8 +233,84 @@
|
|||||||
};
|
};
|
||||||
/* End PBXSourcesBuildPhase section */
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXTargetDependency section */
|
||||||
|
CFD40B303003C283009C9F2A /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
target = CFD40B293003C283009C9F2A /* NoteShareExtension */;
|
||||||
|
targetProxy = CFD40B313003C283009C9F2A /* PBXContainerItemProxy */;
|
||||||
|
};
|
||||||
|
/* End PBXTargetDependency section */
|
||||||
|
|
||||||
/* Begin XCBuildConfiguration section */
|
/* Begin XCBuildConfiguration section */
|
||||||
CFD3A63830037B21001170B3 /* Debug */ = {
|
CFD40B243003C284009C9F2A /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = Note/Note.entitlements;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
DEVELOPMENT_TEAM = 37HGUEC495;
|
||||||
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
INFOPLIST_FILE = Note/Info.plist;
|
||||||
|
INFOPLIST_KEY_CFBundleDisplayName = "备忘录格式化助手";
|
||||||
|
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||||
|
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
|
||||||
|
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
|
||||||
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 26.0;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
MARKETING_VERSION = 1.0.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.fishestlife.note;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||||
|
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
||||||
|
SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor;
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
CFD40B253003C284009C9F2A /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = Note/Note.entitlements;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
DEVELOPMENT_TEAM = 37HGUEC495;
|
||||||
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
INFOPLIST_FILE = Note/Info.plist;
|
||||||
|
INFOPLIST_KEY_CFBundleDisplayName = "备忘录格式化助手";
|
||||||
|
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||||
|
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
|
||||||
|
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
|
||||||
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 26.0;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
MARKETING_VERSION = 1.0.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.fishestlife.note;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||||
|
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
||||||
|
SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor;
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
CFD40B263003C284009C9F2A /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
@@ -178,16 +363,18 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 26.2;
|
||||||
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
CFD3A63930037B21001170B3 /* Release */ = {
|
CFD40B273003C284009C9F2A /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
@@ -234,123 +421,109 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 26.2;
|
||||||
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
SWIFT_COMPILATION_MODE = wholemodule;
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
|
VALIDATE_PRODUCT = YES;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
CFD3A63B30037B21001170B3 /* Debug */ = {
|
CFD40B2B3003C283009C9F2A /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = NoteShareExtension/NoteShareExtension.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_TEAM = 37HGUEC495;
|
DEVELOPMENT_TEAM = 37HGUEC495;
|
||||||
ENABLE_APP_SANDBOX = YES;
|
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
|
||||||
ENABLE_PREVIEWS = YES;
|
|
||||||
ENABLE_USER_SELECTED_FILES = readonly;
|
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
|
INFOPLIST_FILE = NoteShareExtension/Info.plist;
|
||||||
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
|
INFOPLIST_KEY_CFBundleDisplayName = "备忘录格式化助手";
|
||||||
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES;
|
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||||
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES;
|
|
||||||
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES;
|
|
||||||
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES;
|
|
||||||
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault;
|
|
||||||
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
|
|
||||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
|
||||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 26.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 26.0;
|
||||||
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
|
"$(inherited)",
|
||||||
MACOSX_DEPLOYMENT_TARGET = 26.0;
|
"@executable_path/Frameworks",
|
||||||
MARKETING_VERSION = 1.0;
|
"@executable_path/../../Frameworks",
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.fishestlife.note.Note;
|
);
|
||||||
|
MARKETING_VERSION = 1.0.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.fishestlife.note.share;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
REGISTER_APP_GROUPS = YES;
|
SKIP_INSTALL = YES;
|
||||||
SDKROOT = auto;
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
|
||||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
|
||||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
|
|
||||||
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
|
||||||
SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor;
|
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2,7";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
XROS_DEPLOYMENT_TARGET = 26.0;
|
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
CFD3A63C30037B21001170B3 /* Release */ = {
|
CFD40B2C3003C283009C9F2A /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = NoteShareExtension/NoteShareExtension.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_TEAM = 37HGUEC495;
|
DEVELOPMENT_TEAM = 37HGUEC495;
|
||||||
ENABLE_APP_SANDBOX = YES;
|
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
|
||||||
ENABLE_PREVIEWS = YES;
|
|
||||||
ENABLE_USER_SELECTED_FILES = readonly;
|
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
|
INFOPLIST_FILE = NoteShareExtension/Info.plist;
|
||||||
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
|
INFOPLIST_KEY_CFBundleDisplayName = "备忘录格式化助手";
|
||||||
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES;
|
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||||
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES;
|
|
||||||
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES;
|
|
||||||
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES;
|
|
||||||
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault;
|
|
||||||
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
|
|
||||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
|
||||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 26.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 26.0;
|
||||||
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
|
"$(inherited)",
|
||||||
MACOSX_DEPLOYMENT_TARGET = 26.0;
|
"@executable_path/Frameworks",
|
||||||
MARKETING_VERSION = 1.0;
|
"@executable_path/../../Frameworks",
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.fishestlife.note.Note;
|
);
|
||||||
|
MARKETING_VERSION = 1.0.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.fishestlife.note.share;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
REGISTER_APP_GROUPS = YES;
|
SKIP_INSTALL = YES;
|
||||||
SDKROOT = auto;
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
|
||||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
|
|
||||||
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
|
||||||
SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor;
|
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2,7";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
XROS_DEPLOYMENT_TARGET = 26.0;
|
VALIDATE_PRODUCT = YES;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
/* End XCBuildConfiguration section */
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
/* Begin XCConfigurationList section */
|
/* Begin XCConfigurationList section */
|
||||||
CFD3A62A30037B20001170B3 /* Build configuration list for PBXProject "Note" */ = {
|
CFD40B0B3003C283009C9F2A /* Build configuration list for PBXProject "Note" */ = {
|
||||||
isa = XCConfigurationList;
|
isa = XCConfigurationList;
|
||||||
buildConfigurations = (
|
buildConfigurations = (
|
||||||
CFD3A63830037B21001170B3 /* Debug */,
|
CFD40B263003C284009C9F2A /* Debug */,
|
||||||
CFD3A63930037B21001170B3 /* Release */,
|
CFD40B273003C284009C9F2A /* Release */,
|
||||||
);
|
);
|
||||||
defaultConfigurationIsVisible = 0;
|
defaultConfigurationIsVisible = 0;
|
||||||
defaultConfigurationName = Release;
|
defaultConfigurationName = Release;
|
||||||
};
|
};
|
||||||
CFD3A63A30037B21001170B3 /* Build configuration list for PBXNativeTarget "Note" */ = {
|
CFD40B233003C284009C9F2A /* Build configuration list for PBXNativeTarget "Note" */ = {
|
||||||
isa = XCConfigurationList;
|
isa = XCConfigurationList;
|
||||||
buildConfigurations = (
|
buildConfigurations = (
|
||||||
CFD3A63B30037B21001170B3 /* Debug */,
|
CFD40B243003C284009C9F2A /* Debug */,
|
||||||
CFD3A63C30037B21001170B3 /* Release */,
|
CFD40B253003C284009C9F2A /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
CFD40B2A3003C283009C9F2A /* Build configuration list for PBXNativeTarget "NoteShareExtension" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
CFD40B2B3003C283009C9F2A /* Debug */,
|
||||||
|
CFD40B2C3003C283009C9F2A /* Release */,
|
||||||
);
|
);
|
||||||
defaultConfigurationIsVisible = 0;
|
defaultConfigurationIsVisible = 0;
|
||||||
defaultConfigurationName = Release;
|
defaultConfigurationName = Release;
|
||||||
};
|
};
|
||||||
/* End XCConfigurationList section */
|
/* End XCConfigurationList section */
|
||||||
};
|
};
|
||||||
rootObject = CFD3A62730037B20001170B3 /* Project object */;
|
rootObject = CFD40B083003C283009C9F2A /* Project object */;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "2630"
|
||||||
|
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 = "CFD40B0F3003C283009C9F2A"
|
||||||
|
BuildableName = "Note.app"
|
||||||
|
BlueprintName = "Note"
|
||||||
|
ReferencedContainer = "container:Note.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 = "CFD40B0F3003C283009C9F2A"
|
||||||
|
BuildableName = "Note.app"
|
||||||
|
BlueprintName = "Note"
|
||||||
|
ReferencedContainer = "container:Note.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "CFD40B0F3003C283009C9F2A"
|
||||||
|
BuildableName = "Note.app"
|
||||||
|
BlueprintName = "Note"
|
||||||
|
ReferencedContainer = "container:Note.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "2630"
|
||||||
|
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 = "CFD40B293003C283009C9F2A"
|
||||||
|
BuildableName = "NoteShareExtension.appex"
|
||||||
|
BlueprintName = "NoteShareExtension"
|
||||||
|
ReferencedContainer = "container:Note.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "CFD40B0F3003C283009C9F2A"
|
||||||
|
BuildableName = "Note.app"
|
||||||
|
BlueprintName = "Note"
|
||||||
|
ReferencedContainer = "container:Note.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">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "CFD40B0F3003C283009C9F2A"
|
||||||
|
BuildableName = "Note.app"
|
||||||
|
BlueprintName = "Note"
|
||||||
|
ReferencedContainer = "container:Note.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
askForAppToLaunch = "Yes"
|
||||||
|
launchAutomaticallySubstyle = "2">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "CFD40B0F3003C283009C9F2A"
|
||||||
|
BuildableName = "Note.app"
|
||||||
|
BlueprintName = "Note"
|
||||||
|
ReferencedContainer = "container:Note.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
//
|
||||||
|
// AppDelegate.swift
|
||||||
|
// Note
|
||||||
|
//
|
||||||
|
// Created by fish on 2026/7/12.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
@main
|
||||||
|
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||||
|
// Override point for customization after application launch.
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: UISceneSession Lifecycle
|
||||||
|
|
||||||
|
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
||||||
|
// Called when a new scene session is being created.
|
||||||
|
// Use this method to select a configuration to create the new scene with.
|
||||||
|
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
||||||
|
}
|
||||||
|
|
||||||
|
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
|
||||||
|
// Called when the user discards a scene session.
|
||||||
|
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
|
||||||
|
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"images" : [
|
"images" : [
|
||||||
{
|
{
|
||||||
"filename" : "note_app_logo_appstore.png",
|
"filename" : "note_app_logo_full.png",
|
||||||
"idiom" : "universal",
|
"idiom" : "universal",
|
||||||
"platform" : "ios",
|
"platform" : "ios",
|
||||||
"size" : "1024x1024"
|
"size" : "1024x1024"
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"value" : "dark"
|
"value" : "dark"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"filename" : "note_app_logo_appstore 1.png",
|
"filename" : "note_app_logo_full 1.png",
|
||||||
"idiom" : "universal",
|
"idiom" : "universal",
|
||||||
"platform" : "ios",
|
"platform" : "ios",
|
||||||
"size" : "1024x1024"
|
"size" : "1024x1024"
|
||||||
@@ -25,60 +25,10 @@
|
|||||||
"value" : "tinted"
|
"value" : "tinted"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"filename" : "note_app_logo_appstore 2.png",
|
"filename" : "note_app_logo_full 2.png",
|
||||||
"idiom" : "universal",
|
"idiom" : "universal",
|
||||||
"platform" : "ios",
|
"platform" : "ios",
|
||||||
"size" : "1024x1024"
|
"size" : "1024x1024"
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "mac",
|
|
||||||
"scale" : "1x",
|
|
||||||
"size" : "16x16"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "mac",
|
|
||||||
"scale" : "2x",
|
|
||||||
"size" : "16x16"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "mac",
|
|
||||||
"scale" : "1x",
|
|
||||||
"size" : "32x32"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "mac",
|
|
||||||
"scale" : "2x",
|
|
||||||
"size" : "32x32"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "mac",
|
|
||||||
"scale" : "1x",
|
|
||||||
"size" : "128x128"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "mac",
|
|
||||||
"scale" : "2x",
|
|
||||||
"size" : "128x128"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "mac",
|
|
||||||
"scale" : "1x",
|
|
||||||
"size" : "256x256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "mac",
|
|
||||||
"scale" : "2x",
|
|
||||||
"size" : "256x256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "mac",
|
|
||||||
"scale" : "1x",
|
|
||||||
"size" : "512x512"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "mac",
|
|
||||||
"scale" : "2x",
|
|
||||||
"size" : "512x512"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info" : {
|
"info" : {
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.8 KiB |
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||||
|
<dependencies>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
|
||||||
|
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||||
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
|
</dependencies>
|
||||||
|
<scenes>
|
||||||
|
<!--View Controller-->
|
||||||
|
<scene sceneID="EHf-IW-A2E">
|
||||||
|
<objects>
|
||||||
|
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||||
|
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||||
|
</view>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="53" y="375"/>
|
||||||
|
</scene>
|
||||||
|
</scenes>
|
||||||
|
</document>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
|
||||||
|
<dependencies>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
|
||||||
|
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||||
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
|
</dependencies>
|
||||||
|
<scenes>
|
||||||
|
<!--View Controller-->
|
||||||
|
<scene sceneID="tne-QT-ifu">
|
||||||
|
<objects>
|
||||||
|
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||||
|
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||||
|
</view>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
</scene>
|
||||||
|
</scenes>
|
||||||
|
</document>
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
//
|
||||||
|
// ClipEditViewController.swift
|
||||||
|
// Note
|
||||||
|
//
|
||||||
|
// Created by Kimi Code CLI on 2026/7/15.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
class ClipEditViewController: UIViewController {
|
||||||
|
|
||||||
|
private var textView: UITextView!
|
||||||
|
private var floatingDoneButton: UIButton!
|
||||||
|
private var floatingDoneButtonBottomConstraint: NSLayoutConstraint!
|
||||||
|
private var clip: Clip
|
||||||
|
|
||||||
|
init(clip: Clip) {
|
||||||
|
self.clip = clip
|
||||||
|
super.init(nibName: nil, bundle: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
title = "编辑文案"
|
||||||
|
navigationItem.largeTitleDisplayMode = .never
|
||||||
|
view.backgroundColor = .systemGroupedBackground
|
||||||
|
|
||||||
|
setupNavigationBar()
|
||||||
|
setupTextView()
|
||||||
|
setupKeyboardObservers()
|
||||||
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
NotificationCenter.default.removeObserver(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setupKeyboardObservers() {
|
||||||
|
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
|
||||||
|
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func keyboardWillShow(_ notification: Notification) {
|
||||||
|
guard let keyboardFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return }
|
||||||
|
let keyboardFrameInView = view.convert(keyboardFrame, from: nil)
|
||||||
|
let intersection = keyboardFrameInView.intersection(view.bounds)
|
||||||
|
let keyboardHeight = intersection.height
|
||||||
|
|
||||||
|
let duration = notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? TimeInterval ?? 0.25
|
||||||
|
|
||||||
|
UIView.animate(withDuration: duration, delay: 0, options: .beginFromCurrentState) {
|
||||||
|
self.textView.contentInset.bottom = keyboardHeight
|
||||||
|
self.textView.verticalScrollIndicatorInsets.bottom = keyboardHeight
|
||||||
|
self.floatingDoneButtonBottomConstraint.constant = -(keyboardHeight + 8)
|
||||||
|
self.floatingDoneButton.alpha = 1
|
||||||
|
self.view.layoutIfNeeded()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func keyboardWillHide(_ notification: Notification) {
|
||||||
|
let duration = notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? TimeInterval ?? 0.25
|
||||||
|
|
||||||
|
UIView.animate(withDuration: duration, delay: 0, options: .beginFromCurrentState) {
|
||||||
|
self.textView.contentInset.bottom = 0
|
||||||
|
self.textView.verticalScrollIndicatorInsets.bottom = 0
|
||||||
|
self.floatingDoneButtonBottomConstraint.constant = -16
|
||||||
|
self.floatingDoneButton.alpha = 0
|
||||||
|
self.view.layoutIfNeeded()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewDidAppear(_ animated: Bool) {
|
||||||
|
super.viewDidAppear(animated)
|
||||||
|
textView.becomeFirstResponder()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setupNavigationBar() {
|
||||||
|
let saveButton = UIBarButtonItem(
|
||||||
|
title: "保存",
|
||||||
|
style: .prominent,
|
||||||
|
target: self,
|
||||||
|
action: #selector(didTapSaveButton)
|
||||||
|
)
|
||||||
|
navigationItem.rightBarButtonItem = saveButton
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setupTextView() {
|
||||||
|
textView = UITextView()
|
||||||
|
textView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
textView.backgroundColor = UIColor { traitCollection in
|
||||||
|
traitCollection.userInterfaceStyle == .dark ? .secondarySystemBackground : .white
|
||||||
|
}
|
||||||
|
textView.layer.cornerRadius = 12
|
||||||
|
textView.layer.borderWidth = 0.5
|
||||||
|
textView.layer.borderColor = UIColor.separator.cgColor
|
||||||
|
textView.layer.masksToBounds = true
|
||||||
|
textView.font = UIFont.preferredFont(forTextStyle: .body)
|
||||||
|
textView.textContainerInset = UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12)
|
||||||
|
textView.text = clip.text
|
||||||
|
view.addSubview(textView)
|
||||||
|
|
||||||
|
var doneConfig = UIButton.Configuration.glass()
|
||||||
|
doneConfig.title = "完成"
|
||||||
|
doneConfig.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
|
||||||
|
var outgoing = incoming
|
||||||
|
outgoing.font = UIFont.systemFont(ofSize: 17, weight: .semibold)
|
||||||
|
return outgoing
|
||||||
|
}
|
||||||
|
doneConfig.baseForegroundColor = .label
|
||||||
|
doneConfig.cornerStyle = .capsule
|
||||||
|
doneConfig.contentInsets = NSDirectionalEdgeInsets(top: 15, leading: 22, bottom: 15, trailing: 22)
|
||||||
|
floatingDoneButton = UIButton(configuration: doneConfig)
|
||||||
|
floatingDoneButton.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
floatingDoneButton.alpha = 0
|
||||||
|
floatingDoneButton.addTarget(self, action: #selector(didTapFloatingDoneButton), for: .touchUpInside)
|
||||||
|
view.addSubview(floatingDoneButton)
|
||||||
|
|
||||||
|
let safeArea = view.safeAreaLayoutGuide
|
||||||
|
floatingDoneButtonBottomConstraint = floatingDoneButton.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -16)
|
||||||
|
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
textView.topAnchor.constraint(equalTo: safeArea.topAnchor, constant: 16),
|
||||||
|
textView.leadingAnchor.constraint(equalTo: safeArea.leadingAnchor, constant: 16),
|
||||||
|
textView.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor, constant: -16),
|
||||||
|
textView.bottomAnchor.constraint(equalTo: safeArea.bottomAnchor, constant: -16),
|
||||||
|
|
||||||
|
floatingDoneButton.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor, constant: -16),
|
||||||
|
floatingDoneButtonBottomConstraint
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapFloatingDoneButton() {
|
||||||
|
textView.resignFirstResponder()
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapSaveButton() {
|
||||||
|
let updatedText = textView.text ?? ""
|
||||||
|
guard !updatedText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
||||||
|
let alert = UIAlertController(title: "提示", message: "文案不能为空。", preferredStyle: .alert)
|
||||||
|
alert.addAction(UIAlertAction(title: "确定", style: .default))
|
||||||
|
present(alert, animated: true)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var updatedClip = clip
|
||||||
|
updatedClip.text = updatedText
|
||||||
|
|
||||||
|
Task {
|
||||||
|
do {
|
||||||
|
try await ClipStore.shared.update(updatedClip)
|
||||||
|
_ = await MainActor.run {
|
||||||
|
self.navigationController?.popViewController(animated: true)
|
||||||
|
return ()
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
await MainActor.run {
|
||||||
|
let alert = UIAlertController(title: "提示", message: "保存失败: \(error.localizedDescription)", preferredStyle: .alert)
|
||||||
|
alert.addAction(UIAlertAction(title: "确定", style: .default))
|
||||||
|
self.present(alert, animated: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,290 @@
|
|||||||
|
//
|
||||||
|
// ClipInboxViewController.swift
|
||||||
|
// Note
|
||||||
|
//
|
||||||
|
// Created by Kimi Code CLI on 2026/7/15.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
class ClipInboxViewController: UIViewController {
|
||||||
|
|
||||||
|
private var tableView: UITableView!
|
||||||
|
private var emptyLabel: UILabel!
|
||||||
|
private var archiveButton: UIButton!
|
||||||
|
private var clips: [Clip] = []
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
title = "收集箱"
|
||||||
|
navigationItem.largeTitleDisplayMode = .never
|
||||||
|
view.backgroundColor = .systemGroupedBackground
|
||||||
|
|
||||||
|
setupNavigationBar()
|
||||||
|
setupArchiveButton()
|
||||||
|
setupTableView()
|
||||||
|
setupEmptyLabel()
|
||||||
|
setupAppStateObserver()
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
|
super.viewWillAppear(animated)
|
||||||
|
loadClips()
|
||||||
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
NotificationCenter.default.removeObserver(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setupAppStateObserver() {
|
||||||
|
NotificationCenter.default.addObserver(
|
||||||
|
self,
|
||||||
|
selector: #selector(appDidBecomeActive),
|
||||||
|
name: UIApplication.didBecomeActiveNotification,
|
||||||
|
object: nil
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func appDidBecomeActive() {
|
||||||
|
loadClips()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setupNavigationBar() {
|
||||||
|
let clearButton = UIBarButtonItem(
|
||||||
|
title: "清空",
|
||||||
|
style: .plain,
|
||||||
|
target: self,
|
||||||
|
action: #selector(didTapClearButton)
|
||||||
|
)
|
||||||
|
clearButton.tintColor = .systemRed
|
||||||
|
navigationItem.rightBarButtonItem = clearButton
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setupTableView() {
|
||||||
|
tableView = UITableView(frame: .zero, style: .insetGrouped)
|
||||||
|
tableView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
tableView.delegate = self
|
||||||
|
tableView.dataSource = self
|
||||||
|
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "clipCell")
|
||||||
|
tableView.backgroundColor = .systemGroupedBackground
|
||||||
|
view.addSubview(tableView)
|
||||||
|
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
tableView.topAnchor.constraint(equalTo: view.topAnchor),
|
||||||
|
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||||
|
tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
||||||
|
tableView.bottomAnchor.constraint(equalTo: archiveButton.topAnchor, constant: -16)
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setupArchiveButton() {
|
||||||
|
var config = UIButton.Configuration.filled()
|
||||||
|
config.title = "归档"
|
||||||
|
config.baseBackgroundColor = .systemBlue
|
||||||
|
config.baseForegroundColor = .white
|
||||||
|
config.cornerStyle = .medium
|
||||||
|
config.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16)
|
||||||
|
|
||||||
|
archiveButton = UIButton(configuration: config)
|
||||||
|
archiveButton.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
archiveButton.addTarget(self, action: #selector(didTapArchiveButton), for: .touchUpInside)
|
||||||
|
view.addSubview(archiveButton)
|
||||||
|
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
archiveButton.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 16),
|
||||||
|
archiveButton.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -16),
|
||||||
|
archiveButton.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -16),
|
||||||
|
archiveButton.heightAnchor.constraint(equalToConstant: 52)
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapArchiveButton() {
|
||||||
|
guard clips.count >= 2 else {
|
||||||
|
let alert = UIAlertController(title: "提示", message: "至少需要两条文案才能归档。", preferredStyle: .alert)
|
||||||
|
alert.addAction(UIAlertAction(title: "确定", style: .default))
|
||||||
|
present(alert, animated: true)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let title = self.archiveTitle()
|
||||||
|
let itemsText = clips.map { "\($0.text)\n\n---" }.joined(separator: "\n\n")
|
||||||
|
let archivedText = "\(title)\n\n\(itemsText)"
|
||||||
|
let viewController = FormatNoteViewController()
|
||||||
|
viewController.initialText = archivedText
|
||||||
|
navigationController?.pushViewController(viewController, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func archiveTitle() -> String {
|
||||||
|
let dateFormatter = DateFormatter()
|
||||||
|
dateFormatter.locale = Locale(identifier: "zh_CN")
|
||||||
|
dateFormatter.dateFormat = "yyyy年MM月dd日"
|
||||||
|
let dateString = dateFormatter.string(from: Date())
|
||||||
|
let weekdays = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
|
||||||
|
let weekdayIndex = Calendar.current.component(.weekday, from: Date()) - 1
|
||||||
|
let weekday = (weekdayIndex >= 0 && weekdayIndex < weekdays.count) ? weekdays[weekdayIndex] : ""
|
||||||
|
return "【读书摘抄】\(dateString) \(weekday)"
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setupEmptyLabel() {
|
||||||
|
emptyLabel = UILabel()
|
||||||
|
emptyLabel.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
emptyLabel.text = "还没有保存的文案\n复制内容后运行快捷指令即可收藏"
|
||||||
|
emptyLabel.numberOfLines = 0
|
||||||
|
emptyLabel.textAlignment = .center
|
||||||
|
emptyLabel.textColor = .secondaryLabel
|
||||||
|
emptyLabel.font = UIFont.preferredFont(forTextStyle: .body)
|
||||||
|
emptyLabel.isHidden = true
|
||||||
|
view.addSubview(emptyLabel)
|
||||||
|
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
emptyLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||||
|
emptyLabel.centerYAnchor.constraint(equalTo: view.centerYAnchor),
|
||||||
|
emptyLabel.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor),
|
||||||
|
emptyLabel.trailingAnchor.constraint(equalTo: view.readableContentGuide.trailingAnchor)
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
private func loadClips() {
|
||||||
|
Task {
|
||||||
|
do {
|
||||||
|
clips = try await ClipStore.shared.loadAll()
|
||||||
|
await MainActor.run {
|
||||||
|
tableView.reloadData()
|
||||||
|
updateEmptyState()
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
await MainActor.run {
|
||||||
|
showError(message: "加载失败: \(error.localizedDescription)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func updateEmptyState() {
|
||||||
|
let isEmpty = clips.isEmpty
|
||||||
|
emptyLabel.isHidden = !isEmpty
|
||||||
|
tableView.isHidden = isEmpty
|
||||||
|
archiveButton.isHidden = isEmpty
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapClearButton() {
|
||||||
|
guard !clips.isEmpty else {
|
||||||
|
let alert = UIAlertController(title: "提示", message: "收集箱为空,没有可清空的内容。", preferredStyle: .alert)
|
||||||
|
alert.addAction(UIAlertAction(title: "确定", style: .default))
|
||||||
|
present(alert, animated: true)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let alert = UIAlertController(
|
||||||
|
title: "清空收集箱",
|
||||||
|
message: "确定要删除所有保存的文案吗?此操作不可撤销。",
|
||||||
|
preferredStyle: .alert
|
||||||
|
)
|
||||||
|
alert.addAction(UIAlertAction(title: "取消", style: .cancel))
|
||||||
|
alert.addAction(UIAlertAction(title: "清空", style: .destructive) { [weak self] _ in
|
||||||
|
self?.clearAllClips()
|
||||||
|
})
|
||||||
|
present(alert, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func clearAllClips() {
|
||||||
|
Task {
|
||||||
|
do {
|
||||||
|
try await ClipStore.shared.clearAll()
|
||||||
|
clips = []
|
||||||
|
await MainActor.run {
|
||||||
|
tableView.reloadData()
|
||||||
|
updateEmptyState()
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
await MainActor.run {
|
||||||
|
showError(message: "清空失败: \(error.localizedDescription)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func deleteClip(at indexPath: IndexPath) {
|
||||||
|
let clip = clips[indexPath.row]
|
||||||
|
Task {
|
||||||
|
do {
|
||||||
|
try await ClipStore.shared.delete(id: clip.id)
|
||||||
|
clips.remove(at: indexPath.row)
|
||||||
|
await MainActor.run {
|
||||||
|
tableView.deleteRows(at: [indexPath], with: .automatic)
|
||||||
|
updateEmptyState()
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
await MainActor.run {
|
||||||
|
showError(message: "删除失败: \(error.localizedDescription)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func openClip(_ clip: Clip) {
|
||||||
|
let viewController = ClipEditViewController(clip: clip)
|
||||||
|
navigationController?.pushViewController(viewController, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func showError(message: String) {
|
||||||
|
let alert = UIAlertController(title: "提示", message: message, preferredStyle: .alert)
|
||||||
|
alert.addAction(UIAlertAction(title: "确定", style: .default))
|
||||||
|
present(alert, animated: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ClipInboxViewController: UITableViewDataSource {
|
||||||
|
|
||||||
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||||
|
return clips.count
|
||||||
|
}
|
||||||
|
|
||||||
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||||
|
let cell = tableView.dequeueReusableCell(withIdentifier: "clipCell", for: indexPath)
|
||||||
|
let clip = clips[indexPath.row]
|
||||||
|
|
||||||
|
var config = cell.defaultContentConfiguration()
|
||||||
|
config.text = previewText(for: clip.text)
|
||||||
|
config.textProperties.numberOfLines = 0
|
||||||
|
config.secondaryText = formattedDate(clip.createdAt)
|
||||||
|
config.secondaryTextProperties.color = .secondaryLabel
|
||||||
|
config.textToSecondaryTextVerticalPadding = 12
|
||||||
|
cell.contentConfiguration = config
|
||||||
|
cell.accessoryType = .disclosureIndicator
|
||||||
|
|
||||||
|
return cell
|
||||||
|
}
|
||||||
|
|
||||||
|
private func previewText(for text: String) -> String {
|
||||||
|
let preview = text.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
if preview.isEmpty {
|
||||||
|
return "(无内容)"
|
||||||
|
}
|
||||||
|
return preview
|
||||||
|
}
|
||||||
|
|
||||||
|
private func formattedDate(_ date: Date) -> String {
|
||||||
|
let formatter = RelativeDateTimeFormatter()
|
||||||
|
formatter.unitsStyle = .short
|
||||||
|
return formatter.localizedString(for: date, relativeTo: Date())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ClipInboxViewController: UITableViewDelegate {
|
||||||
|
|
||||||
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||||
|
tableView.deselectRow(at: indexPath, animated: true)
|
||||||
|
let clip = clips[indexPath.row]
|
||||||
|
openClip(clip)
|
||||||
|
}
|
||||||
|
|
||||||
|
func tableView(_ tableView: UITableView,
|
||||||
|
trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
|
||||||
|
let deleteAction = UIContextualAction(style: .destructive, title: "删除") { [weak self] _, _, completion in
|
||||||
|
self?.deleteClip(at: indexPath)
|
||||||
|
completion(true)
|
||||||
|
}
|
||||||
|
return UISwipeActionsConfiguration(actions: [deleteAction])
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
//
|
||||||
|
// ClipStore.swift
|
||||||
|
// Note
|
||||||
|
//
|
||||||
|
// Created by Kimi Code CLI on 2026/7/15.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
struct Clip: Codable, Identifiable, Equatable, Sendable {
|
||||||
|
let id: UUID
|
||||||
|
var text: String
|
||||||
|
let createdAt: Date
|
||||||
|
var source: String?
|
||||||
|
|
||||||
|
nonisolated init(id: UUID = UUID(), text: String, createdAt: Date = Date(), source: String? = nil) {
|
||||||
|
self.id = id
|
||||||
|
self.text = text
|
||||||
|
self.createdAt = createdAt
|
||||||
|
self.source = source
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ClipStoreError: Error, LocalizedError {
|
||||||
|
case appGroupUnavailable
|
||||||
|
|
||||||
|
var errorDescription: String? {
|
||||||
|
switch self {
|
||||||
|
case .appGroupUnavailable:
|
||||||
|
return "无法访问 App Group 容器,请检查签名和 entitlements 配置。"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
actor ClipStore {
|
||||||
|
|
||||||
|
static let shared = ClipStore()
|
||||||
|
|
||||||
|
private let appGroupIdentifier = "group.com.fishestlife.note"
|
||||||
|
private let fileName = "clips.json"
|
||||||
|
private let subdirectory = "SharedFiles/Clips"
|
||||||
|
|
||||||
|
private var cachedClips: [Clip]?
|
||||||
|
|
||||||
|
private func fileURL() throws -> URL {
|
||||||
|
let fileManager = FileManager.default
|
||||||
|
guard let containerURL = fileManager.containerURL(forSecurityApplicationGroupIdentifier: appGroupIdentifier) else {
|
||||||
|
throw ClipStoreError.appGroupUnavailable
|
||||||
|
}
|
||||||
|
let directoryURL = containerURL.appendingPathComponent(subdirectory, isDirectory: true)
|
||||||
|
try fileManager.createDirectory(at: directoryURL, withIntermediateDirectories: true)
|
||||||
|
return directoryURL.appendingPathComponent(fileName)
|
||||||
|
}
|
||||||
|
|
||||||
|
private init() {}
|
||||||
|
|
||||||
|
func save(text: String, source: String? = nil) async throws {
|
||||||
|
var clips = try await loadAll()
|
||||||
|
let clip = Clip(text: text, source: source)
|
||||||
|
clips.insert(clip, at: 0)
|
||||||
|
try await persist(clips)
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadAll() async throws -> [Clip] {
|
||||||
|
if let cached = cachedClips {
|
||||||
|
return cached
|
||||||
|
}
|
||||||
|
|
||||||
|
let url = try fileURL()
|
||||||
|
let fileManager = FileManager.default
|
||||||
|
guard fileManager.fileExists(atPath: url.path) else {
|
||||||
|
cachedClips = []
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
let data = try Data(contentsOf: url)
|
||||||
|
let clips = try JSONDecoder().decode([Clip].self, from: data)
|
||||||
|
cachedClips = clips
|
||||||
|
return clips
|
||||||
|
}
|
||||||
|
|
||||||
|
func update(_ clip: Clip) async throws {
|
||||||
|
var clips = try await loadAll()
|
||||||
|
guard let index = clips.firstIndex(where: { $0.id == clip.id }) else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
clips[index] = clip
|
||||||
|
try await persist(clips)
|
||||||
|
}
|
||||||
|
|
||||||
|
func delete(id: UUID) async throws {
|
||||||
|
var clips = try await loadAll()
|
||||||
|
clips.removeAll { $0.id == id }
|
||||||
|
try await persist(clips)
|
||||||
|
}
|
||||||
|
|
||||||
|
func clearAll() async throws {
|
||||||
|
try await persist([])
|
||||||
|
}
|
||||||
|
|
||||||
|
func count() async throws -> Int {
|
||||||
|
let clips = try await loadAll()
|
||||||
|
return clips.count
|
||||||
|
}
|
||||||
|
|
||||||
|
private func persist(_ clips: [Clip]) async throws {
|
||||||
|
let url = try fileURL()
|
||||||
|
let data = try JSONEncoder().encode(clips)
|
||||||
|
try data.write(to: url, options: .atomic)
|
||||||
|
cachedClips = clips
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
//
|
|
||||||
// ContentView.swift
|
|
||||||
// Note
|
|
||||||
//
|
|
||||||
// Created by fish on 2026/7/12.
|
|
||||||
//
|
|
||||||
|
|
||||||
import SwiftUI
|
|
||||||
|
|
||||||
struct ContentView: View {
|
|
||||||
var body: some View {
|
|
||||||
VStack {
|
|
||||||
Image(systemName: "globe")
|
|
||||||
.imageScale(.large)
|
|
||||||
.foregroundStyle(.tint)
|
|
||||||
Text("Hello, world!")
|
|
||||||
}
|
|
||||||
.padding()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#Preview {
|
|
||||||
ContentView()
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,268 @@
|
|||||||
|
//
|
||||||
|
// FormatLogViewController.swift
|
||||||
|
// Note
|
||||||
|
//
|
||||||
|
// Created by fish on 2026/7/12.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
class FormatLogViewController: UIViewController {
|
||||||
|
|
||||||
|
private var textView: UITextView!
|
||||||
|
private var formatButton: UIButton!
|
||||||
|
private var floatingDoneButton: UIButton!
|
||||||
|
private var floatingDoneButtonBottomConstraint: NSLayoutConstraint!
|
||||||
|
private var doneButton: UIBarButtonItem!
|
||||||
|
private var pasteButton: UIBarButtonItem!
|
||||||
|
private var resetButton: UIBarButtonItem!
|
||||||
|
private var isFormatted = false
|
||||||
|
private var rightBarButtonMode: RightBarButtonMode = .paste
|
||||||
|
var initialText: String?
|
||||||
|
|
||||||
|
private enum RightBarButtonMode {
|
||||||
|
case paste
|
||||||
|
case reset
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
title = "格式化日志"
|
||||||
|
navigationItem.largeTitleDisplayMode = .never
|
||||||
|
view.backgroundColor = .systemGroupedBackground
|
||||||
|
setupUI()
|
||||||
|
if let initialText = initialText {
|
||||||
|
textView.text = initialText
|
||||||
|
isFormatted = true
|
||||||
|
formatButton.setTitle("保存到 iCloud", for: .normal)
|
||||||
|
rightBarButtonMode = .reset
|
||||||
|
updateRightBarButtonItem()
|
||||||
|
}
|
||||||
|
setupKeyboardObservers()
|
||||||
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
NotificationCenter.default.removeObserver(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setupUI() {
|
||||||
|
textView = UITextView()
|
||||||
|
textView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
textView.font = UIFont.systemFont(ofSize: 16)
|
||||||
|
textView.backgroundColor = UIColor { traitCollection in
|
||||||
|
traitCollection.userInterfaceStyle == .dark ? .secondarySystemBackground : .white
|
||||||
|
}
|
||||||
|
textView.layer.cornerRadius = 12
|
||||||
|
textView.layer.borderWidth = 0.5
|
||||||
|
textView.layer.borderColor = UIColor.separator.cgColor
|
||||||
|
textView.textContainerInset = UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12)
|
||||||
|
textView.delegate = self
|
||||||
|
view.addSubview(textView)
|
||||||
|
|
||||||
|
doneButton = UIBarButtonItem(title: "完成", style: .prominent, target: self, action: #selector(didTapDoneButton))
|
||||||
|
pasteButton = UIBarButtonItem(title: "粘贴文案", style: .plain, target: self, action: #selector(didTapPasteButton))
|
||||||
|
resetButton = UIBarButtonItem(title: "重置", style: .plain, target: self, action: #selector(didTapResetButton))
|
||||||
|
|
||||||
|
updateRightBarButtonItem()
|
||||||
|
|
||||||
|
formatButton = UIButton(type: .system)
|
||||||
|
formatButton.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
formatButton.setTitle("格式化", for: .normal)
|
||||||
|
formatButton.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .semibold)
|
||||||
|
formatButton.backgroundColor = .systemBlue
|
||||||
|
formatButton.setTitleColor(.white, for: .normal)
|
||||||
|
formatButton.layer.cornerRadius = 12
|
||||||
|
formatButton.addTarget(self, action: #selector(didTapFormatButton), for: .touchUpInside)
|
||||||
|
view.addSubview(formatButton)
|
||||||
|
|
||||||
|
var doneConfig = UIButton.Configuration.glass()
|
||||||
|
doneConfig.title = "完成"
|
||||||
|
doneConfig.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
|
||||||
|
var outgoing = incoming
|
||||||
|
outgoing.font = UIFont.systemFont(ofSize: 17, weight: .semibold)
|
||||||
|
return outgoing
|
||||||
|
}
|
||||||
|
doneConfig.baseForegroundColor = .label
|
||||||
|
doneConfig.cornerStyle = .capsule
|
||||||
|
doneConfig.contentInsets = NSDirectionalEdgeInsets(top: 15, leading: 22, bottom: 15, trailing: 22)
|
||||||
|
floatingDoneButton = UIButton(configuration: doneConfig)
|
||||||
|
floatingDoneButton.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
floatingDoneButton.alpha = 0
|
||||||
|
floatingDoneButton.addTarget(self, action: #selector(didTapFloatingDoneButton), for: .touchUpInside)
|
||||||
|
view.addSubview(floatingDoneButton)
|
||||||
|
|
||||||
|
floatingDoneButtonBottomConstraint = floatingDoneButton.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -16)
|
||||||
|
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
floatingDoneButton.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -16),
|
||||||
|
floatingDoneButtonBottomConstraint,
|
||||||
|
|
||||||
|
textView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 16),
|
||||||
|
textView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16),
|
||||||
|
textView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -16),
|
||||||
|
textView.bottomAnchor.constraint(equalTo: formatButton.topAnchor, constant: -16),
|
||||||
|
|
||||||
|
formatButton.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16),
|
||||||
|
formatButton.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -16),
|
||||||
|
formatButton.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -16),
|
||||||
|
formatButton.heightAnchor.constraint(equalToConstant: 52)
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapDoneButton() {
|
||||||
|
textView.resignFirstResponder()
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapFloatingDoneButton() {
|
||||||
|
textView.resignFirstResponder()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setupKeyboardObservers() {
|
||||||
|
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
|
||||||
|
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func keyboardWillShow(_ notification: Notification) {
|
||||||
|
guard let keyboardFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return }
|
||||||
|
let keyboardFrameInView = view.convert(keyboardFrame, from: nil)
|
||||||
|
let intersection = keyboardFrameInView.intersection(view.bounds)
|
||||||
|
let keyboardHeight = intersection.height
|
||||||
|
|
||||||
|
let duration = notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? TimeInterval ?? 0.25
|
||||||
|
|
||||||
|
UIView.animate(withDuration: duration, delay: 0, options: .beginFromCurrentState) {
|
||||||
|
self.textView.contentInset.bottom = keyboardHeight
|
||||||
|
self.textView.verticalScrollIndicatorInsets.bottom = keyboardHeight
|
||||||
|
self.floatingDoneButtonBottomConstraint.constant = -(keyboardHeight + 8)
|
||||||
|
self.floatingDoneButton.alpha = 1
|
||||||
|
self.view.layoutIfNeeded()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func keyboardWillHide(_ notification: Notification) {
|
||||||
|
let duration = notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? TimeInterval ?? 0.25
|
||||||
|
|
||||||
|
UIView.animate(withDuration: duration, delay: 0, options: .beginFromCurrentState) {
|
||||||
|
self.textView.contentInset.bottom = 0
|
||||||
|
self.textView.verticalScrollIndicatorInsets.bottom = 0
|
||||||
|
self.floatingDoneButtonBottomConstraint.constant = -16
|
||||||
|
self.floatingDoneButton.alpha = 0
|
||||||
|
self.view.layoutIfNeeded()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapFormatButton() {
|
||||||
|
guard !trimmedText().isEmpty else {
|
||||||
|
showEmptyAlert()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if isFormatted {
|
||||||
|
saveToFiles()
|
||||||
|
} else {
|
||||||
|
textView.text = TextFormatter.formatLog(textView.text)
|
||||||
|
isFormatted = true
|
||||||
|
formatButton.setTitle("保存到 iCloud", for: .normal)
|
||||||
|
rightBarButtonMode = .reset
|
||||||
|
updateRightBarButtonItem()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapPasteButton() {
|
||||||
|
if let string = UIPasteboard.general.string {
|
||||||
|
textView.text = string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func trimmedText() -> String {
|
||||||
|
return textView.text?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
||||||
|
}
|
||||||
|
|
||||||
|
private func showEmptyAlert() {
|
||||||
|
let alert = UIAlertController(title: "提示", message: "请输入内容后再进行格式化", preferredStyle: .alert)
|
||||||
|
alert.addAction(UIAlertAction(title: "确定", style: .default))
|
||||||
|
present(alert, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapResetButton() {
|
||||||
|
let alert = UIAlertController(
|
||||||
|
title: "确认重置",
|
||||||
|
message: "确定要清空当前内容吗?",
|
||||||
|
preferredStyle: .alert
|
||||||
|
)
|
||||||
|
alert.addAction(UIAlertAction(title: "取消", style: .cancel))
|
||||||
|
alert.addAction(UIAlertAction(title: "重置", style: .destructive) { [weak self] _ in
|
||||||
|
self?.performReset()
|
||||||
|
})
|
||||||
|
present(alert, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func performReset() {
|
||||||
|
textView.text = ""
|
||||||
|
isFormatted = false
|
||||||
|
formatButton.setTitle("格式化", for: .normal)
|
||||||
|
rightBarButtonMode = .paste
|
||||||
|
updateRightBarButtonItem()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func updateRightBarButtonItem() {
|
||||||
|
if textView.isFirstResponder {
|
||||||
|
navigationItem.rightBarButtonItem = doneButton
|
||||||
|
} else {
|
||||||
|
switch rightBarButtonMode {
|
||||||
|
case .paste:
|
||||||
|
navigationItem.rightBarButtonItem = pasteButton
|
||||||
|
case .reset:
|
||||||
|
navigationItem.rightBarButtonItem = resetButton
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func saveToFiles() {
|
||||||
|
let fileName = generateFileName()
|
||||||
|
let fileURL = FileManager.default.temporaryDirectory.appendingPathComponent(fileName)
|
||||||
|
|
||||||
|
do {
|
||||||
|
try textView.text.write(to: fileURL, atomically: true, encoding: .utf8)
|
||||||
|
let documentPicker = UIDocumentPickerViewController(forExporting: [fileURL], asCopy: true)
|
||||||
|
documentPicker.delegate = self
|
||||||
|
present(documentPicker, animated: true)
|
||||||
|
} catch {
|
||||||
|
print("Failed to write file: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func generateFileName() -> String {
|
||||||
|
let text = textView.text ?? ""
|
||||||
|
let firstLine = text.components(separatedBy: .newlines).first ?? ""
|
||||||
|
let trimmed = firstLine.trimmingCharacters(in: .whitespaces)
|
||||||
|
let withoutHash = trimmed.replacingOccurrences(of: "^#\\s*", with: "", options: .regularExpression)
|
||||||
|
let cleanName = withoutHash.trimmingCharacters(in: .whitespaces)
|
||||||
|
|
||||||
|
if cleanName.isEmpty {
|
||||||
|
return "formatted_log_\(Int(Date().timeIntervalSince1970)).md"
|
||||||
|
}
|
||||||
|
return cleanName + ".md"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension FormatLogViewController: UITextViewDelegate {
|
||||||
|
|
||||||
|
func textViewDidBeginEditing(_ textView: UITextView) {
|
||||||
|
updateRightBarButtonItem()
|
||||||
|
}
|
||||||
|
|
||||||
|
func textViewDidEndEditing(_ textView: UITextView) {
|
||||||
|
updateRightBarButtonItem()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension FormatLogViewController: UIDocumentPickerDelegate {
|
||||||
|
|
||||||
|
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
|
||||||
|
// File saved to selected location
|
||||||
|
}
|
||||||
|
|
||||||
|
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
|
||||||
|
// User cancelled
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,313 @@
|
|||||||
|
//
|
||||||
|
// FormatNoteViewController.swift
|
||||||
|
// Note
|
||||||
|
//
|
||||||
|
// Created by fish on 2026/7/12.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
class FormatNoteViewController: UIViewController {
|
||||||
|
|
||||||
|
private var textView: UITextView!
|
||||||
|
private var iCloudButton: UIButton!
|
||||||
|
private var noteButton: UIButton!
|
||||||
|
private var floatingDoneButton: UIButton!
|
||||||
|
private var floatingDoneButtonBottomConstraint: NSLayoutConstraint!
|
||||||
|
private var doneButton: UIBarButtonItem!
|
||||||
|
private var pasteButton: UIBarButtonItem!
|
||||||
|
private var resetButton: UIBarButtonItem!
|
||||||
|
private var rightBarButtonMode: RightBarButtonMode = .paste
|
||||||
|
private var isCloudFormatted = false
|
||||||
|
private var isNoteFormatted = false
|
||||||
|
var initialText: String?
|
||||||
|
|
||||||
|
private enum RightBarButtonMode {
|
||||||
|
case paste
|
||||||
|
case reset
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
title = "格式化笔记"
|
||||||
|
navigationItem.largeTitleDisplayMode = .never
|
||||||
|
view.backgroundColor = .systemGroupedBackground
|
||||||
|
setupUI()
|
||||||
|
if let initialText = initialText {
|
||||||
|
textView.text = initialText
|
||||||
|
}
|
||||||
|
setupKeyboardObservers()
|
||||||
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
NotificationCenter.default.removeObserver(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setupUI() {
|
||||||
|
textView = UITextView()
|
||||||
|
textView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
textView.backgroundColor = UIColor { traitCollection in
|
||||||
|
traitCollection.userInterfaceStyle == .dark ? .secondarySystemBackground : .white
|
||||||
|
}
|
||||||
|
textView.layer.cornerRadius = 12
|
||||||
|
textView.layer.borderWidth = 0.5
|
||||||
|
textView.layer.borderColor = UIColor.separator.cgColor
|
||||||
|
textView.layer.masksToBounds = true
|
||||||
|
textView.font = UIFont.preferredFont(forTextStyle: .body)
|
||||||
|
textView.textContainerInset = UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12)
|
||||||
|
textView.isEditable = true
|
||||||
|
textView.delegate = self
|
||||||
|
view.addSubview(textView)
|
||||||
|
|
||||||
|
doneButton = UIBarButtonItem(title: "完成", style: .plain, target: self, action: #selector(didTapDoneButton))
|
||||||
|
pasteButton = UIBarButtonItem(title: "粘贴文案", style: .plain, target: self, action: #selector(didTapPasteButton))
|
||||||
|
resetButton = UIBarButtonItem(title: "重置", style: .plain, target: self, action: #selector(didTapResetButton))
|
||||||
|
updateRightBarButtonItem()
|
||||||
|
|
||||||
|
iCloudButton = createBottomButton(title: "iCloud 格式化", color: .systemBlue)
|
||||||
|
iCloudButton.addTarget(self, action: #selector(didTapiCloudButton), for: .touchUpInside)
|
||||||
|
view.addSubview(iCloudButton)
|
||||||
|
|
||||||
|
noteButton = createBottomButton(title: "Note 格式化", color: .systemGreen)
|
||||||
|
noteButton.addTarget(self, action: #selector(didTapNoteButton), for: .touchUpInside)
|
||||||
|
view.addSubview(noteButton)
|
||||||
|
|
||||||
|
var doneConfig = UIButton.Configuration.glass()
|
||||||
|
doneConfig.title = "完成"
|
||||||
|
doneConfig.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
|
||||||
|
var outgoing = incoming
|
||||||
|
outgoing.font = UIFont.systemFont(ofSize: 17, weight: .semibold)
|
||||||
|
return outgoing
|
||||||
|
}
|
||||||
|
doneConfig.baseForegroundColor = .label
|
||||||
|
doneConfig.cornerStyle = .capsule
|
||||||
|
doneConfig.contentInsets = NSDirectionalEdgeInsets(top: 15, leading: 22, bottom: 15, trailing: 22)
|
||||||
|
floatingDoneButton = UIButton(configuration: doneConfig)
|
||||||
|
floatingDoneButton.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
floatingDoneButton.alpha = 0
|
||||||
|
floatingDoneButton.addTarget(self, action: #selector(didTapFloatingDoneButton), for: .touchUpInside)
|
||||||
|
view.addSubview(floatingDoneButton)
|
||||||
|
|
||||||
|
let safeArea = view.safeAreaLayoutGuide
|
||||||
|
let buttonHeight: CGFloat = 52
|
||||||
|
let spacing: CGFloat = 16
|
||||||
|
|
||||||
|
floatingDoneButtonBottomConstraint = floatingDoneButton.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -spacing)
|
||||||
|
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
textView.topAnchor.constraint(equalTo: safeArea.topAnchor, constant: spacing),
|
||||||
|
textView.leadingAnchor.constraint(equalTo: safeArea.leadingAnchor, constant: spacing),
|
||||||
|
textView.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor, constant: -spacing),
|
||||||
|
|
||||||
|
iCloudButton.topAnchor.constraint(equalTo: textView.bottomAnchor, constant: spacing),
|
||||||
|
iCloudButton.leadingAnchor.constraint(equalTo: safeArea.leadingAnchor, constant: spacing),
|
||||||
|
iCloudButton.trailingAnchor.constraint(equalTo: safeArea.centerXAnchor, constant: -spacing / 2),
|
||||||
|
iCloudButton.heightAnchor.constraint(equalToConstant: buttonHeight),
|
||||||
|
iCloudButton.bottomAnchor.constraint(equalTo: safeArea.bottomAnchor, constant: -spacing),
|
||||||
|
|
||||||
|
noteButton.topAnchor.constraint(equalTo: textView.bottomAnchor, constant: spacing),
|
||||||
|
noteButton.leadingAnchor.constraint(equalTo: safeArea.centerXAnchor, constant: spacing / 2),
|
||||||
|
noteButton.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor, constant: -spacing),
|
||||||
|
noteButton.heightAnchor.constraint(equalToConstant: buttonHeight),
|
||||||
|
noteButton.bottomAnchor.constraint(equalTo: safeArea.bottomAnchor, constant: -spacing),
|
||||||
|
|
||||||
|
floatingDoneButton.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor, constant: -spacing),
|
||||||
|
floatingDoneButtonBottomConstraint
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
private func createBottomButton(title: String, color: UIColor) -> UIButton {
|
||||||
|
var config = UIButton.Configuration.filled()
|
||||||
|
config.title = title
|
||||||
|
config.baseBackgroundColor = color
|
||||||
|
config.baseForegroundColor = .white
|
||||||
|
config.cornerStyle = .medium
|
||||||
|
config.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16)
|
||||||
|
|
||||||
|
let button = UIButton(configuration: config)
|
||||||
|
button.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
return button
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapDoneButton() {
|
||||||
|
textView.resignFirstResponder()
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapFloatingDoneButton() {
|
||||||
|
textView.resignFirstResponder()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setupKeyboardObservers() {
|
||||||
|
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
|
||||||
|
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func keyboardWillShow(_ notification: Notification) {
|
||||||
|
guard let keyboardFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return }
|
||||||
|
let keyboardFrameInView = view.convert(keyboardFrame, from: nil)
|
||||||
|
let intersection = keyboardFrameInView.intersection(view.bounds)
|
||||||
|
let keyboardHeight = intersection.height
|
||||||
|
|
||||||
|
let duration = notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? TimeInterval ?? 0.25
|
||||||
|
|
||||||
|
UIView.animate(withDuration: duration, delay: 0, options: .beginFromCurrentState) {
|
||||||
|
self.textView.contentInset.bottom = keyboardHeight
|
||||||
|
self.textView.verticalScrollIndicatorInsets.bottom = keyboardHeight
|
||||||
|
self.floatingDoneButtonBottomConstraint.constant = -(keyboardHeight + 8)
|
||||||
|
self.floatingDoneButton.alpha = 1
|
||||||
|
self.view.layoutIfNeeded()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func keyboardWillHide(_ notification: Notification) {
|
||||||
|
let duration = notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? TimeInterval ?? 0.25
|
||||||
|
|
||||||
|
UIView.animate(withDuration: duration, delay: 0, options: .beginFromCurrentState) {
|
||||||
|
self.textView.contentInset.bottom = 0
|
||||||
|
self.textView.verticalScrollIndicatorInsets.bottom = 0
|
||||||
|
self.floatingDoneButtonBottomConstraint.constant = -16
|
||||||
|
self.floatingDoneButton.alpha = 0
|
||||||
|
self.view.layoutIfNeeded()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapPasteButton() {
|
||||||
|
if let string = UIPasteboard.general.string {
|
||||||
|
textView.text = string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func trimmedText() -> String {
|
||||||
|
return textView.text?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
||||||
|
}
|
||||||
|
|
||||||
|
private func showEmptyAlert() {
|
||||||
|
let alert = UIAlertController(title: "提示", message: "请输入内容后再进行格式化", preferredStyle: .alert)
|
||||||
|
alert.addAction(UIAlertAction(title: "确定", style: .default))
|
||||||
|
present(alert, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapResetButton() {
|
||||||
|
let alert = UIAlertController(
|
||||||
|
title: "确认重置",
|
||||||
|
message: "确定要清空当前内容吗?",
|
||||||
|
preferredStyle: .alert
|
||||||
|
)
|
||||||
|
alert.addAction(UIAlertAction(title: "取消", style: .cancel))
|
||||||
|
alert.addAction(UIAlertAction(title: "重置", style: .destructive) { [weak self] _ in
|
||||||
|
self?.performReset()
|
||||||
|
})
|
||||||
|
present(alert, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func performReset() {
|
||||||
|
textView.text = ""
|
||||||
|
rightBarButtonMode = .paste
|
||||||
|
isCloudFormatted = false
|
||||||
|
isNoteFormatted = false
|
||||||
|
iCloudButton.setTitle("iCloud 格式化", for: .normal)
|
||||||
|
noteButton.setTitle("Note 格式化", for: .normal)
|
||||||
|
updateRightBarButtonItem()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func updateRightBarButtonItem() {
|
||||||
|
if textView.isFirstResponder {
|
||||||
|
navigationItem.rightBarButtonItem = doneButton
|
||||||
|
} else {
|
||||||
|
switch rightBarButtonMode {
|
||||||
|
case .paste:
|
||||||
|
navigationItem.rightBarButtonItem = pasteButton
|
||||||
|
case .reset:
|
||||||
|
navigationItem.rightBarButtonItem = resetButton
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapiCloudButton() {
|
||||||
|
guard !trimmedText().isEmpty else {
|
||||||
|
showEmptyAlert()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if isCloudFormatted {
|
||||||
|
saveToFiles()
|
||||||
|
} else {
|
||||||
|
textView.text = TextFormatter.formatForCloud(textView.text)
|
||||||
|
isCloudFormatted = true
|
||||||
|
iCloudButton.setTitle("保存到 iCloud", for: .normal)
|
||||||
|
rightBarButtonMode = .reset
|
||||||
|
updateRightBarButtonItem()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapNoteButton() {
|
||||||
|
guard !trimmedText().isEmpty else {
|
||||||
|
showEmptyAlert()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if isNoteFormatted {
|
||||||
|
copyAndOpenNotes()
|
||||||
|
} else {
|
||||||
|
textView.text = TextFormatter.formatForNote(textView.text)
|
||||||
|
isNoteFormatted = true
|
||||||
|
noteButton.setTitle("复制并打开备忘录", for: .normal)
|
||||||
|
rightBarButtonMode = .reset
|
||||||
|
updateRightBarButtonItem()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func copyAndOpenNotes() {
|
||||||
|
UIPasteboard.general.string = textView.text
|
||||||
|
guard let url = URL(string: "mobilenotes://") else { return }
|
||||||
|
guard UIApplication.shared.canOpenURL(url) else { return }
|
||||||
|
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func saveToFiles() {
|
||||||
|
let fileName = generateFileName()
|
||||||
|
let fileURL = FileManager.default.temporaryDirectory.appendingPathComponent(fileName)
|
||||||
|
|
||||||
|
do {
|
||||||
|
try textView.text.write(to: fileURL, atomically: true, encoding: .utf8)
|
||||||
|
let documentPicker = UIDocumentPickerViewController(forExporting: [fileURL], asCopy: true)
|
||||||
|
documentPicker.delegate = self
|
||||||
|
present(documentPicker, animated: true)
|
||||||
|
} catch {
|
||||||
|
print("Failed to write file: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func generateFileName() -> String {
|
||||||
|
let text = textView.text ?? ""
|
||||||
|
let firstLine = text.components(separatedBy: .newlines).first ?? ""
|
||||||
|
let trimmed = firstLine.trimmingCharacters(in: .whitespaces)
|
||||||
|
let withoutHash = trimmed.replacingOccurrences(of: "^#\\s*", with: "", options: .regularExpression)
|
||||||
|
let cleanName = withoutHash.trimmingCharacters(in: .whitespaces)
|
||||||
|
|
||||||
|
if cleanName.isEmpty {
|
||||||
|
return "formatted_note_\(Int(Date().timeIntervalSince1970)).md"
|
||||||
|
}
|
||||||
|
return cleanName + ".md"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension FormatNoteViewController: UIDocumentPickerDelegate {
|
||||||
|
|
||||||
|
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
|
||||||
|
// File saved to selected location
|
||||||
|
}
|
||||||
|
|
||||||
|
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
|
||||||
|
// User cancelled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension FormatNoteViewController: UITextViewDelegate {
|
||||||
|
|
||||||
|
func textViewDidBeginEditing(_ textView: UITextView) {
|
||||||
|
updateRightBarButtonItem()
|
||||||
|
}
|
||||||
|
|
||||||
|
func textViewDidEndEditing(_ textView: UITextView) {
|
||||||
|
updateRightBarButtonItem()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
//
|
|
||||||
// FormatterView.swift
|
|
||||||
// Note
|
|
||||||
//
|
|
||||||
// Created by fish on 2026/7/12.
|
|
||||||
//
|
|
||||||
|
|
||||||
import SwiftUI
|
|
||||||
|
|
||||||
struct FormatterView: View {
|
|
||||||
@State private var inputText: String = ""
|
|
||||||
@State private var outputText: String = ""
|
|
||||||
@State private var showCopied: Bool = false
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
NavigationStack {
|
|
||||||
VStack(spacing: 16) {
|
|
||||||
TextEditor(text: $inputText)
|
|
||||||
.frame(minHeight: 120)
|
|
||||||
.padding(8)
|
|
||||||
.background(Color(.systemGray6))
|
|
||||||
.cornerRadius(8)
|
|
||||||
.overlay(
|
|
||||||
RoundedRectangle(cornerRadius: 8)
|
|
||||||
.stroke(Color(.systemGray4), lineWidth: 1)
|
|
||||||
)
|
|
||||||
|
|
||||||
Button(action: formatText) {
|
|
||||||
Label("格式化", systemImage: "wand.and.stars")
|
|
||||||
.font(.headline)
|
|
||||||
.frame(maxWidth: .infinity)
|
|
||||||
.padding()
|
|
||||||
.background(Color.accentColor)
|
|
||||||
.foregroundStyle(.white)
|
|
||||||
.cornerRadius(10)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !outputText.isEmpty {
|
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
|
||||||
HStack {
|
|
||||||
Text("格式化结果")
|
|
||||||
.font(.subheadline)
|
|
||||||
.foregroundStyle(.secondary)
|
|
||||||
Spacer()
|
|
||||||
Button(action: copyOutput) {
|
|
||||||
Image(systemName: "doc.on.doc")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TextEditor(text: .constant(outputText))
|
|
||||||
.frame(minHeight: 120)
|
|
||||||
.padding(8)
|
|
||||||
.background(Color(.systemGray6))
|
|
||||||
.cornerRadius(8)
|
|
||||||
.overlay(
|
|
||||||
RoundedRectangle(cornerRadius: 8)
|
|
||||||
.stroke(Color(.systemGray4), lineWidth: 1)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer()
|
|
||||||
}
|
|
||||||
.padding()
|
|
||||||
.navigationTitle("文案格式化")
|
|
||||||
.overlay {
|
|
||||||
if showCopied {
|
|
||||||
VStack {
|
|
||||||
Spacer()
|
|
||||||
Text("已复制")
|
|
||||||
.font(.subheadline)
|
|
||||||
.padding(.horizontal, 16)
|
|
||||||
.padding(.vertical, 8)
|
|
||||||
.background(Color.black.opacity(0.75))
|
|
||||||
.foregroundStyle(.white)
|
|
||||||
.cornerRadius(20)
|
|
||||||
.padding(.bottom, 32)
|
|
||||||
}
|
|
||||||
.transition(.opacity)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private func formatText() {
|
|
||||||
var content = inputText
|
|
||||||
|
|
||||||
// 去 #
|
|
||||||
content = content.replacingOccurrences(of: "# ", with: "")
|
|
||||||
content = content.replacingOccurrences(of: "#", with: "")
|
|
||||||
// 将 ; 转为句号
|
|
||||||
content = content.replacingOccurrences(of: ";", with: "。")
|
|
||||||
// 将 ; 转为句号
|
|
||||||
content = content.replacingOccurrences(of: ";", with: "。")
|
|
||||||
// 将 . 转为句号
|
|
||||||
content = content.replacingOccurrences(of: ".", with: "。")
|
|
||||||
// 将 ( 转为 (
|
|
||||||
content = content.replacingOccurrences(of: "(", with: "(")
|
|
||||||
// 将 ) 转为 )
|
|
||||||
content = content.replacingOccurrences(of: ")", with: ")")
|
|
||||||
// 将 ? 转为 ?
|
|
||||||
content = content.replacingOccurrences(of: "?", with: "?")
|
|
||||||
// 将 , 转为 ,
|
|
||||||
content = content.replacingOccurrences(of: ",", with: ",")
|
|
||||||
// 将 : 转为 :
|
|
||||||
content = content.replacingOccurrences(of: ":", with: ":")
|
|
||||||
// 将 日星期 转为 日 星期
|
|
||||||
content = content.replacingOccurrences(of: "日星期", with: "日 星期")
|
|
||||||
// 在第一行插入 #
|
|
||||||
content = "# " + content
|
|
||||||
// 标题设置
|
|
||||||
content = content.replacingOccurrences(of: "一、生活方面", with: "## 一、生活方面")
|
|
||||||
content = content.replacingOccurrences(of: "二、交易方面", with: "## 二、交易方面")
|
|
||||||
content = content.replacingOccurrences(of: "三、工作方面", with: "## 三、工作方面")
|
|
||||||
|
|
||||||
outputText = content
|
|
||||||
}
|
|
||||||
|
|
||||||
private func copyOutput() {
|
|
||||||
UIPasteboard.general.string = outputText
|
|
||||||
withAnimation {
|
|
||||||
showCopied = true
|
|
||||||
}
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
|
|
||||||
withAnimation {
|
|
||||||
showCopied = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#Preview {
|
|
||||||
FormatterView()
|
|
||||||
}
|
|
||||||
+177
@@ -0,0 +1,177 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>ITSAppUsesNonExemptEncryption</key>
|
||||||
|
<false/>
|
||||||
|
<key>LSApplicationQueriesSchemes</key>
|
||||||
|
<array>
|
||||||
|
<string>mobilenotes</string>
|
||||||
|
<string>shareddocuments</string>
|
||||||
|
<string>noteapp</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleURLTypes</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleURLName</key>
|
||||||
|
<string>com.fishestlife.note</string>
|
||||||
|
<key>CFBundleURLSchemes</key>
|
||||||
|
<array>
|
||||||
|
<string>noteapp</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleDocumentTypes</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>Markdown File</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Editor</string>
|
||||||
|
<key>LSHandlerRank</key>
|
||||||
|
<string>Owner</string>
|
||||||
|
<key>LSItemContentTypes</key>
|
||||||
|
<array>
|
||||||
|
<string>net.daringfireball.markdown</string>
|
||||||
|
<string>public.markdown</string>
|
||||||
|
<string>public.text</string>
|
||||||
|
<string>public.plain-text</string>
|
||||||
|
<string>public.utf8-plain-text</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>md</string>
|
||||||
|
<string>markdown</string>
|
||||||
|
<string>mdown</string>
|
||||||
|
<string>mkd</string>
|
||||||
|
<string>mkdn</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeMIMETypes</key>
|
||||||
|
<array>
|
||||||
|
<string>text/markdown</string>
|
||||||
|
<string>text/x-markdown</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>Plain Text File</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Editor</string>
|
||||||
|
<key>LSHandlerRank</key>
|
||||||
|
<string>Alternate</string>
|
||||||
|
<key>LSItemContentTypes</key>
|
||||||
|
<array>
|
||||||
|
<string>public.plain-text</string>
|
||||||
|
<string>public.utf8-plain-text</string>
|
||||||
|
<string>public.text</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>txt</string>
|
||||||
|
<string>text</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>Any Text or Data File</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Viewer</string>
|
||||||
|
<key>LSHandlerRank</key>
|
||||||
|
<string>Alternate</string>
|
||||||
|
<key>LSItemContentTypes</key>
|
||||||
|
<array>
|
||||||
|
<string>public.data</string>
|
||||||
|
<string>public.content</string>
|
||||||
|
<string>public.item</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>md</string>
|
||||||
|
<string>markdown</string>
|
||||||
|
<string>txt</string>
|
||||||
|
<string>*</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>LSSupportsOpeningDocumentsInPlace</key>
|
||||||
|
<true/>
|
||||||
|
<key>UTExportedTypeDeclarations</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>UTTypeConformsTo</key>
|
||||||
|
<array>
|
||||||
|
<string>public.text</string>
|
||||||
|
<string>public.plain-text</string>
|
||||||
|
</array>
|
||||||
|
<key>UTTypeDescription</key>
|
||||||
|
<string>Markdown File</string>
|
||||||
|
<key>UTTypeIdentifier</key>
|
||||||
|
<string>net.daringfireball.markdown</string>
|
||||||
|
<key>UTTypeTagSpecification</key>
|
||||||
|
<dict>
|
||||||
|
<key>public.filename-extension</key>
|
||||||
|
<array>
|
||||||
|
<string>md</string>
|
||||||
|
<string>markdown</string>
|
||||||
|
<string>mdown</string>
|
||||||
|
<string>mkd</string>
|
||||||
|
<string>mkdn</string>
|
||||||
|
</array>
|
||||||
|
<key>public.mime-type</key>
|
||||||
|
<array>
|
||||||
|
<string>text/markdown</string>
|
||||||
|
<string>text/x-markdown</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>UTImportedTypeDeclarations</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>UTTypeConformsTo</key>
|
||||||
|
<array>
|
||||||
|
<string>public.text</string>
|
||||||
|
<string>public.plain-text</string>
|
||||||
|
<string>public.data</string>
|
||||||
|
</array>
|
||||||
|
<key>UTTypeDescription</key>
|
||||||
|
<string>Markdown File</string>
|
||||||
|
<key>UTTypeIdentifier</key>
|
||||||
|
<string>net.daringfireball.markdown</string>
|
||||||
|
<key>UTTypeTagSpecification</key>
|
||||||
|
<dict>
|
||||||
|
<key>public.filename-extension</key>
|
||||||
|
<array>
|
||||||
|
<string>md</string>
|
||||||
|
<string>markdown</string>
|
||||||
|
<string>mdown</string>
|
||||||
|
<string>mkd</string>
|
||||||
|
<string>mkdn</string>
|
||||||
|
</array>
|
||||||
|
<key>public.mime-type</key>
|
||||||
|
<array>
|
||||||
|
<string>text/markdown</string>
|
||||||
|
<string>text/x-markdown</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>UIApplicationSceneManifest</key>
|
||||||
|
<dict>
|
||||||
|
<key>UIApplicationSupportsMultipleScenes</key>
|
||||||
|
<false/>
|
||||||
|
<key>UISceneConfigurations</key>
|
||||||
|
<dict>
|
||||||
|
<key>UIWindowSceneSessionRoleApplication</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>UISceneConfigurationName</key>
|
||||||
|
<string>Default Configuration</string>
|
||||||
|
<key>UISceneDelegateClassName</key>
|
||||||
|
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>com.apple.security.application-groups</key>
|
||||||
|
<array>
|
||||||
|
<string>group.com.fishestlife.note</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
//
|
|
||||||
// NoteApp.swift
|
|
||||||
// Note
|
|
||||||
//
|
|
||||||
// Created by fish on 2026/7/12.
|
|
||||||
//
|
|
||||||
|
|
||||||
import SwiftUI
|
|
||||||
|
|
||||||
@main
|
|
||||||
struct NoteApp: App {
|
|
||||||
var body: some Scene {
|
|
||||||
WindowGroup {
|
|
||||||
FormatterView()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// NoteAppShortcuts.swift
|
||||||
|
// Note
|
||||||
|
//
|
||||||
|
// Created by Kimi Code CLI on 2026/7/15.
|
||||||
|
//
|
||||||
|
|
||||||
|
import AppIntents
|
||||||
|
|
||||||
|
struct NoteAppShortcuts: AppShortcutsProvider {
|
||||||
|
|
||||||
|
static var appShortcuts: [AppShortcut] {
|
||||||
|
AppShortcut(
|
||||||
|
intent: SaveClipIntent(),
|
||||||
|
phrases: ["保存剪贴板到 ${applicationName}"],
|
||||||
|
shortTitle: "保存剪贴板",
|
||||||
|
systemImageName: "doc.text"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
//
|
||||||
|
// PreviewViewController.swift
|
||||||
|
// Note
|
||||||
|
//
|
||||||
|
// Created by fish on 2026/7/13.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
class PreviewViewController: UIViewController {
|
||||||
|
|
||||||
|
private var textView: UITextView!
|
||||||
|
private var logButton: UIButton!
|
||||||
|
private var noteButton: UIButton!
|
||||||
|
|
||||||
|
var initialText: String?
|
||||||
|
var fileName: String?
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
title = "预览"
|
||||||
|
navigationItem.largeTitleDisplayMode = .never
|
||||||
|
view.backgroundColor = .systemGroupedBackground
|
||||||
|
setupUI()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setupUI() {
|
||||||
|
textView = UITextView()
|
||||||
|
textView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
textView.backgroundColor = UIColor { traitCollection in
|
||||||
|
traitCollection.userInterfaceStyle == .dark ? .secondarySystemBackground : .white
|
||||||
|
}
|
||||||
|
textView.layer.cornerRadius = 12
|
||||||
|
textView.layer.borderWidth = 0.5
|
||||||
|
textView.layer.borderColor = UIColor.separator.cgColor
|
||||||
|
textView.layer.masksToBounds = true
|
||||||
|
textView.font = UIFont.preferredFont(forTextStyle: .body)
|
||||||
|
textView.textContainerInset = UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12)
|
||||||
|
textView.isEditable = false
|
||||||
|
textView.isSelectable = true
|
||||||
|
textView.text = initialText
|
||||||
|
view.addSubview(textView)
|
||||||
|
|
||||||
|
logButton = createBottomButton(title: "处理日志", color: .systemBlue)
|
||||||
|
logButton.addTarget(self, action: #selector(didTapLogButton), for: .touchUpInside)
|
||||||
|
view.addSubview(logButton)
|
||||||
|
|
||||||
|
noteButton = createBottomButton(title: "处理 Note", color: .systemGreen)
|
||||||
|
noteButton.addTarget(self, action: #selector(didTapNoteButton), for: .touchUpInside)
|
||||||
|
view.addSubview(noteButton)
|
||||||
|
|
||||||
|
let safeArea = view.safeAreaLayoutGuide
|
||||||
|
let buttonHeight: CGFloat = 52
|
||||||
|
let spacing: CGFloat = 16
|
||||||
|
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
textView.topAnchor.constraint(equalTo: safeArea.topAnchor, constant: spacing),
|
||||||
|
textView.leadingAnchor.constraint(equalTo: safeArea.leadingAnchor, constant: spacing),
|
||||||
|
textView.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor, constant: -spacing),
|
||||||
|
|
||||||
|
logButton.topAnchor.constraint(equalTo: textView.bottomAnchor, constant: spacing),
|
||||||
|
logButton.leadingAnchor.constraint(equalTo: safeArea.leadingAnchor, constant: spacing),
|
||||||
|
logButton.trailingAnchor.constraint(equalTo: safeArea.centerXAnchor, constant: -spacing / 2),
|
||||||
|
logButton.heightAnchor.constraint(equalToConstant: buttonHeight),
|
||||||
|
logButton.bottomAnchor.constraint(equalTo: safeArea.bottomAnchor, constant: -spacing),
|
||||||
|
|
||||||
|
noteButton.topAnchor.constraint(equalTo: textView.bottomAnchor, constant: spacing),
|
||||||
|
noteButton.leadingAnchor.constraint(equalTo: safeArea.centerXAnchor, constant: spacing / 2),
|
||||||
|
noteButton.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor, constant: -spacing),
|
||||||
|
noteButton.heightAnchor.constraint(equalToConstant: buttonHeight),
|
||||||
|
noteButton.bottomAnchor.constraint(equalTo: safeArea.bottomAnchor, constant: -spacing)
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
private func createBottomButton(title: String, color: UIColor) -> UIButton {
|
||||||
|
var config = UIButton.Configuration.filled()
|
||||||
|
config.title = title
|
||||||
|
config.baseBackgroundColor = color
|
||||||
|
config.baseForegroundColor = .white
|
||||||
|
config.cornerStyle = .medium
|
||||||
|
config.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16)
|
||||||
|
|
||||||
|
let button = UIButton(configuration: config)
|
||||||
|
button.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
return button
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapLogButton() {
|
||||||
|
let viewController = FormatLogViewController()
|
||||||
|
viewController.initialText = TextFormatter.formatLog(initialText ?? "")
|
||||||
|
navigationController?.pushViewController(viewController, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapNoteButton() {
|
||||||
|
let viewController = FormatNoteViewController()
|
||||||
|
viewController.initialText = TextFormatter.formatForNote(initialText ?? "")
|
||||||
|
navigationController?.pushViewController(viewController, animated: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
//
|
||||||
|
// SaveClipIntent.swift
|
||||||
|
// Note
|
||||||
|
//
|
||||||
|
// Created by Kimi Code CLI on 2026/7/15.
|
||||||
|
//
|
||||||
|
|
||||||
|
import AppIntents
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
struct SaveClipIntent: AppIntent {
|
||||||
|
|
||||||
|
static var title: LocalizedStringResource = "保存剪贴板到 Note"
|
||||||
|
static var description: IntentDescription? = "将一段文本保存到 Note App 的收集箱,稍后统一处理。"
|
||||||
|
|
||||||
|
@Parameter(title: "文案", description: "要保存的文本内容", default: "")
|
||||||
|
var text: String
|
||||||
|
|
||||||
|
@Parameter(title: "来源", description: "文案来源,例如应用名称", default: "快捷指令")
|
||||||
|
var source: String?
|
||||||
|
|
||||||
|
init() {}
|
||||||
|
|
||||||
|
init(text: String, source: String? = nil) {
|
||||||
|
self.text = text
|
||||||
|
self.source = source
|
||||||
|
}
|
||||||
|
|
||||||
|
func perform() async throws -> some IntentResult & ReturnsValue<String> {
|
||||||
|
var inputText = text
|
||||||
|
if inputText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||||
|
inputText = await MainActor.run {
|
||||||
|
UIPasteboard.general.string ?? ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let trimmed = inputText.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
guard !trimmed.isEmpty else {
|
||||||
|
return .result(value: "文案为空,未保存。")
|
||||||
|
}
|
||||||
|
|
||||||
|
guard !isSystemClipboardPlaceholder(trimmed) else {
|
||||||
|
return .result(value: "剪贴板没有有效文本,未保存。")
|
||||||
|
}
|
||||||
|
|
||||||
|
let formattedText = TextFormatter.formatForShortcut(trimmed)
|
||||||
|
try await ClipStore.shared.save(text: formattedText, source: source)
|
||||||
|
return .result(value: "已保存到收集箱。")
|
||||||
|
}
|
||||||
|
|
||||||
|
private func isSystemClipboardPlaceholder(_ text: String) -> Bool {
|
||||||
|
let lowercased = text.lowercased()
|
||||||
|
if lowercased.hasPrefix("clipboard ") && lowercased.contains(" at ") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if text == "获取剪贴板" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
//
|
||||||
|
// SceneDelegate.swift
|
||||||
|
// Note
|
||||||
|
//
|
||||||
|
// Created by fish on 2026/7/12.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||||
|
|
||||||
|
var window: UIWindow?
|
||||||
|
|
||||||
|
|
||||||
|
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
||||||
|
guard let windowScene = (scene as? UIWindowScene) else { return }
|
||||||
|
|
||||||
|
window = UIWindow(windowScene: windowScene)
|
||||||
|
let rootViewController = ViewController()
|
||||||
|
let navigationController = UINavigationController(rootViewController: rootViewController)
|
||||||
|
window?.rootViewController = navigationController
|
||||||
|
window?.makeKeyAndVisible()
|
||||||
|
|
||||||
|
if let url = connectionOptions.urlContexts.first?.url {
|
||||||
|
handleSharedFile(url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func sceneDidDisconnect(_ scene: UIScene) {
|
||||||
|
// Called as the scene is being released by the system.
|
||||||
|
// This occurs shortly after the scene enters the background, or when its session is discarded.
|
||||||
|
// Release any resources associated with this scene that can be re-created the next time the scene connects.
|
||||||
|
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
|
||||||
|
}
|
||||||
|
|
||||||
|
func sceneDidBecomeActive(_ scene: UIScene) {
|
||||||
|
// Called when the scene has moved from an inactive state to an active state.
|
||||||
|
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
|
||||||
|
}
|
||||||
|
|
||||||
|
func sceneWillResignActive(_ scene: UIScene) {
|
||||||
|
// Called when the scene will move from an active state to an inactive state.
|
||||||
|
// This may occur due to temporary interruptions (ex. an incoming phone call).
|
||||||
|
}
|
||||||
|
|
||||||
|
func sceneWillEnterForeground(_ scene: UIScene) {
|
||||||
|
// Called as the scene transitions from the background to the foreground.
|
||||||
|
// Use this method to undo the changes made on entering the background.
|
||||||
|
}
|
||||||
|
|
||||||
|
func sceneDidEnterBackground(_ scene: UIScene) {
|
||||||
|
// Called as the scene transitions from the foreground to the background.
|
||||||
|
// Use this method to save data, release shared resources, and store enough scene-specific state information
|
||||||
|
// to restore the scene back to its current state.
|
||||||
|
}
|
||||||
|
|
||||||
|
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
|
||||||
|
guard let url = URLContexts.first?.url else { return }
|
||||||
|
handleSharedFile(url)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func handleSharedFile(_ url: URL) {
|
||||||
|
guard let navigationController = window?.rootViewController as? UINavigationController else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if url.scheme == "noteapp", url.host == "share" {
|
||||||
|
handleShareURL(url, navigationController: navigationController)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
guard url.isFileURL else { return }
|
||||||
|
|
||||||
|
let shouldStopAccessing = url.startAccessingSecurityScopedResource()
|
||||||
|
defer {
|
||||||
|
if shouldStopAccessing {
|
||||||
|
url.stopAccessingSecurityScopedResource()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
let content = try String(contentsOf: url, encoding: .utf8)
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
let viewController = PreviewViewController()
|
||||||
|
viewController.initialText = content
|
||||||
|
viewController.fileName = url.lastPathComponent
|
||||||
|
viewController.title = url.lastPathComponent
|
||||||
|
navigationController.pushViewController(viewController, animated: true)
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
print("Failed to read shared file: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func handleShareURL(_ url: URL, navigationController: UINavigationController) {
|
||||||
|
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
|
||||||
|
let queryItems = components.queryItems else { return }
|
||||||
|
|
||||||
|
let fileManager = FileManager.default
|
||||||
|
let containerURL = fileManager.containerURL(forSecurityApplicationGroupIdentifier: "group.com.fishestlife.note")
|
||||||
|
let sharedDir = containerURL?.appendingPathComponent("SharedFiles", isDirectory: true)
|
||||||
|
|
||||||
|
var contents: [(text: String, fileName: String)] = []
|
||||||
|
|
||||||
|
for item in queryItems {
|
||||||
|
if item.name.hasPrefix("text"), let text = item.value, !text.isEmpty {
|
||||||
|
contents.append((text: text, fileName: "shared.md"))
|
||||||
|
} else if item.name.hasPrefix("file"), let fileName = item.value, !fileName.isEmpty {
|
||||||
|
if let sharedDir = sharedDir {
|
||||||
|
let fileURL = sharedDir.appendingPathComponent(fileName)
|
||||||
|
if let text = try? String(contentsOf: fileURL, encoding: .utf8) {
|
||||||
|
contents.append((text: text, fileName: fileName))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
guard let first = contents.first else { return }
|
||||||
|
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
let viewController = PreviewViewController()
|
||||||
|
viewController.initialText = first.text
|
||||||
|
viewController.fileName = first.fileName
|
||||||
|
viewController.title = first.fileName
|
||||||
|
navigationController.pushViewController(viewController, animated: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
//
|
||||||
|
// TextFormatter.swift
|
||||||
|
// Note
|
||||||
|
//
|
||||||
|
// Created by fish on 2026/7/13.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
enum TextFormatter {
|
||||||
|
|
||||||
|
static nonisolated func formatLog(_ text: String) -> String {
|
||||||
|
var content = text
|
||||||
|
|
||||||
|
content = content.replacingOccurrences(of: "# ", with: "")
|
||||||
|
content = content.replacingOccurrences(of: "#", with: "")
|
||||||
|
content = content.replacingOccurrences(of: ";", with: "。")
|
||||||
|
content = content.replacingOccurrences(of: ";", with: "。")
|
||||||
|
content = content.replacingOccurrences(of: ".", with: "。")
|
||||||
|
content = content.replacingOccurrences(of: "(", with: "(")
|
||||||
|
content = content.replacingOccurrences(of: ")", with: ")")
|
||||||
|
content = content.replacingOccurrences(of: "?", with: "?")
|
||||||
|
content = content.replacingOccurrences(of: ",", with: ",")
|
||||||
|
content = content.replacingOccurrences(of: ":", with: ":")
|
||||||
|
content = content.replacingOccurrences(of: "日星期", with: "日 星期")
|
||||||
|
content = "# " + content
|
||||||
|
content = content.replacingOccurrences(of: "一、生活方面", with: "## 一、生活方面")
|
||||||
|
content = content.replacingOccurrences(of: "二、交易方面", with: "## 二、交易方面")
|
||||||
|
content = content.replacingOccurrences(of: "三、工作方面", with: "## 三、工作方面")
|
||||||
|
|
||||||
|
return content
|
||||||
|
}
|
||||||
|
|
||||||
|
static nonisolated func formatForCloud(_ text: String) -> String {
|
||||||
|
var content = formatForShortcut(text)
|
||||||
|
content = "# " + content
|
||||||
|
content = insertEmptyLineAfterFirstLine(content)
|
||||||
|
return content
|
||||||
|
}
|
||||||
|
|
||||||
|
static nonisolated func formatForShortcut(_ text: String) -> String {
|
||||||
|
var content = text
|
||||||
|
content = content.replacingOccurrences(of: " ", with: "")
|
||||||
|
content = content.replacingOccurrences(of: " ", with: "")
|
||||||
|
content = content.replacingOccurrences(of: "\u{00A0}", with: "")
|
||||||
|
content = content.replacingOccurrences(of: "# ", with: "")
|
||||||
|
content = content.replacingOccurrences(of: "#", with: "")
|
||||||
|
content = content.replacingOccurrences(of: "!", with: "。")
|
||||||
|
content = content.replacingOccurrences(of: "!", with: "。")
|
||||||
|
content = content.replacingOccurrences(of: ";", with: "。")
|
||||||
|
content = content.replacingOccurrences(of: ";", with: "。")
|
||||||
|
content = content.replacingOccurrences(of: ".", with: "。")
|
||||||
|
content = content.replacingOccurrences(of: "(", with: "(")
|
||||||
|
content = content.replacingOccurrences(of: ")", with: ")")
|
||||||
|
content = content.replacingOccurrences(of: "?", with: "?")
|
||||||
|
content = content.replacingOccurrences(of: ",", with: ",")
|
||||||
|
content = content.replacingOccurrences(of: ":", with: ":")
|
||||||
|
|
||||||
|
let numberReplacements: [(String, String)] = [
|
||||||
|
("20、", "二十、"), ("19、", "十九、"), ("18、", "十八、"), ("17、", "十七、"),
|
||||||
|
("16、", "十六、"), ("15、", "十五、"), ("14、", "十四、"), ("13、", "十三、"),
|
||||||
|
("12、", "十二、"), ("11、", "十一、"), ("10、", "十、"),
|
||||||
|
("9、", "九、"), ("8、", "八、"), ("7、", "七、"), ("6、", "六、"),
|
||||||
|
("5、", "五、"), ("4、", "四、"), ("3、", "三、"), ("2、", "二、"), ("1、", "一、")
|
||||||
|
]
|
||||||
|
for (old, new) in numberReplacements {
|
||||||
|
content = content.replacingOccurrences(of: old, with: new)
|
||||||
|
}
|
||||||
|
|
||||||
|
content = content.replacingOccurrences(of: "。", with: "。\n")
|
||||||
|
content = content.replacingOccurrences(of: "?", with: "?\n")
|
||||||
|
content = removeEmptyLines(content)
|
||||||
|
content = content.replacingOccurrences(of: ":\\s*", with: ":\n\n", options: .regularExpression)
|
||||||
|
content = content.replacingOccurrences(of: "。", with: "。\n")
|
||||||
|
content = content.replacingOccurrences(of: "?", with: "?\n")
|
||||||
|
content = content.replacingOccurrences(of: ":\n\n", with: ":")
|
||||||
|
content = content.replacingOccurrences(of: ":一、", with: ":\n\n一、")
|
||||||
|
content = content.replacingOccurrences(of: " ", with: "")
|
||||||
|
content = content.replacingOccurrences(of: "---", with: "---\n")
|
||||||
|
content = content.replacingOccurrences(of: "日星期", with: "日 星期")
|
||||||
|
return content
|
||||||
|
}
|
||||||
|
|
||||||
|
static nonisolated func formatForNote(_ text: String) -> String {
|
||||||
|
var content = text
|
||||||
|
content = content.replacingOccurrences(of: "# ", with: "")
|
||||||
|
content = content.replacingOccurrences(of: "#", with: "")
|
||||||
|
content = content.replacingOccurrences(of: "日星期", with: "日 星期")
|
||||||
|
|
||||||
|
// 第一行固定为标题
|
||||||
|
let allLines = removeEmptyLines(content).components(separatedBy: .newlines)
|
||||||
|
guard let title = allLines.first else { return content }
|
||||||
|
|
||||||
|
// 剩余内容按 --- 分段
|
||||||
|
let bodyLines = Array(allLines.dropFirst())
|
||||||
|
var groups: [[String]] = []
|
||||||
|
var currentGroup: [String] = []
|
||||||
|
for line in bodyLines {
|
||||||
|
if line == "---" {
|
||||||
|
if !currentGroup.isEmpty {
|
||||||
|
groups.append(currentGroup)
|
||||||
|
currentGroup = []
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
currentGroup.append(line)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !currentGroup.isEmpty {
|
||||||
|
groups.append(currentGroup)
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = title
|
||||||
|
for group in groups {
|
||||||
|
result += "\n\n\n" + group.joined(separator: "\n")
|
||||||
|
}
|
||||||
|
return result.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
}
|
||||||
|
|
||||||
|
static nonisolated func removeEmptyLines(_ text: String) -> String {
|
||||||
|
let lines = text.components(separatedBy: .newlines)
|
||||||
|
let nonEmptyLines = lines.filter { !$0.trimmingCharacters(in: .whitespaces).isEmpty }
|
||||||
|
return nonEmptyLines.joined(separator: "\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
static nonisolated func insertEmptyLineAfterFirstLine(_ text: String) -> String {
|
||||||
|
var lines = text.components(separatedBy: .newlines)
|
||||||
|
if !lines.isEmpty {
|
||||||
|
lines.insert("", at: 1)
|
||||||
|
}
|
||||||
|
return lines.joined(separator: "\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,235 @@
|
|||||||
|
//
|
||||||
|
// ViewController.swift
|
||||||
|
// Note
|
||||||
|
//
|
||||||
|
// Created by fish on 2026/7/12.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
class ViewController: UIViewController {
|
||||||
|
|
||||||
|
private var tableView: UITableView!
|
||||||
|
private var editButton: UIBarButtonItem!
|
||||||
|
|
||||||
|
private let menuOrderKey = "homeMenuOrder"
|
||||||
|
|
||||||
|
private struct MenuItem {
|
||||||
|
let icon: String
|
||||||
|
let iconColor: UIColor
|
||||||
|
let title: String
|
||||||
|
let identifier: String
|
||||||
|
}
|
||||||
|
|
||||||
|
private let defaultMenuItems: [MenuItem] = [
|
||||||
|
MenuItem(icon: "tray.full", iconColor: .systemIndigo, title: "收集箱", identifier: "inbox"),
|
||||||
|
MenuItem(icon: "note.text", iconColor: .systemYellow, title: "打开备忘录", identifier: "notes"),
|
||||||
|
MenuItem(icon: "doc.text", iconColor: .systemBlue, title: "格式化日志", identifier: "formatLog"),
|
||||||
|
MenuItem(icon: "text.alignleft", iconColor: .systemGreen, title: "格式化笔记", identifier: "formatNote"),
|
||||||
|
MenuItem(icon: "folder", iconColor: .systemOrange, title: "打开文件", identifier: "files")
|
||||||
|
]
|
||||||
|
|
||||||
|
private var menuItems: [[MenuItem]] = []
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
menuItems = [loadMenuOrder()]
|
||||||
|
setupUI()
|
||||||
|
setupAppStateObserver()
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
|
super.viewWillAppear(animated)
|
||||||
|
updateInboxBadge()
|
||||||
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
NotificationCenter.default.removeObserver(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setupAppStateObserver() {
|
||||||
|
NotificationCenter.default.addObserver(
|
||||||
|
self,
|
||||||
|
selector: #selector(appDidBecomeActive),
|
||||||
|
name: UIApplication.didBecomeActiveNotification,
|
||||||
|
object: nil
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func appDidBecomeActive() {
|
||||||
|
updateInboxBadge()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setupUI() {
|
||||||
|
title = "首页"
|
||||||
|
navigationController?.navigationBar.prefersLargeTitles = true
|
||||||
|
navigationItem.largeTitleDisplayMode = .always
|
||||||
|
view.backgroundColor = .systemGroupedBackground
|
||||||
|
|
||||||
|
editButton = UIBarButtonItem(title: "编辑", style: .plain, target: self, action: #selector(didTapEditButton))
|
||||||
|
navigationItem.rightBarButtonItem = editButton
|
||||||
|
|
||||||
|
tableView = UITableView(frame: .zero, style: .insetGrouped)
|
||||||
|
tableView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
tableView.delegate = self
|
||||||
|
tableView.dataSource = self
|
||||||
|
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "menuCell")
|
||||||
|
tableView.backgroundColor = .systemGroupedBackground
|
||||||
|
view.addSubview(tableView)
|
||||||
|
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
tableView.topAnchor.constraint(equalTo: view.topAnchor),
|
||||||
|
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||||
|
tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
||||||
|
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func didTapEditButton() {
|
||||||
|
tableView.setEditing(!tableView.isEditing, animated: true)
|
||||||
|
editButton.title = tableView.isEditing ? "完成" : "编辑"
|
||||||
|
}
|
||||||
|
|
||||||
|
private func loadMenuOrder() -> [MenuItem] {
|
||||||
|
guard let savedOrder = UserDefaults.standard.array(forKey: menuOrderKey) as? [String] else {
|
||||||
|
return defaultMenuItems
|
||||||
|
}
|
||||||
|
|
||||||
|
var orderedItems: [MenuItem] = []
|
||||||
|
for identifier in savedOrder {
|
||||||
|
if let item = defaultMenuItems.first(where: { $0.identifier == identifier }) {
|
||||||
|
orderedItems.append(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let remaining = defaultMenuItems.filter { item in
|
||||||
|
!orderedItems.contains { $0.identifier == item.identifier }
|
||||||
|
}
|
||||||
|
return orderedItems + remaining
|
||||||
|
}
|
||||||
|
|
||||||
|
private func saveMenuOrder() {
|
||||||
|
let identifiers = menuItems.flatMap { $0.map(\.identifier) }
|
||||||
|
UserDefaults.standard.set(identifiers, forKey: menuOrderKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ViewController: UITableViewDataSource {
|
||||||
|
|
||||||
|
func numberOfSections(in tableView: UITableView) -> Int {
|
||||||
|
return menuItems.count
|
||||||
|
}
|
||||||
|
|
||||||
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||||
|
return menuItems[section].count
|
||||||
|
}
|
||||||
|
|
||||||
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||||
|
let cell = tableView.dequeueReusableCell(withIdentifier: "menuCell", for: indexPath)
|
||||||
|
let item = menuItems[indexPath.section][indexPath.row]
|
||||||
|
|
||||||
|
var config = cell.defaultContentConfiguration()
|
||||||
|
config.text = item.title
|
||||||
|
config.image = UIImage(systemName: item.icon)
|
||||||
|
config.imageProperties.tintColor = item.iconColor
|
||||||
|
config.imageToTextPadding = 12
|
||||||
|
cell.contentConfiguration = config
|
||||||
|
cell.accessoryType = tableView.isEditing ? .none : .disclosureIndicator
|
||||||
|
cell.selectionStyle = tableView.isEditing ? .none : .default
|
||||||
|
|
||||||
|
return cell
|
||||||
|
}
|
||||||
|
|
||||||
|
func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
|
||||||
|
guard sourceIndexPath != destinationIndexPath else { return }
|
||||||
|
|
||||||
|
let item = menuItems[sourceIndexPath.section].remove(at: sourceIndexPath.row)
|
||||||
|
menuItems[destinationIndexPath.section].insert(item, at: destinationIndexPath.row)
|
||||||
|
saveMenuOrder()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ViewController: UITableViewDelegate {
|
||||||
|
|
||||||
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||||
|
tableView.deselectRow(at: indexPath, animated: true)
|
||||||
|
guard !tableView.isEditing else { return }
|
||||||
|
|
||||||
|
let item = menuItems[indexPath.section][indexPath.row]
|
||||||
|
switch item.identifier {
|
||||||
|
case "inbox":
|
||||||
|
let viewController = ClipInboxViewController()
|
||||||
|
navigationController?.pushViewController(viewController, animated: true)
|
||||||
|
case "notes":
|
||||||
|
openSystemNotesApp()
|
||||||
|
case "formatLog":
|
||||||
|
let viewController = FormatLogViewController()
|
||||||
|
navigationController?.pushViewController(viewController, animated: true)
|
||||||
|
case "formatNote":
|
||||||
|
let viewController = FormatNoteViewController()
|
||||||
|
navigationController?.pushViewController(viewController, animated: true)
|
||||||
|
case "files":
|
||||||
|
openFilesApp()
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle {
|
||||||
|
return .none
|
||||||
|
}
|
||||||
|
|
||||||
|
func tableView(_ tableView: UITableView, shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private func updateInboxBadge() {
|
||||||
|
Task {
|
||||||
|
guard let count = try? await ClipStore.shared.count(), count > 0 else {
|
||||||
|
await MainActor.run {
|
||||||
|
self.updateInboxTitle("收集箱")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await MainActor.run {
|
||||||
|
self.updateInboxTitle("收集箱(\(count))")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func updateInboxTitle(_ title: String) {
|
||||||
|
for (sectionIndex, section) in menuItems.enumerated() {
|
||||||
|
for (rowIndex, item) in section.enumerated() {
|
||||||
|
if item.identifier == "inbox" {
|
||||||
|
menuItems[sectionIndex][rowIndex] = MenuItem(
|
||||||
|
icon: item.icon,
|
||||||
|
iconColor: item.iconColor,
|
||||||
|
title: title,
|
||||||
|
identifier: item.identifier
|
||||||
|
)
|
||||||
|
let indexPath = IndexPath(row: rowIndex, section: sectionIndex)
|
||||||
|
tableView.reloadRows(at: [indexPath], with: .none)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func openSystemNotesApp() {
|
||||||
|
openURLIfPossible("mobilenotes://")
|
||||||
|
}
|
||||||
|
|
||||||
|
private func openFilesApp() {
|
||||||
|
openURLIfPossible("shareddocuments://")
|
||||||
|
}
|
||||||
|
|
||||||
|
private func openURLIfPossible(_ string: String) {
|
||||||
|
guard let url = URL(string: string) else { return }
|
||||||
|
guard UIApplication.shared.canOpenURL(url) else { return }
|
||||||
|
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
/* Simplified Chinese localization */
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>NSExtension</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSExtensionAttributes</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSExtensionActivationRule</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSExtensionActivationSupportsFileWithMaxCount</key>
|
||||||
|
<integer>10</integer>
|
||||||
|
<key>NSExtensionActivationSupportsText</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>NSExtensionPointIdentifier</key>
|
||||||
|
<string>com.apple.share-services</string>
|
||||||
|
<key>NSExtensionPrincipalClass</key>
|
||||||
|
<string>$(PRODUCT_MODULE_NAME).ShareViewController</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>com.apple.security.application-groups</key>
|
||||||
|
<array>
|
||||||
|
<string>group.com.fishestlife.note</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
import UIKit
|
||||||
|
import UniformTypeIdentifiers
|
||||||
|
|
||||||
|
class ShareViewController: UIViewController {
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
handleSharedItems()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func handleSharedItems() {
|
||||||
|
guard let items = extensionContext?.inputItems as? [NSExtensionItem] else {
|
||||||
|
closeExtension()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let fileManager = FileManager.default
|
||||||
|
guard let containerURL = fileManager.containerURL(forSecurityApplicationGroupIdentifier: "group.com.fishestlife.note") else {
|
||||||
|
closeExtension()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let sharedDir = containerURL.appendingPathComponent("SharedFiles", isDirectory: true)
|
||||||
|
try? fileManager.createDirectory(at: sharedDir, withIntermediateDirectories: true)
|
||||||
|
|
||||||
|
var sharedTexts: [String] = []
|
||||||
|
var sharedFileNames: [String] = []
|
||||||
|
let group = DispatchGroup()
|
||||||
|
|
||||||
|
for item in items {
|
||||||
|
guard let attachments = item.attachments else { continue }
|
||||||
|
|
||||||
|
for attachment in attachments {
|
||||||
|
group.enter()
|
||||||
|
|
||||||
|
if attachment.hasItemConformingToTypeIdentifier(UTType.plainText.identifier) {
|
||||||
|
attachment.loadItem(forTypeIdentifier: UTType.plainText.identifier, options: nil) { data, _ in
|
||||||
|
defer { group.leave() }
|
||||||
|
if let text = data as? String {
|
||||||
|
sharedTexts.append(text)
|
||||||
|
} else if let url = data as? URL, let text = try? String(contentsOf: url, encoding: .utf8) {
|
||||||
|
sharedTexts.append(text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if attachment.hasItemConformingToTypeIdentifier(UTType.url.identifier) {
|
||||||
|
attachment.loadItem(forTypeIdentifier: UTType.url.identifier, options: nil) { data, _ in
|
||||||
|
defer { group.leave() }
|
||||||
|
if let url = data as? URL, let text = try? String(contentsOf: url, encoding: .utf8) {
|
||||||
|
sharedTexts.append(text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
attachment.loadItem(forTypeIdentifier: UTType.data.identifier, options: nil) { data, _ in
|
||||||
|
defer { group.leave() }
|
||||||
|
if let url = data as? URL {
|
||||||
|
let destURL = sharedDir.appendingPathComponent(url.lastPathComponent)
|
||||||
|
try? fileManager.removeItem(at: destURL)
|
||||||
|
if (try? fileManager.copyItem(at: url, to: destURL)) != nil {
|
||||||
|
sharedFileNames.append(url.lastPathComponent)
|
||||||
|
}
|
||||||
|
} else if let fileData = data as? Data {
|
||||||
|
let fileName = "shared-\(UUID().uuidString).md"
|
||||||
|
let destURL = sharedDir.appendingPathComponent(fileName)
|
||||||
|
if (try? fileData.write(to: destURL)) != nil {
|
||||||
|
sharedFileNames.append(fileName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
group.notify(queue: .main) { [weak self] in
|
||||||
|
self?.openMainApp(texts: sharedTexts, fileNames: sharedFileNames)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func openMainApp(texts: [String], fileNames: [String]) {
|
||||||
|
var components = URLComponents(string: "noteapp://share")!
|
||||||
|
var queryItems: [URLQueryItem] = []
|
||||||
|
|
||||||
|
for (index, text) in texts.prefix(5).enumerated() {
|
||||||
|
queryItems.append(URLQueryItem(name: "text\(index)", value: text))
|
||||||
|
}
|
||||||
|
for (index, fileName) in fileNames.prefix(5).enumerated() {
|
||||||
|
queryItems.append(URLQueryItem(name: "file\(index)", value: fileName))
|
||||||
|
}
|
||||||
|
|
||||||
|
components.queryItems = queryItems.isEmpty ? nil : queryItems
|
||||||
|
|
||||||
|
guard let url = components.url else {
|
||||||
|
closeExtension()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
extensionContext?.open(url) { [weak self] _ in
|
||||||
|
self?.closeExtension()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func closeExtension() {
|
||||||
|
extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
def format_md_file(file_path):
|
|
||||||
with open(file_path, 'r', encoding='utf-8') as file:
|
|
||||||
content = file.read()
|
|
||||||
|
|
||||||
# 去#
|
|
||||||
content = content.replace('# ', '')
|
|
||||||
content = content.replace('#', '')
|
|
||||||
# 将;转为句号
|
|
||||||
content = content.replace(';', '。')
|
|
||||||
# 将;转为句号
|
|
||||||
content = content.replace(';', '。')
|
|
||||||
# 将.转为句号
|
|
||||||
content = content.replace('.', '。')
|
|
||||||
# 将(转为(
|
|
||||||
content = content.replace('(', '(')
|
|
||||||
# 将)转为)
|
|
||||||
content = content.replace(')', ')')
|
|
||||||
# 将?转为?
|
|
||||||
content = content.replace('?', '?')
|
|
||||||
# 将,转为,
|
|
||||||
content = content.replace(',', ',')
|
|
||||||
# 将:转为:
|
|
||||||
content = content.replace(':', ':')
|
|
||||||
# 将 日星期 转为:日 星期
|
|
||||||
content = content.replace('日星期', '日 星期')
|
|
||||||
# 在第一行插入 #
|
|
||||||
content = '# ' + content
|
|
||||||
# 标题设置
|
|
||||||
content = content.replace('一、生活方面', '## 一、生活方面')
|
|
||||||
content = content.replace('二、交易方面', '## 二、交易方面')
|
|
||||||
content = content.replace('三、工作方面', '## 三、工作方面')
|
|
||||||
|
|
||||||
with open(file_path, 'w', encoding='utf-8') as file:
|
|
||||||
file.write(content)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
||||||
print(current_dir)
|
|
||||||
for root, dirs, files in os.walk(current_dir):
|
|
||||||
for file in files:
|
|
||||||
if file.endswith('.md'):
|
|
||||||
file_path = os.path.join(root, file)
|
|
||||||
format_md_file(file_path)
|
|
||||||
Reference in New Issue
Block a user