Skip to content

Commit

Permalink
下层一些样式
Browse files Browse the repository at this point in the history
  • Loading branch information
ming1016 committed May 26, 2024
1 parent 7816275 commit 5c4cf50
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 175 deletions.
61 changes: 0 additions & 61 deletions README5.md

This file was deleted.

16 changes: 12 additions & 4 deletions SwiftPamphletApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
08026C512869B43500792EF1 /* Table(ap).md in Resources */ = {isa = PBXBuildFile; fileRef = 08026C502869B41B00792EF1 /* Table(ap).md */; };
08026C522869B43D00792EF1 /* SF Symbol(ap).md in Resources */ = {isa = PBXBuildFile; fileRef = 08026C3E2869AD7800792EF1 /* SF Symbol(ap).md */; };
08026C532869B44400792EF1 /* macOS技术演进(ap).md in Resources */ = {isa = PBXBuildFile; fileRef = 08026C3F2869B00D00792EF1 /* macOS技术演进(ap).md */; };
0805F4962BAAABEA0008BB52 /* ViewStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0805F4952BAAABEA0008BB52 /* ViewStyle.swift */; };
08069CAB2BDE01E800D48E24 /* GuideListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08069CAA2BDE01E800D48E24 /* GuideListView.swift */; };
08069CAD2BDE7A6B00D48E24 /* GuideDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08069CAC2BDE7A6B00D48E24 /* GuideDetailView.swift */; };
0820367A2C02EEA7002FB5E3 /* SMUI in Frameworks */ = {isa = PBXBuildFile; productRef = 082036792C02EEA7002FB5E3 /* SMUI */; };
0825E4872BC6596F00332378 /* EditCustomSearchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0825E4862BC6596F00332378 /* EditCustomSearchView.swift */; };
08397E252B9EEE1300DFDD02 /* InfoListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08397E242B9EEE1300DFDD02 /* InfoListView.swift */; };
08397E292B9F0A9100DFDD02 /* EditInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08397E282B9F0A9100DFDD02 /* EditInfoView.swift */; };
Expand Down Expand Up @@ -354,7 +354,6 @@
08026C402869B1BF00792EF1 /* 性能技术演进(ap).md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = "性能技术演进(ap).md"; sourceTree = "<group>"; };
08026C422869B22E00792EF1 /* Regex(ap).md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = "Regex(ap).md"; sourceTree = "<group>"; };
08026C502869B41B00792EF1 /* Table(ap).md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = "Table(ap).md"; sourceTree = "<group>"; };
0805F4952BAAABEA0008BB52 /* ViewStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewStyle.swift; sourceTree = "<group>"; };
08069CAA2BDE01E800D48E24 /* GuideListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuideListView.swift; sourceTree = "<group>"; };
08069CAC2BDE7A6B00D48E24 /* GuideDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuideDetailView.swift; sourceTree = "<group>"; };
0825E4862BC6596F00332378 /* EditCustomSearchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditCustomSearchView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -660,6 +659,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
0820367A2C02EEA7002FB5E3 /* SMUI in Frameworks */,
086923412BF2BFCC006779A3 /* AVKit.framework in Frameworks */,
0868D00B2BDD37280023C871 /* SMGitHub in Frameworks */,
08448F4E279E8CA400B61353 /* Ink in Frameworks */,
Expand Down Expand Up @@ -1274,7 +1274,6 @@
086A5F512744EF4C00FECE02 /* ViewComponent.swift */,
08A9E1A12BC25D0700A73764 /* ViewComponentMarkdown.swift */,
08F14B432BBE2865005B46CC /* ViewComponentImage.swift */,
0805F4952BAAABEA0008BB52 /* ViewStyle.swift */,
);
path = ViewComponet;
sourceTree = "<group>";
Expand Down Expand Up @@ -1642,6 +1641,7 @@
3ACA74FA2BD7964A0024B18E /* SMFile */,
3A46DEF42BD7AAB2008AD993 /* SMDate */,
0868D00A2BDD37280023C871 /* SMGitHub */,
082036792C02EEA7002FB5E3 /* SMUI */,
);
productName = SwiftPamphletApp;
productReference = 086A5F032744E88E00FECE02 /* 戴铭的开发小册子.app */;
Expand Down Expand Up @@ -1683,6 +1683,7 @@
3ACA74F92BD7964A0024B18E /* XCLocalSwiftPackageReference "SwiftPamphletApp/SharePackage/SMFile" */,
3A46DEF32BD7AAB2008AD993 /* XCLocalSwiftPackageReference "SwiftPamphletApp/SharePackage/SMDate" */,
0868D0092BDD37280023C871 /* XCLocalSwiftPackageReference "SwiftPamphletApp/SharePackage/SMGitHub" */,
082036782C02EEA7002FB5E3 /* XCLocalSwiftPackageReference "SwiftPamphletApp/SharePackage/SMUI" */,
);
productRefGroup = 086A5F042744E88E00FECE02 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -2014,7 +2015,6 @@
08A7FF312BEB02EA00E12E5A /* GithubAccessTokenView.swift in Sources */,
086A5F372744ED9600FECE02 /* UserView.swift in Sources */,
086A5F522744EF4C00FECE02 /* ViewComponent.swift in Sources */,
0805F4962BAAABEA0008BB52 /* ViewStyle.swift in Sources */,
08CD61FF27758B8A008C0935 /* Token.swift in Sources */,
3AE0D59E2BAB183100D6D925 /* EditDeveloper.swift in Sources */,
08EF35D22BECFDA80098E2D4 /* BookmarkModel.swift in Sources */,
Expand Down Expand Up @@ -2246,6 +2246,10 @@
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
082036782C02EEA7002FB5E3 /* XCLocalSwiftPackageReference "SwiftPamphletApp/SharePackage/SMUI" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = SwiftPamphletApp/SharePackage/SMUI;
};
0868D0092BDD37280023C871 /* XCLocalSwiftPackageReference "SwiftPamphletApp/SharePackage/SMGitHub" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = SwiftPamphletApp/SharePackage/SMGitHub;
Expand Down Expand Up @@ -2312,6 +2316,10 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
082036792C02EEA7002FB5E3 /* SMUI */ = {
isa = XCSwiftPackageProductDependency;
productName = SMUI;
};
08397E312B9F39C100DFDD02 /* SwiftSoup */ = {
isa = XCSwiftPackageProductDependency;
package = 08397E302B9F39C100DFDD02 /* XCRemoteSwiftPackageReference "SwiftSoup" */;
Expand Down
1 change: 1 addition & 0 deletions SwiftPamphletApp/App/IntroView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import SwiftUI
import MarkdownUI
import SMFile
import SMUI

struct LightingView<Content: View>: View {
@Environment(\.colorScheme) var colorSchemeMode
Expand Down
3 changes: 2 additions & 1 deletion SwiftPamphletApp/InfoOrganizer/Info/EditInfoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import PhotosUI
import InfoOrganizer
import SMFile
import SMNetwork
import SMUI

struct EditInfoView: View {
@Environment(\.modelContext) var modelContext
Expand Down Expand Up @@ -203,7 +204,7 @@ struct EditInfoView: View {
if info.imageUrls.isEmpty == false {
LazyVGrid(columns: [GridItem(.adaptive(minimum: 150), spacing: 10)]) {
ForEach(info.imageUrls, id:\.self) { img in
NukeImage(url: img)
NukeImage(height: 150, url: img)
.contextMenu {
Button {
IOInfo.updateCoverImage(info: info, img: IOImg(url: img))
Expand Down
40 changes: 40 additions & 0 deletions SwiftPamphletApp/Resource/Guide/SwiftUI/图文组件/Image(ap).md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
![](https://ming1016.github.io/qdimg/240505/image-ap01.png)

## Image 使用

```swift
struct PlayImageView: View {
var body: some View {
Expand Down Expand Up @@ -30,3 +32,41 @@ struct PlayImageView: View {
}
}
```

## AsyncImage

```swift
struct AsyncImageWithPlaceholder: View {
enum Size {
case tinySize, smallSize,normalSize, bigSize

var v: CGFloat {
switch self {
case .tinySize:
return 20
case .smallSize:
return 40
case .normalSize:
return 60
case .bigSize:
return 100
}
}
}
var size: Size
var url: String
var body: some View {
AsyncImage(url: URL(string: url), content: { image in
image
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: size.v, height: size.v)
.cornerRadius(5)
},
placeholder: {
Image(systemName: "person")
.frame(width: size.v, height: size.v)
})
}
}
```
8 changes: 8 additions & 0 deletions SwiftPamphletApp/SharePackage/SMUI/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
24 changes: 24 additions & 0 deletions SwiftPamphletApp/SharePackage/SMUI/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// swift-tools-version: 5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "SMUI",
platforms: [.iOS(.v17), .macOS(.v14)],
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "SMUI",
targets: ["SMUI"]),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "SMUI"),
.testTarget(
name: "SMUITests",
dependencies: ["SMUI"]),
]
)
36 changes: 36 additions & 0 deletions SwiftPamphletApp/SharePackage/SMUI/Sources/SMUI/SMUI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// The Swift Programming Language
// https://docs.swift.org/swift-book
import SwiftUI

// MARK: Text
extension Text {
public func gradientTitle(color: Color = .primary) -> some View {
self
.font(.largeTitle)
.fontWeight(.bold)
.foregroundStyle(color.gradient)
.fontDesign(.rounded)
}
}

// MARK: TextEidtor
extension TextEditor {
public func border() -> some View {
self
.overlay(
Rectangle()
.stroke(.secondary, lineWidth: 1)
.opacity(0.5)
)
.disableAutocorrection(true)
}
}

// MARK: TextField
// 圆角
extension TextField {
public func rounded() -> some View {
self
.textFieldStyle(RoundedBorderTextFieldStyle())
}
}
12 changes: 12 additions & 0 deletions SwiftPamphletApp/SharePackage/SMUI/Tests/SMUITests/SMUITests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import XCTest
@testable import SMUI

final class SMUITests: XCTestCase {
func testExample() throws {
// XCTest Documentation
// https://developer.apple.com/documentation/xctest

// Defining Test Cases and Test Methods
// https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods
}
}
32 changes: 0 additions & 32 deletions SwiftPamphletApp/ViewComponet/ViewComponentImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,4 @@ struct NukeImage: View {
}
}

struct AsyncImageWithPlaceholder: View {
enum Size {
case tinySize, smallSize,normalSize, bigSize

var v: CGFloat {
switch self {
case .tinySize:
return 20
case .smallSize:
return 40
case .normalSize:
return 60
case .bigSize:
return 100
}
}
}
var size: Size
var url: String
var body: some View {
AsyncImage(url: URL(string: url), content: { image in
image
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: size.v, height: size.v)
.cornerRadius(5)
},
placeholder: {
Image(systemName: "person")
.frame(width: size.v, height: size.v)
})
}
}
Loading

0 comments on commit 5c4cf50

Please sign in to comment.