openswiftui
OpenSwiftui เป็นการใช้งาน OpenSource ของ Swiftui DSL ของ Apple (ภาษาเฉพาะโดเมน)
เป้าหมายของโครงการคือการอยู่ใกล้กับ API ดั้งเดิมที่สุดเท่าที่จะทำได้
ปัจจุบันโครงการนี้อยู่ในระหว่างการพัฒนาก่อน
พื้นหลัง
Apple แนะนำ Swiftui ที่ WWDC 19 ตั้งแต่นั้นมาการพัฒนาแอพพลิเคชั่นที่มีส่วนต่อประสานกับผู้ใช้กราฟิกก็สะดวกสบายในการอ่านเขียนและบำรุงรักษา น่าเสียดายที่หลักการ "เรียนรู้หนึ่งครั้งใช้ทุกที่" ทำงานบนแพลตฟอร์ม Apple เท่านั้น
Swift ทำงานบนแพลตฟอร์ม Apple, Web, Linux, Windows และแม้แต่อุปกรณ์ฝังตัว มันจะไม่ดีถ้าคุณสามารถเขียนแอปพลิเคชันที่ใช้ GUI กับ Swiftui บนแพลตฟอร์มที่รัน Swift?
Swiftui บนแพลตฟอร์มของคุณ
OpenSwiftui จัดเตรียม API - โครงการอื่น ๆ สามารถใช้การเรนเดอร์จริงขององค์ประกอบ UI สำหรับแพลตฟอร์มที่แตกต่างกันเช่น Linux, Windows, Embedded และอื่น ๆ อีกมากมาย
Swiftuiembedded เป็นหนึ่งในโครงการแรกที่ใช้ประโยชน์จาก OpenSwiftui (สาธิต)
การบริจาค
เมื่อเวลาผ่านไปและการคาดเดาร่วมกันควรเป็นไปได้ที่จะสร้าง Swiftui API ที่สมบูรณ์จาก Apple อีกครั้ง ตรวจสอบภาพรวมสถานะเพื่อดูสิ่งที่ขาดหายไปหรือต้องทำให้เสร็จ
จุดเริ่มต้นที่ดีคือการทำความคุ้นเคยกับอินเทอร์เฟซ Swiftui มุ่งเน้นไปที่ฟังก์ชั่นบางอย่างและพยายามที่จะนำมาใช้ใหม่ เครื่องมือที่มีประโยชน์คือการใช้การสะท้อนกลับ ( Mirror(reflecting: …) ) เพื่อมองเข้าไปในประเภทและอินสแตนซ์ของ Swiftui สิ่งนี้เผยให้เห็นโครงสร้างภายในของอินสแตนซ์ (คุณสมบัติประเภทชื่อและมรดก)
เมื่อคุณใช้งานชิ้นส่วนที่ขาดหายไปโปรดอย่าลังเลที่จะมีส่วนร่วมในคำขอดึง
โปรดทราบ:
วิธีการส่วนตัวและคุณสมบัติของ Swiftui ควรได้รับการแก้ไขโดย _ (ขีดล่าง) และทำเครื่องหมายว่าเป็นสาธารณะใน OpenSwiftui การทำเช่นนี้เป็นสิ่งจำเป็นเพราะส่วนหน้าอาจต้องเข้าถึง
จำเป็นต้องใช้ Xcode 11.2 หรือสูงกว่า
สถานะ
มุมมองและการควบคุม
สิ่งจำเป็น
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| protocol View | |
ข้อความ
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct Text | |
| struct TextField | |
| struct SecureField | |
| struct Font | |
ภาพ
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct Image | ไม่รองรับ CGIMAGE |
ปุ่ม
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct Button | |
| struct NavigationLink | |
| struct MenuButton | |
| struct EditButton | |
| struct PasteButton | |
ตัวเลือกค่า
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct Toggle | |
| struct Picker | |
| struct DatePicker | |
| struct Slider | |
| struct Stepper | |
ประเภทสนับสนุน
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct ViewBuilder | |
| protocol ViewModifier | |
ดูเค้าโครงและการนำเสนอ
กองซ้อน
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct HStack | |
| struct VStack | |
| struct ZStack | |
รายการและมุมมองเลื่อน
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct List | |
| protocol DynamicViewContent | |
| protocol Identifiable | จัดทำโดย Swift |
| struct ForEach | |
| struct ScrollView | |
| enum Axis | |
มุมมองคอนเทนเนอร์
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct Form | |
| struct Group | |
| struct GroupBox | |
| struct Section | |
ตัวเว้นวรรคและตัวแบ่ง
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct Spacer | |
| struct Divider | |
มุมมองทางสถาปัตยกรรม
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct NavigationView | |
| struct TabView | |
| struct HSplitView | |
| struct VSplitView | |
การนำเสนอ
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct Alert | |
| struct ActionSheet | |
รายการที่มองเห็นได้อย่างมีเงื่อนไข
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct EmptyView | |
| struct EquatableView | |
ใช้มุมมองที่ใช้ไม่บ่อยนัก
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct AnyView | init?(_fromValue value: Any) หายไป |
| struct TupleView | |
ภาพวาดและภาพเคลื่อนไหว
สิ่งจำเป็น
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| protocol Shape | |
ความเคลื่อนไหว
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct Animation | |
| protocol Animatable | |
| protocol AnimatableModifier | |
| func withAnimation<Result>(Animation?, () -> Result) -> Result | |
| struct AnimationPair | |
| struct EmptyAnimationData | |
| struct AnyTransition | |
รูปทรง
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct Rectangle | |
| enum Edge | |
| struct RoundedRectangle | |
| struct Circle | |
| struct Ellipse | |
| struct Capsule | |
| struct Path | |
รูปร่างที่เปลี่ยนไป
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| protocol InsettableShape | |
| struct ScaledShape | |
| struct RotatedShape | |
| struct OffsetShape | |
| struct TransformedShape | |
สีสไตล์และการไล่ระดับสี
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct Color | |
| struct ImagePaint | |
| struct Gradient | |
| struct LinearGradient | |
| struct AngularGradient | |
| struct RadialGradient | |
| struct ForegroundStyle | |
| struct FillStyle | |
| protocol ShapeStyle | |
| enum RoundedCornerStyle | |
| struct SelectionShapeStyle | |
| struct SeparatorShapeStyle | |
| struct StrokeStyle | |
เรขาคณิต
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct GeometryProxy | |
| struct GeometryReader | |
| protocol GeometryEffect | |
| struct Angle | |
| struct Anchor | |
| struct UnitPoint | |
| enum CoordinateSpace | |
| struct ProjectionTransform | |
| protocol VectorArithmetic | |
สถานะและการไหลของข้อมูล
การผูกมัด
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct Binding | |
มุมมองที่ขึ้นกับข้อมูล
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct State | |
| struct ObservedObject | |
| struct EnvironmentObject | |
| struct FetchRequest | |
| struct FetchedResults | |
| protocol DynamicProperty | func update() หายไป |
ค่าสภาพแวดล้อม
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct Environment | |
| struct EnvironmentValues | |
การตั้งค่า
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| protocol PreferenceKey | |
| struct LocalizedStringKey | |
การทำธุรกรรม
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct Transaction | |
ท่าทาง
ท่าทางพื้นฐาน
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct TapGesture | |
| struct LongPressGesture | |
| struct DragGesture | |
| struct MagnificationGesture | |
| struct RotationGesture | |
ท่าทางรวมกัน
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct SequenceGesture | |
| struct SimultaneousGesture | |
| struct ExclusiveGesture | |
ท่าทางที่กำหนดเอง
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| protocol Gesture | |
| struct AnyGesture | |
คุณสมบัติมุมมองแบบไดนามิก
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct GestureState | |
| struct GestureStateGesture | |
การสนับสนุนท่าทาง
| สถานะ | ชื่อ | หมายเหตุ |
|---|
| struct GestureMask | |
| struct EventModifiers | |
ตำนาน
| เครื่องหมาย | คำอธิบาย |
|---|
| เสร็จแล้ว |
| เปิด |
| ไม่สมบูรณ์ |
ทรัพยากร
อินเทอร์เฟซ Swiftui
เมื่อเทียบกับสิ่งที่คุณเห็นใน XCode ส่วนสำคัญนี้จะแสดงให้คุณเห็นมากกว่าแค่อินเทอร์เฟซสาธารณะ มันแสดงคุณสมบัติส่วนตัวและร่างกายของคุณสมบัติที่ทำเครื่องหมายไว้ @inlinable ฟังก์ชั่นและ initializers
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/SwiftUI.framework/Versions/A/Modules/SwiftUI.swiftmodule/x86_64.swiftinterface
Swiftwebui
Swiftwebui เป็นการดำเนินการของ Swiftui สำหรับเว็บโดย Helge Heß เป้าหมายของโครงการนี้มุ่งเน้นไปที่เว็บโดยเฉพาะ มันเบี่ยงเบนไปเล็กน้อยจาก Swiftui โดยใช้ทางลัดที่นี่และที่นั่น - แต่ดูค่อนข้างสมบูรณ์ในการใช้งานและเหมาะสำหรับแรงบันดาลใจ
สัญลักษณ์ Swiftui
คำสั่งนี้พิมพ์ตารางสัญลักษณ์ของ Swiftui ผ่านยูทิลิตี้ llvm-mn
nm -gUj /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/SwiftUI.framework/SwiftUI | swift-demangle | sed ' s/SwiftUI.//g ' | sed ' s/Swift.//g '
นอกจากนี้คุณยังสามารถดูที่ส่วนสำคัญนี้แทน
ลิงค์
- ผลลัพธ์ Swiftui @ViewBuilder เป็นทิวทัศน์ทิวทัศน์ Apple ใช้มันอย่างไรและสามารถหลีกเลี่ยงการเปลี่ยนสิ่งต่าง ๆ ให้กลายเป็น Anyview ได้อย่างไร
- https://stackoverflow.com/questions/56434549/ what-enables-swiftuis-dsl
- การสร้างมุมมองที่กำหนดเองด้วย Swiftui
- Swiftui Essentials
- การไหลของข้อมูลผ่าน Swiftui
- แนะนำ Swiftui: การสร้างแอพแรกของคุณ
- Swiftui บนอุปกรณ์ทั้งหมด
ขอบคุณเป็นพิเศษ
ฉันต้องการขอบคุณเป็นพิเศษกับ Helge Heß เขาสร้าง Swiftwebui สนับสนุนคำแนะนำมากมายให้กับ OpenSwiftui และช่วยด้วยข้อมูลเชิงลึกเกี่ยวกับการค้นพบของเขา
ติดต่อ
- Devran "Cosmo" Uenal
- Twitter: @maccosmo
- LinkedIn: devranuenal
ใบอนุญาต
OpenSwiftui เปิดตัวภายใต้ใบอนุญาต MIT