openswiftui
OpenSwiftuiは、AppleのSwiftui DSL(ドメイン固有の言語)のOpenSource実装です。
プロジェクトの目標は、可能な限り元のAPIの近くにとどまることです。
現在、このプロジェクトは早期開発中です。
背景
AppleはWWDC 19でSwiftuiを導入しました。それ以来、グラフィカルユーザーインターフェイスを使用したアプリケーションの開発により、読み書きが快適になりました。残念ながら、原則は「一度学習し、どこでも適用する」という原則は、Appleプラットフォームでのみ動作します。
Swiftは、Appleプラットフォーム、Web、Linux、Windows、さらには組み込みデバイスで実行されます。 Swiftを実行するプラットフォームにSwiftuiを使用してGUIベースのアプリケーションを書くことができれば、それは素晴らしいことではないでしょうか?
プラットフォーム上のswiftui
OpenSwiftuiはAPIを提供します。他のプロジェクトでは、Linux、Windows、EmbeddedなどのさまざまなプラットフォームにUI要素の実際のレンダリングを実装できます。
Swiftuiembededは、OpenSwiftui(DEMO)を使用する最初のプロジェクトの1つです。
貢献
時間と集合的な推測の経過とともに、Appleの完全なSwiftui APIを再作成することが可能であるはずです。ステータスの概要を確認して、不足しているか、完了する必要があるかを確認してください。
良い出発点は、SwiftUIインターフェイスに精通し、特定の機能に焦点を合わせ、再実装を試みることです。役立つツールは、リフレクション( Mirror(reflecting: …) )を使用して、Swiftuiの種類とインスタンスを覗くことです。これにより、インスタンスの内部構造(プロパティ、タイプ、名前、継承)が明らかになります。
不足しているピースを実装したら、お気軽にプルリクエストを提供してください。
ご注意ください:
Swiftuiのプライベート方法と特性は、 _ (アンダースコア)が付けられ、Openswiftuiで公開されているとマークされる必要があります。フロントエンドにアクセスが必要になる場合があるため、これを行うことが必要です。
Xcode 11.2以上が必要です。
状態
ビューとコントロール
必需品
文章
| 状態 | 名前 | メモ |
|---|
| ✅ | 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 | |
描画とアニメーション
必需品
アニメーション
| 状態 | 名前 | メモ |
|---|
| 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 State | |
| struct ObservedObject | |
| struct EnvironmentObject | |
| struct FetchRequest | |
| struct FetchedResults | |
| ショ和 | protocol DynamicProperty | func update()欠落。 |
環境値
| 状態 | 名前 | メモ |
|---|
| ✅ | struct Environment | |
| ✅ | struct EnvironmentValues | |
好み
| 状態 | 名前 | メモ |
|---|
| protocol PreferenceKey | |
| struct LocalizedStringKey | |
トランザクション
ジェスチャー
基本的なジェスチャー
| 状態 | 名前 | メモ |
|---|
| 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で見ることができるものと比較して、このGISTは公共インターフェイスだけではありません。プライベートプロパティ、および@inlinableマークされたプロパティ、関数、および初期化剤の本文が表示されます。
/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は、HelgeHeßによるWeb向けのSwiftuiの実装です。このプロジェクトの目標は、Webのみに焦点を当てています。あちこちでいくつかのショートカットを撮ることで、Swiftuiから少し逸脱していますが、機能は非常に完全に見え、インスピレーションに最適です。
Swiftuiシンボル
このコマンドはllvm-mnユーティリティを介してSwiftuiのシンボルテーブルを印刷します。
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の結果はTupleviewです。Appleはどのようにそれを使用しており、物事をAnyviewに変えることを避けることができますか?
- https://stackoverflow.com/questions/56434549/what-enables-swiftuis-dsl
- Swiftuiでカスタムビューを構築します
- Swiftui Essentials
- Swiftuiを介したデータフロー
- Swiftuiの紹介:最初のアプリを構築します
- すべてのデバイスのswiftui
特別なありがとう
HelgeHeßに特別な感謝を捧げたいです。彼はSwiftWebuiを作成し、OpenSwiftuiに多くの提案を提供し、彼の発見の洞察を手伝いました。
接触
- デボラン「コスモ」卒業
- Twitter:@maccosmo
- LinkedIn:Devranuenal
ライセンス
OpenSwiftuiはMITライセンスの下でリリースされます。