updated with main screen

This commit is contained in:
2025-06-02 16:16:16 +03:00
parent 5baca9f3be
commit 94c64a9dec
5 changed files with 95 additions and 5 deletions

Binary file not shown.

3
info.txt Normal file
View File

@@ -0,0 +1,3 @@
python -m venv track
source track/bin/activate
pip install -r reqirements.txt

44
main.py
View File

@@ -148,8 +148,8 @@ class SettingsScreen(Screen):
self.ids.result_label.text = f"Failed to save settings: {str(e)}"
# Home Screen
class HomeScreen(Screen):
# Get Trip From Server Screen
class GetTripFromServer(Screen): # Renamed from HomeScreen
server_info_text = StringProperty("LOADING DATA...") # Default text for the label
server_box_color = ListProperty([0.984, 0.553, 0.078, 1]) # Default yellow color (#FB8D14)
device_mapping = {} # Store the mapping of device names to IDs
@@ -255,8 +255,6 @@ class HomeScreen(Screen):
popup = Popup(title="Select a Date", content=layout, size_hint=(0.8, 0.8))
popup.open()
def get_trip_server_data(self):
"""Handle the Get trip server data button press."""
selected_device = self.ids.devices_spinner.text
@@ -331,6 +329,43 @@ class RegisterScreen(Screen):
except Exception as e:
self.ids.result_label.text = f"Error checking user: {str(e)}"
return False
# Home Screen
class HomeScreen(Screen):
def on_pre_enter(self):
"""Load existing projects/trips when the screen is entered."""
self.load_existing_projects()
def load_existing_projects(self):
"""Load the list of existing projects/trips."""
projects_folder = os.path.join(RESOURCES_FOLDER, "projects")
if not os.path.exists(projects_folder):
os.makedirs(projects_folder)
# Clear the list area
self.ids.projects_list.clear_widgets()
# Populate the list with existing projects/trips
for project in os.listdir(projects_folder):
project_button = Button(
text=project,
size_hint_y=None,
height=40,
on_press=lambda instance: self.open_project(instance.text)
)
self.ids.projects_list.add_widget(project_button)
def open_project(self, project_name):
"""Handle opening an existing project/trip."""
print(f"Opening project: {project_name}")
self.ids.result_label.text = f"Opened project: {project_name}"
def create_new_project(self):
"""Navigate to the GetTripFromServer screen to create a new project/trip."""
self.manager.current = "get_trip_from_server"
# Main App
class TraccarApp(App):
def build(self):
@@ -345,6 +380,7 @@ class TraccarApp(App):
sm = ScreenManager()
sm.add_widget(LoginScreen(name="login"))
sm.add_widget(HomeScreen(name="home")) # Add the HomeScreen
sm.add_widget(GetTripFromServer(name="get_trip_from_server")) # Updated reference
sm.add_widget(SettingsScreen(name="settings")) # Add the renamed SettingsScreen
sm.add_widget(RegisterScreen(name="register")) # Add the RegisterScreen

View File

@@ -1 +1 @@
gAAAAABoPZqrY8gNIQXxQ_TAwdtbkZWX-zhwrx7hLuBFXH0M47fThQkAAG0vi8pMJhRnFipZ7t2Nj7SoVhjQqwHo4WOs7IH7lJCKSReeQT-1MdB0fYG16foBJpxK29kz-F9YRjCELQ0m
gAAAAABoPaPrItydUFVvwuzoJNOIF45pusZlJtW62JzZ74gfMb04ZfpUkkZq2Vl7TVSruG0_vH9b-ig_WFInrvwSTcxxN1hRN3Xz9yLdgZ_7qfE3qFS_KZpNtjW_5l9Fj5gpDAXJwX2v

View File

@@ -145,6 +145,47 @@
size_hint: (1, 0.2)
<HomeScreen>:
BoxLayout:
orientation: "vertical"
padding: 10
spacing: 10
canvas.before:
Color:
rgba: 0.11, 0.10, 0.15, 1 # Background color: #1C1A27
Rectangle:
pos: self.pos
size: self.size
Label:
text: "Welcome to Home Screen"
font_size: 24
size_hint_y: None
height: 50
color: 1, 1, 1, 1 # White text color
ScrollView:
size_hint: (1, 0.6)
GridLayout:
id: projects_list
cols: 1
size_hint_y: None
height: self.minimum_height
Button:
text: "Create New Project / Trip"
size_hint_y: None
height: 50
background_color: 0.341, 0.235, 0.980, 1 # Purple color (#573CFA)
on_press: root.create_new_project()
Label:
id: result_label
text: ""
size_hint_y: None
height: 30
color: 1, 1, 1, 1 # White text color
<GetTripFromServer>:
BoxLayout:
orientation: "vertical"
padding: 20
@@ -242,6 +283,16 @@
font_size: 14 # Reduced font size
size_hint: (1, 0.8)
# Fourth row: Back to Home button
Button:
text: "Back to Home"
size_hint_y: None
height: 50
size_hint_x: 0.8
pos_hint: {"center_x": 0.5}
background_color: 0.341, 0.235, 0.980, 1 # Purple color (#573CFA)
on_press: app.root.current = "home"
<SettingsScreen>:
BoxLayout:
orientation: "vertical"