splits/Splits/LaTeXView.swift

34 lines
757 B
Swift

//
// LaTeXView.swift
// Paces
//
// Created by Isaac Greene on 2023-01-16.
//
import SwiftUI
import UIKit
import iosMath
struct MathView: UIViewRepresentable {
var latex: String
@Environment(\.colorScheme) var colorScheme
func makeUIView(context: Context) -> MTMathUILabel {
let label = MTMathUILabel()
label.latex = latex
label.textColor = textColor(for: colorScheme)
return label
}
func updateUIView(_ uiView: MTMathUILabel, context: Context) {
uiView.latex = latex
uiView.textColor = textColor(for: colorScheme)
}
private func textColor(for colorScheme: ColorScheme) -> UIColor {
return colorScheme == .dark ? .white : .black
}
}