Skip to content

Commit

Permalink
chore: tweak input styling
Browse files Browse the repository at this point in the history
  • Loading branch information
x86y committed Oct 18, 2023
1 parent 3533d03 commit 5234794
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 27 deletions.
23 changes: 7 additions & 16 deletions Beacon/Components/ReplInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,20 @@ struct ReplInput: View {
.disableAutocorrection(true)
.font(font)
.frame(minHeight: 36)
.padding(EdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 48))
.padding(EdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16))
.overlay(
RoundedRectangle(cornerRadius: 48)
.stroke(.gray.opacity(0.25), lineWidth: 1)
).modifier(EvalButton(onSubmit: onSubmit))
}
}
}

struct EvalButton: ViewModifier {
var onSubmit: (() -> Void)?

public func body(content: Content) -> some View {
ZStack(alignment: .trailing) {
content
.stroke(.gray.opacity(0.2), lineWidth: 1)
)
Button(action: {
onSubmit?()
}) {
Image(systemName: "restart.circle")
Image(systemName: "play.circle.fill")
.resizable()
.frame(width: 36.0, height: 36.0)
.frame(width: 32.0, height: 32.0)
.foregroundStyle(.blue.opacity(0.9))
}
.padding(8)
.padding(4)
}
}
}
2 changes: 1 addition & 1 deletion Beacon/Utilities/Lexer.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// LexK.swift
// Lexer.swift
// Arrayground
//

Expand Down
2 changes: 0 additions & 2 deletions Beacon/Utilities/Tokenizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func colorK(_ type: TokenType, _ isDarkTheme: Bool) -> Color {
return Color(hex: colorHex)
}


extension Color {
init(hex: String) {
let scanner = Scanner(string: hex)
Expand All @@ -71,7 +70,6 @@ extension Color {
}
}


enum TokenType: String, Codable {
case regC = "0"
case fnsC = "1"
Expand Down
4 changes: 2 additions & 2 deletions Beacon/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ struct ContentView: View {
let output = UserDefaults.standard.integer(forKey: "lang") == Language.bqn.rawValue
? e(input: input)
: ke(input: input)

let attr = CSSearchableItemAttributeSet(contentType: .item)
attr.title = input
attr.contentDescription = output
attr.displayName = input
let uid = UUID().uuidString
let item = CSSearchableItem(uniqueIdentifier: uid, domainIdentifier: "arrscience.beacons", attributeSet: attr)
CSSearchableIndex.default().indexSearchableItems([item])

viewModel.addMessage(with: input, out: output, lang: lang, for: curBuffer)
} else {
isFocused = false
Expand Down
8 changes: 3 additions & 5 deletions Beacon/Views/HelpView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func toDict(h: String) -> [String: String] {
return helpDict
}


// taken from ngn/k/repl.k
let kh: String = """
--------------------------------------------------------------------------------
Expand Down Expand Up @@ -214,7 +213,7 @@ struct HelpCard: View {
let key: String
let value: String
@State var isExpanded: Bool = false

var body: some View {
VStack {
Button(action: { self.isExpanded.toggle() }) {
Expand Down Expand Up @@ -242,9 +241,9 @@ struct HelpView: View {
let helpDict: [String: String]

init() {
self.helpDict = toDict(h: kh)
helpDict = toDict(h: kh)
}

var body: some View {
ScrollView {
ForEach(helpDict.keys.sorted(), id: \.self) { key in
Expand All @@ -256,7 +255,6 @@ struct HelpView: View {
}
}


#Preview {
HelpView()
}
2 changes: 1 addition & 1 deletion Beacon/Views/HistoryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct HistoryView: View {
let isDarkTheme = (scheme == .dark)
let col = historyItem.lang == Language.k ? colorK(token.type, isDarkTheme) : colorBQN(token.type)
Text(token.value)
.lineLimit(1) // HACK to stop long tokens from messing alignment
.lineLimit(1) // HACK to stop long tokens from messing alignment
.foregroundColor(col)
.font(Font.custom("BQN386 Unicode", size: 18))
.onTapGesture {
Expand Down

0 comments on commit 5234794

Please sign in to comment.