Skip to content

Commit 223b8f8

Browse files
authored
Create ui.slint
1 parent 6124d88 commit 223b8f8

File tree

1 file changed

+155
-0
lines changed

1 file changed

+155
-0
lines changed

src/ui.slint

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
import { TabWidget, LineEdit, Button, ListView, HorizontalLayout, VerticalLayout, StandardListView, ComboBox } from "std-widgets.slint";
2+
3+
component AppWindow {
4+
property <[Device]> devices: [];
5+
property <[string]> messages: [];
6+
property <string> my_device_name: "My Device";
7+
property <string> my_ip: "0.0.0.0";
8+
property <string> status_message: "";
9+
10+
callback discover_devices();
11+
callback pair_device(int);
12+
callback disconnect_device(int);
13+
callback send_file(int, string);
14+
callback send_clipboard(int, string);
15+
callback send_message(int, string);
16+
17+
Window {
18+
title: "Hackeros Connect";
19+
width: 800px;
20+
height: 600px;
21+
background: #f0f0f0;
22+
23+
VerticalLayout {
24+
spacing: 10px;
25+
padding: 10px;
26+
27+
Text { text: "My Device: " + root.my_device_name + " (" + root.my_ip + ")"; font-size: 16px; color: #333; }
28+
29+
TabWidget {
30+
Tab {
31+
title: "Devices";
32+
VerticalLayout {
33+
Button {
34+
text: "Discover Devices";
35+
clicked => { root.discover_devices(); }
36+
}
37+
38+
StandardListView {
39+
model: root.devices;
40+
delegate: Rectangle {
41+
background: model-data.paired ? #d4ffd4 : #ffffff;
42+
border-color: #ddd;
43+
border-width: 1px;
44+
HorizontalLayout {
45+
padding: 10px;
46+
Text { text: "📱 "; }
47+
Text { text: model-data.name + " (" + model-data.ip + ":" + model-data.port + ") - " + model-data.status; color: #333; }
48+
if !model-data.paired: Button {
49+
text: "Pair";
50+
clicked => { root.pair_device(model-row); }
51+
}
52+
if model-data.paired: Button {
53+
text: "Disconnect";
54+
clicked => { root.disconnect_device(model-row); }
55+
}
56+
}
57+
}
58+
}
59+
}
60+
}
61+
62+
Tab {
63+
title: "File Transfer";
64+
VerticalLayout {
65+
Text { text: "Select Device and File to Send"; color: #333; }
66+
67+
StandardListView {
68+
model: root.devices;
69+
delegate: HorizontalLayout {
70+
if model-data.paired: {
71+
Text { text: model-data.name; color: #333; }
72+
LineEdit { placeholder-text: "File path"; id: file_path; }
73+
Button {
74+
text: "Send File";
75+
clicked => { root.send_file(model-row, file_path.text); }
76+
}
77+
}
78+
}
79+
}
80+
}
81+
}
82+
83+
Tab {
84+
title: "Clipboard Share";
85+
VerticalLayout {
86+
Text { text: "Select Device and Content to Send"; color: #333; }
87+
88+
StandardListView {
89+
model: root.devices;
90+
delegate: HorizontalLayout {
91+
if model-data.paired: {
92+
Text { text: model-data.name; color: #333; }
93+
LineEdit { placeholder-text: "Clipboard content"; id: clipboard_content; }
94+
Button {
95+
text: "Send Clipboard";
96+
clicked => { root.send_clipboard(model-row, clipboard_content.text); }
97+
}
98+
}
99+
}
100+
}
101+
}
102+
}
103+
104+
Tab {
105+
title: "Chat";
106+
VerticalLayout {
107+
Text { text: "Select Device and Send Message"; color: #333; }
108+
109+
ComboBox {
110+
model: root.devices;
111+
text-role: "name";
112+
id: device_combo;
113+
}
114+
115+
HorizontalLayout {
116+
LineEdit { placeholder-text: "Type message"; id: chat_input; width: parent.width - 100px; }
117+
Button {
118+
text: "Send";
119+
clicked => { root.send_message(device_combo.current_index, chat_input.text); chat_input.text = ""; }
120+
}
121+
}
122+
123+
ListView {
124+
model: root.messages;
125+
delegate: Rectangle {
126+
background: #ffffff;
127+
border-color: #ddd;
128+
border-width: 1px;
129+
padding: 5px;
130+
Text { text: model-data; color: #333; }
131+
}
132+
}
133+
}
134+
}
135+
136+
Tab {
137+
title: "Settings";
138+
VerticalLayout {
139+
Text { text: "Settings: Ports, etc. (Coming soon)"; color: #333; }
140+
}
141+
}
142+
}
143+
144+
Text { text: root.status_message; color: #007bff; }
145+
}
146+
}
147+
}
148+
149+
struct Device {
150+
name: string,
151+
ip: string,
152+
port: string,
153+
status: string,
154+
paired: bool,
155+
}

0 commit comments

Comments
 (0)