SwiftUI View that can be used in combination with other frameworks

View and Modifier that can be used by importing various frameworks in addition to SwiftUI.

MapKit You can use Map.

Sample code

import SwiftUI
import MapKit

struct SwiftUIView: View {
    @State var region: MKCoordinateRegion
    var body: some View {
        Map(coordinateRegion: $region)
    }
}

struct SwiftUIView_Previews: PreviewProvider {
    static var previews: some View {
        let initialCoordinate = CLLocationCoordinate2DMake(40,40)
        let span = MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5)
        let region = MKCoordinateRegion(center: initialCoordinate, span: span)
        
        return SwiftUIView(region: region)
    }
}

preview

スクリーンショット 2020-11-14 11.34.52.png

SpriteKit You can use SpriteView. The GameScene file is the one used when the Xcode project was created on Multiplatform.

Sample code

import SwiftUI
import SpriteKit

struct SwiftUIView: View {
    let scene: SKScene
    var body: some View {
        SpriteView(scene: scene)
    }
}

struct SwiftUIView_Previews: PreviewProvider {
    static var previews: some View {
        guard let scene = SKScene(fileNamed: "GameScene") as? GameScene else {
            abort()
        }
        scene.scaleMode = .aspectFit

        return SwiftUIView(scene: scene)
    }
}

preview

スクリーンショット 2020-11-14 11.36.21.png

AuthenticationServices You can use SignInWithAppleButton.

Sample code

import SwiftUI
import AuthenticationServices

struct SwiftUIView: View {
    var body: some View {
        SignInWithAppleButton(.continue) { _ in
            
        } onCompletion: { _ in
            
        }
        .frame(width: 300.0, height: 44.0)
        .signInWithAppleButtonStyle(.black)
    }
}

struct SwiftUIView_Previews: PreviewProvider {
    static var previews: some View {
        SwiftUIView()
    }
}

preview

スクリーンショット 2020-11-14 11.54.47.png

StoreKit You can use appStoreOverlay.

Sample code

import SwiftUI
import StoreKit

struct SwiftUIView: View {
    @State var showOverlay:Bool = false
    var body: some View {
        Button("App Store Overlay") {
            self.showOverlay.toggle()
        }
        .appStoreOverlay(isPresented: $showOverlay) {
            SKOverlay.AppConfiguration(appIdentifier: "687721425", position: .bottom)
        }
    }
}

struct SwiftUIView_Previews: PreviewProvider {
    static var previews: some View {
        return SwiftUIView()
    }
}

preview

スクリーンショット 2020-11-14 11.46.41.png

AVKit You can use VideoPlayer. The documentation says A view that displays the video content from a player object along with system-supplied playback controls., but with tvOS it feels like there is no control.

Sample code

import SwiftUI
import AVKit

struct SwiftUIView: View {
    let player: AVPlayer?
    var body: some View {
        VideoPlayer(player: player)
    }
}

struct SwiftUIView_Previews: PreviewProvider {
    static var previews: some View {
        return SwiftUIView(player: AVPlayer(url: URL(string: "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8")!))
    }
}

preview

スクリーンショット 2020-11-14 11.34.07.png

SceneKit You can use SceneView. Please prepare your own scn file.

Sample code

import SwiftUI
import SceneKit

struct SwiftUIView: View {
    let scene: SCNScene?
    var body: some View {
        SceneView(scene: scene)
    }
}

struct SwiftUIView_Previews: PreviewProvider {
    static var previews: some View {
        let scene = SCNScene(named: "Scene.scn")
        
        return SwiftUIView(scene: scene)
    }
}

preview

スクリーンショット 2020-11-14 11.32.49.png

HomeKit You can use CameraView. You will need HMCameraSource, but it probably cannot be prepared in SwiftUI preview, so please check it on your own.

Sample code

import SwiftUI
import HomeKit

struct SwiftUIView: View {
    let cameraSource:HMCameraSource
    var body: some View {
        CameraView(source: cameraSource)
    }
}

image

IMG_1F757207E2D1-1.jpeg

WatchKit You can use NowPlayingView.

Sample code

import SwiftUI
import WatchKit

struct SwiftUIView: View {
    var body: some View {
        NowPlayingView()
    }
}

struct SwiftUIView_Previews: PreviewProvider {
    static var previews: some View {
        SwiftUIView()
    }
}

preview

スクリーンショット 2020-11-14 11.39.10.png

Summary

Let's use it! HomeKit!

Recommended Posts

SwiftUI View that can be used in combination with other frameworks
Organize methods that can be used with StringUtils
[Ruby] Methods that can be used with strings
Ruby array methods that can be used with Rails (other than each)
Convenient shortcut keys that can be used in Eclipse
Summary of css selectors that can be used with Nookogiri
Create a page control that can be used with RecyclerView
Firebase-Realtime Database on Android that can be used with copy
Syntax and exception occurrence conditions that can be used when comparing with null in Java
Summary of ORM "uroboroSQL" that can be used in enterprise Java
Simple slot machine implementation that can be used with copy and paste
[Rails] "pry-rails" that can be used when saving with the create method
Performance analysis and failure diagnostic tools that can be used with OpenJDK
Technology excerpt that can be used for creating EC sites in Java training
Basic functional interface that can be understood in 3 minutes
Write a class that can be ordered in Java
Scala String can be used other than java.lang.String method
About the matter that hidden_field can be used insanely
Ruby on Rails 5 quick learning practice guide that can be used in the field Summary
[Java 8] Sorting method in alphabetical order and string length order that can be used in coding tests
Learning Ruby with AtCoder Beginners Selection [Some Sums] Increase the methods that can be used
List of devices that can be previewed in Swift UI
Create a jar file that can be executed in Gradle
The case that @Autowired could not be used in JUnit5
Four-in-a-row with gravity that can be played on the console
[Question] Can nullif be used in the count function in JPQL?
Introduction to Rakefile that can be done in about 10 minutes
Java (super beginner edition) that can be understood in 180 seconds
[rails] Problems that cannot be registered / logged in with devise
Object-oriented design that can be used when you want to return a response in form format
Reference memo / In-memory LDAP server that can be embedded in Java
Static analysis tool that can be used on GitHub [Java version]
Build an environment where pip3 can be used with CentOS7 + Python3
Note that system properties including JAXBContext cannot be used in Java11
File form status check sheet that can be deleted with thumbnails
I made a question that can be used for a technical interview
Power skills that can be used quickly at any time --Reflection
Summary of JDK that can be installed with Homebrew (as of November 2019)
Introduction to Java that can be understood even with Krillin (Part 1)
[Java 8] Until converting standard input that can be used in coding tests into a list or array
How to override in a model unit test so that Faker can be used to generate random values
[Spring Boot] List of validation rules that can be used in the property file for error messages
Set the access load that can be changed graphically with JMeter (Part 2)
Java file input / output processing that can be used through historical background
About the problem that the server can not be started with rails s
Set the access load that can be changed graphically with JMeter (Part 1)
Library summary that seems to be often used in recent Android development (2019/11)
[Android Studio] Description that can be continuously input in SQLite Database [Java]
[ERROR message display] A simplified version that can be used at any time with the rails partial template.
[Swift] Color Picker that can be used with copy and paste (palette that allows you to freely select colors)