This commit is contained in:
2025-09-06 10:15:14 +02:00
parent cf1e7bba24
commit bae1572d3f
11 changed files with 1076 additions and 675 deletions

74
widgets/customer_card.py Normal file
View File

@@ -0,0 +1,74 @@
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from .location_card import ActiveLocationCard, InactiveLocationCard
class ActiveCustomerCard:
def __init__(self, customer, callbacks):
self.customer = customer
self.callbacks = callbacks
self.widget = self._create_widget()
def _create_widget(self):
# GNOME-style card container
card_frame = Gtk.Frame()
card_frame.get_style_context().add_class("card")
card_frame.set_shadow_type(Gtk.ShadowType.NONE) # Shadow handled by CSS
card_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
card_frame.add(card_vbox)
# Customer header
customer_label = Gtk.Label()
customer_label.set_markup(f"<b><big>🏢 {self.customer.name}</big></b>")
customer_label.set_halign(Gtk.Align.START)
card_vbox.pack_start(customer_label, False, False, 0)
# Locations section
for i, location in enumerate(self.customer.locations):
if i > 0: # Add separator between locations
separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
separator.set_margin_top(8)
separator.set_margin_bottom(8)
card_vbox.pack_start(separator, False, False, 0)
location_card = ActiveLocationCard(location, self.customer.name, self.callbacks)
card_vbox.pack_start(location_card.widget, False, False, 0)
return card_frame
class InactiveCustomerCard:
def __init__(self, customer, callbacks):
self.customer = customer
self.callbacks = callbacks
self.widget = self._create_widget()
def _create_widget(self):
# GNOME-style card container
card_frame = Gtk.Frame()
card_frame.get_style_context().add_class("card")
card_frame.set_shadow_type(Gtk.ShadowType.NONE) # Shadow handled by CSS
card_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
card_frame.add(card_vbox)
# Customer header - muted
customer_label = Gtk.Label()
customer_label.set_markup(f"<span alpha='60%'><b><big>🏢 {self.customer.name}</big></b></span>")
customer_label.set_halign(Gtk.Align.START)
card_vbox.pack_start(customer_label, False, False, 0)
# Locations section
for i, location in enumerate(self.customer.locations):
if i > 0: # Add separator between locations
separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
separator.set_margin_top(8)
separator.set_margin_bottom(8)
card_vbox.pack_start(separator, False, False, 0)
location_card = InactiveLocationCard(location, self.customer.name, self.callbacks)
card_vbox.pack_start(location_card.widget, False, False, 0)
return card_frame