Skip to content

Commit

Permalink
refactor: clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Sep 20, 2022
1 parent c3f63a5 commit 2e7952e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 80 deletions.
11 changes: 4 additions & 7 deletions PlantUML/PlantUMLEditorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ struct PlantUMLEditorView: View {
@Environment(\.openURL) private var openURL

@EnvironmentObject private var diagram: PlantUMLDiagramObject

@ObservedObject var customKeyboard = CustomKeyboardObject()

@Binding var document: PlantUMLDocument

Expand All @@ -35,10 +33,9 @@ struct PlantUMLEditorView: View {
GeometryReader { _ in
HStack {
EditorView()
.onReceive( customKeyboard.$itemsToAdd ) { items in
// print( "\(items)")
appendBelow(values: items)
}
// .onReceive( customKeyboard.$itemsToAdd ) { items in
// appendBelow(values: items)
// }
if !isPreviewVisible {
PlantUMLDiagramView( url: diagram.buildURL() )
}
Expand Down Expand Up @@ -137,7 +134,7 @@ struct PlantUMLEditorView: View {
}
}

PlantUMLTextFieldWithCustomKeyboard( value: item.rawValue, onChange: updateItem )
PlantUMLTextFieldWithCustomKeyboard( item: item, onChange: updateItem )
.focused($focusedItem, equals: .row(id: item.id))
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@

import UIKit
import SwiftUI
import PlantUMLFramework

public struct PlantUMLTextFieldWithCustomKeyboard : UIViewRepresentable {
public typealias ChangeHandler = ( String ) -> Void
public typealias UIViewType = UITextField
private let textField = UITextField()


public var value:String
public var item:SyntaxStructure
public var onChange:ChangeHandler

public init( value:String, onChange:@escaping ChangeHandler ) {
self.value = value
public init( item:SyntaxStructure, onChange:@escaping ChangeHandler ) {
self.item = item
self.onChange = onChange
}

Expand All @@ -33,7 +34,7 @@ public struct PlantUMLTextFieldWithCustomKeyboard : UIViewRepresentable {
textField.autocapitalizationType = .none
textField.font = UIFont.monospacedSystemFont(ofSize: 15, weight: .regular)
textField.returnKeyType = .done
textField.text = value
textField.text = item.rawValue
return textField
}

Expand Down

0 comments on commit 2e7952e

Please sign in to comment.