-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// | ||
// SwiftUIExample.swift | ||
// Example | ||
// | ||
// Created by Andrew Breckenridge on 10/3/20. | ||
// Copyright © 2020 Nathan Tannar. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import SwiftUI | ||
import InputBarAccessoryView | ||
|
||
var built: CommonTableViewController? | ||
|
||
struct CommonTableViewControllerUI: UIViewControllerRepresentable { | ||
let style: InputBarStyle | ||
let conversation: SampleData.Conversation | ||
|
||
var inputBar: InputBarAccessoryView { | ||
if built == nil { | ||
built = CommonTableViewController(style: style, conversation: conversation) | ||
} | ||
return built!.inputBar | ||
} | ||
|
||
func makeUIViewController(context: Context) -> some UIViewController { | ||
if built == nil { | ||
built = CommonTableViewController(style: style, conversation: conversation) | ||
} | ||
return built! | ||
} | ||
|
||
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) { | ||
} | ||
} | ||
|
||
struct InputBarUI: UIViewRepresentable { | ||
let view: InputBarAccessoryView | ||
|
||
func makeUIView(context: Context) -> some UIView { | ||
return view | ||
} | ||
|
||
func updateUIView(_ uiView: UIViewType, context: Context) { | ||
} | ||
} | ||
|
||
|
||
public struct SwiftUIExample: View { | ||
let style: InputBarStyle | ||
let conversation: SampleData.Conversation | ||
|
||
var table: CommonTableViewControllerUI { | ||
CommonTableViewControllerUI(style: style, conversation: conversation) | ||
} | ||
|
||
|
||
public var body: some View { | ||
VStack { | ||
self.table | ||
InputBarUI(view: table.inputBar) | ||
} | ||
} | ||
|
||
} | ||
|
||
extension SwiftUIExample { | ||
static func make(style: InputBarStyle, conversation: SampleData.Conversation) -> Self { | ||
return Self.init(style: style, conversation: conversation) | ||
} | ||
} |