From 5234794fc5ac4491a6834471b91da2ececafaa64 Mon Sep 17 00:00:00 2001 From: x86y Date: Wed, 18 Oct 2023 10:55:05 +0400 Subject: [PATCH] chore: tweak input styling --- Beacon/Components/ReplInput.swift | 23 +++++++---------------- Beacon/Utilities/Lexer.swift | 2 +- Beacon/Utilities/Tokenizer.swift | 2 -- Beacon/Views/ContentView.swift | 4 ++-- Beacon/Views/HelpView.swift | 8 +++----- Beacon/Views/HistoryView.swift | 2 +- 6 files changed, 14 insertions(+), 27 deletions(-) diff --git a/Beacon/Components/ReplInput.swift b/Beacon/Components/ReplInput.swift index 72e71a4..dca6246 100644 --- a/Beacon/Components/ReplInput.swift +++ b/Beacon/Components/ReplInput.swift @@ -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) } } } diff --git a/Beacon/Utilities/Lexer.swift b/Beacon/Utilities/Lexer.swift index be3b4bd..cb01d7a 100644 --- a/Beacon/Utilities/Lexer.swift +++ b/Beacon/Utilities/Lexer.swift @@ -1,5 +1,5 @@ // -// LexK.swift +// Lexer.swift // Arrayground // diff --git a/Beacon/Utilities/Tokenizer.swift b/Beacon/Utilities/Tokenizer.swift index 3a9cd2d..4d9298e 100644 --- a/Beacon/Utilities/Tokenizer.swift +++ b/Beacon/Utilities/Tokenizer.swift @@ -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) @@ -71,7 +70,6 @@ extension Color { } } - enum TokenType: String, Codable { case regC = "0" case fnsC = "1" diff --git a/Beacon/Views/ContentView.swift b/Beacon/Views/ContentView.swift index d1944df..d8a33d8 100644 --- a/Beacon/Views/ContentView.swift +++ b/Beacon/Views/ContentView.swift @@ -40,7 +40,7 @@ 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 @@ -48,7 +48,7 @@ struct ContentView: View { 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 diff --git a/Beacon/Views/HelpView.swift b/Beacon/Views/HelpView.swift index bc9b056..9cb51e5 100644 --- a/Beacon/Views/HelpView.swift +++ b/Beacon/Views/HelpView.swift @@ -18,7 +18,6 @@ func toDict(h: String) -> [String: String] { return helpDict } - // taken from ngn/k/repl.k let kh: String = """ -------------------------------------------------------------------------------- @@ -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() }) { @@ -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 @@ -256,7 +255,6 @@ struct HelpView: View { } } - #Preview { HelpView() } diff --git a/Beacon/Views/HistoryView.swift b/Beacon/Views/HistoryView.swift index 6c017fb..5db421a 100644 --- a/Beacon/Views/HistoryView.swift +++ b/Beacon/Views/HistoryView.swift @@ -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 {