删除项目文件备份
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "note_app_logo_appstore.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"filename" : "note_app_logo_appstore 1.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "tinted"
|
||||
}
|
||||
],
|
||||
"filename" : "note_app_logo_appstore 2.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"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" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
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 |
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
@@ -1,151 +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 showEmptyAlert: Bool = false
|
||||
@State private var showCopied: Bool = false
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
VStack(spacing: 0) {
|
||||
inputArea
|
||||
.frame(maxHeight: .infinity)
|
||||
|
||||
actionArea
|
||||
}
|
||||
.background(Color(.systemGroupedBackground).ignoresSafeArea())
|
||||
.navigationTitle("文案格式化")
|
||||
.navigationBarTitleDisplayMode(.large)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .topBarTrailing) {
|
||||
MoreMenuBarButton(text: $inputText, showCopied: $showCopied)
|
||||
}
|
||||
}
|
||||
.alert("提示", isPresented: $showEmptyAlert) {
|
||||
Button("确定", role: .cancel) {}
|
||||
} message: {
|
||||
Text("请输入需要格式化的文案")
|
||||
}
|
||||
.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 var inputArea: some View {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Text("输入")
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(.secondary)
|
||||
.padding(.horizontal)
|
||||
|
||||
TextEditor(text: $inputText)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.padding(12)
|
||||
.background(Color(.systemBackground))
|
||||
.cornerRadius(12)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 12)
|
||||
.stroke(Color(.systemGray4), lineWidth: 1)
|
||||
)
|
||||
.padding(.horizontal)
|
||||
.toolbar {
|
||||
ToolbarItemGroup(placement: .keyboard) {
|
||||
Spacer()
|
||||
Button("完成") {
|
||||
dismissKeyboard()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text("粘贴需要格式化的文案")
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(.secondary)
|
||||
.padding(.horizontal)
|
||||
}
|
||||
.padding(.vertical, 8)
|
||||
}
|
||||
|
||||
private var actionArea: some View {
|
||||
Button(action: formatText) {
|
||||
Label("格式化", systemImage: "wand.and.stars")
|
||||
.font(.headline)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding()
|
||||
.background(Color(.systemBackground))
|
||||
.foregroundStyle(Color.accentColor)
|
||||
.cornerRadius(12)
|
||||
}
|
||||
.padding()
|
||||
.background(Color(.systemGroupedBackground))
|
||||
}
|
||||
|
||||
private func dismissKeyboard() {
|
||||
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
|
||||
}
|
||||
|
||||
private func formatText() {
|
||||
if inputText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
showEmptyAlert = true
|
||||
return
|
||||
}
|
||||
|
||||
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: "## 三、工作方面")
|
||||
|
||||
inputText = content
|
||||
dismissKeyboard()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#Preview {
|
||||
FormatterView()
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
//
|
||||
// MoreMenuBarButton.swift
|
||||
// Note
|
||||
//
|
||||
// Created by fish on 2026/7/12.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct MoreMenuBarButton: UIViewRepresentable {
|
||||
@Binding var text: String
|
||||
@Binding var showCopied: Bool
|
||||
|
||||
func makeUIView(context: Context) -> UIView {
|
||||
let button = makeGlassButton()
|
||||
button.menu = context.coordinator.makeMenu()
|
||||
button.showsMenuAsPrimaryAction = true
|
||||
|
||||
let barButtonItem = UIBarButtonItem(customView: button)
|
||||
context.coordinator.barButtonItem = barButtonItem
|
||||
context.coordinator.button = button
|
||||
|
||||
return button
|
||||
}
|
||||
|
||||
func updateUIView(_ uiView: UIView, context: Context) {
|
||||
context.coordinator.button?.menu = context.coordinator.makeMenu()
|
||||
}
|
||||
|
||||
func makeCoordinator() -> Coordinator {
|
||||
Coordinator(self)
|
||||
}
|
||||
|
||||
private func makeGlassButton() -> UIButton {
|
||||
let button = UIButton(type: .system)
|
||||
button.setImage(UIImage(systemName: "ellipsis"), for: .normal)
|
||||
button.tintColor = UIColor.label
|
||||
button.frame = CGRect(x: 0, y: 0, width: 44, height: 44)
|
||||
button.layer.cornerRadius = 22
|
||||
button.clipsToBounds = true
|
||||
|
||||
let blurEffect = UIBlurEffect(style: .systemUltraThinMaterial)
|
||||
let blurView = UIVisualEffectView(effect: blurEffect)
|
||||
blurView.frame = button.bounds
|
||||
blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
||||
blurView.isUserInteractionEnabled = false
|
||||
button.insertSubview(blurView, at: 0)
|
||||
|
||||
return button
|
||||
}
|
||||
|
||||
class Coordinator {
|
||||
var parent: MoreMenuBarButton
|
||||
weak var barButtonItem: UIBarButtonItem?
|
||||
weak var button: UIButton?
|
||||
|
||||
init(_ parent: MoreMenuBarButton) {
|
||||
self.parent = parent
|
||||
}
|
||||
|
||||
func makeMenu() -> UIMenu {
|
||||
let copyAction = UIAction(
|
||||
title: "复制",
|
||||
image: UIImage(systemName: "doc.on.doc"),
|
||||
attributes: parent.text.isEmpty ? .disabled : [],
|
||||
handler: { [weak self] _ in
|
||||
UIPasteboard.general.string = self?.parent.text ?? ""
|
||||
self?.parent.showCopied = true
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
|
||||
self?.parent.showCopied = false
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
let clearAction = UIAction(
|
||||
title: "清除",
|
||||
image: UIImage(systemName: "xmark.circle"),
|
||||
attributes: parent.text.isEmpty ? [.disabled, .destructive] : .destructive,
|
||||
handler: { [weak self] _ in
|
||||
self?.parent.text = ""
|
||||
}
|
||||
)
|
||||
|
||||
return UIMenu(title: "", children: [copyAction, clearAction])
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user