Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 230a9ad260 | |||
| ce9d1cff19 | |||
| 7d42eec98c | |||
| 677b860395 | |||
| 849a5e40e4 | |||
| 65aa5980ac |
@@ -150,7 +150,6 @@
|
||||
INFOPLIST_FILE = Note/Info.plist;
|
||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
|
||||
INFOPLIST_KEY_UIMainStoryboardFile = Main;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 26.0;
|
||||
@@ -183,7 +182,6 @@
|
||||
INFOPLIST_FILE = Note/Info.plist;
|
||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
|
||||
INFOPLIST_KEY_UIMainStoryboardFile = Main;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 26.0;
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// FormatLogViewController.swift
|
||||
// Note
|
||||
//
|
||||
// Created by fish on 2026/7/12.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class FormatLogViewController: UIViewController {
|
||||
|
||||
private var textView: UITextView!
|
||||
private var formatButton: UIButton!
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
title = "格式化日志"
|
||||
navigationItem.largeTitleDisplayMode = .never
|
||||
view.backgroundColor = .systemGroupedBackground
|
||||
setupUI()
|
||||
}
|
||||
|
||||
private func setupUI() {
|
||||
textView = UITextView()
|
||||
textView.translatesAutoresizingMaskIntoConstraints = false
|
||||
textView.font = UIFont.systemFont(ofSize: 16)
|
||||
textView.backgroundColor = .white
|
||||
textView.layer.cornerRadius = 12
|
||||
textView.textContainerInset = UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12)
|
||||
view.addSubview(textView)
|
||||
|
||||
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
|
||||
view.addSubview(formatButton)
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
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)
|
||||
])
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -15,8 +15,7 @@
|
||||
<string>Default Configuration</string>
|
||||
<key>UISceneDelegateClassName</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
|
||||
<key>UISceneStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
|
||||
@@ -13,10 +13,13 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
|
||||
|
||||
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
||||
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
|
||||
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
|
||||
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||
guard let _ = (scene as? UIWindowScene) else { return }
|
||||
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()
|
||||
}
|
||||
|
||||
func sceneDidDisconnect(_ scene: UIScene) {
|
||||
|
||||
@@ -9,11 +9,96 @@ import UIKit
|
||||
|
||||
class ViewController: UIViewController {
|
||||
|
||||
private var tableView: UITableView!
|
||||
|
||||
private struct MenuItem {
|
||||
let icon: String
|
||||
let iconColor: UIColor
|
||||
let title: String
|
||||
}
|
||||
|
||||
private let menuItems: [[MenuItem]] = [
|
||||
[
|
||||
MenuItem(icon: "note.text", iconColor: .systemYellow, title: "打开备忘录"),
|
||||
MenuItem(icon: "doc.text", iconColor: .systemBlue, title: "格式化日志"),
|
||||
MenuItem(icon: "text.alignleft", iconColor: .systemGreen, title: "格式化笔记")
|
||||
]
|
||||
]
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
// Do any additional setup after loading the view.
|
||||
setupUI()
|
||||
}
|
||||
|
||||
private func setupUI() {
|
||||
title = "首页"
|
||||
navigationController?.navigationBar.prefersLargeTitles = true
|
||||
navigationItem.largeTitleDisplayMode = .always
|
||||
view.backgroundColor = .systemGroupedBackground
|
||||
|
||||
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)
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
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 = .disclosureIndicator
|
||||
|
||||
return cell
|
||||
}
|
||||
}
|
||||
|
||||
extension ViewController: UITableViewDelegate {
|
||||
|
||||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
tableView.deselectRow(at: indexPath, animated: true)
|
||||
|
||||
let item = menuItems[indexPath.section][indexPath.row]
|
||||
switch item.title {
|
||||
case "打开备忘录":
|
||||
openSystemNotesApp()
|
||||
case "格式化日志":
|
||||
let viewController = FormatLogViewController()
|
||||
navigationController?.pushViewController(viewController, animated: true)
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
private func openSystemNotesApp() {
|
||||
guard let url = URL(string: "mobilenotes://") else { return }
|
||||
guard UIApplication.shared.canOpenURL(url) else { return }
|
||||
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user