| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- import Foundation
- import ark_ui_basic
- // In a real framework, ark_ui_basic would automatically use ArkGraphics as a render backend.
- // For now, we simulate the backend processing the SwiftUI View graph.
- struct AppUI: View {
- var body: some View {
- ZStack {
- Color.blue
- Button(action: {
- print("Button tapped")
- }) {
- Color.blue
- }
- .background(Color.blue)
- }
- }
- }
- struct UITestApp {
- static let fontMap: [Character: [String]] = [
- "S": [".###.", "#...#", "#....", ".###.", "....#", "#...#", ".###."],
- "t": [".#...", ".###.", ".#...", ".#...", ".#...", ".#..#", "..##."],
- "a": [".....", ".....", ".###.", "....#", ".####", "#...#", ".####"],
- "r": [".....", ".....", "#.##.", "##..#", "#....", "#....", "#...."],
- "G": [".###.", "#...#", "#....", "#.###", "#...#", "#...#", ".###."],
- "e": [".....", ".....", ".###.", "#...#", "#####", "#....", ".###."],
- "s": [".....", ".....", ".###.", "#....", ".###.", "....#", ".###."],
- "d": ["....#", "....#", ".####", "#...#", "#...#", "#...#", ".####"],
- "-": [".....", ".....", ".....", "#####", ".....", ".....", "....."],
- ">": ["#....", ".#...", "..#..", "...#.", "..#..", ".#...", "#...."],
- " ": [".....", ".....", ".....", ".....", ".....", ".....", "....."]
- ]
- static func drawText(_ graphics: ArkGraphics, _ text: String, x: Int, y: Int, size: Int, r: UInt8, g: UInt8, b: UInt8) {
- var cursorX = x
- for char in text {
- if let lines = fontMap[char] {
- for (row, line) in lines.enumerated() {
- var cursorY = y + (row * size)
- for (col, pixel) in line.enumerated() {
- if pixel == "#" {
- graphics.fillRectRGB(x: cursorX + (col * size), y: cursorY, w: size, h: size, r: r, g: g, b: b)
- }
- }
- }
- }
- cursorX += 6 * size
- }
- }
- static func main() {
- print("ui_test: Starting OS Native UI App (Waiting for splash...)")
- sleep(4) // Wait for atom splash animation to finish (approx 3.8s)
- let graphics = ArkGraphics()
- // 1. Bright White Background so we know it's not a black screen!
- graphics.fillRectRGB(x: 0, y: 0, w: 1024, h: 768, r: 255, g: 255, b: 255)
- // 2. Draw "Get started" button (Bright Blue)
- let btn1W = 280
- let btn1H = 60
- let btn1X = (1024 - btn1W) / 2
- let btn1Y = 300
- graphics.fillRectRGB(x: btn1X, y: btn1Y, w: btn1W, h: btn1H, r: 0, g: 122, b: 255)
-
- // 3. Draw "Start ->" button (Green)
- let btn2W = 280
- let btn2H = 60
- let btn2X = (1024 - btn2W) / 2
- let btn2Y = 400
- graphics.fillRectRGB(x: btn2X, y: btn2Y, w: btn2W, h: btn2H, r: 52, g: 199, b: 89)
- // Draw Text! (Black text)
- drawText(graphics, "Get started", x: btn1X + 45, y: btn1Y + 18, size: 3, r: 0, g: 0, b: 0)
- drawText(graphics, "Start ->", x: btn2X + 65, y: btn2Y + 18, size: 3, r: 0, g: 0, b: 0)
- graphics.pan()
- print("ui_test: UI Layout mapped and sent to Display Daemon.")
- while true {
- sleep(1)
- }
- }
- }
- UITestApp.main()
|