patch home
This commit is contained in:
parent
2b306562f8
commit
9d995480a6
@ -1,9 +1,9 @@
|
|||||||
from PySide6.QtWidgets import (
|
from PySide6.QtWidgets import (
|
||||||
QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QFrame,
|
QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QFrame,
|
||||||
QStackedWidget, QSpacerItem, QSizePolicy
|
QStackedWidget, QSpacerItem, QSizePolicy, QGraphicsDropShadowEffect
|
||||||
)
|
)
|
||||||
from PySide6.QtCore import Qt, QSize
|
from PySide6.QtCore import Qt, QSize
|
||||||
from PySide6.QtGui import QIcon
|
from PySide6.QtGui import QIcon, QColor
|
||||||
|
|
||||||
class YobbleHomeView(QWidget):
|
class YobbleHomeView(QWidget):
|
||||||
def __init__(self, username: str):
|
def __init__(self, username: str):
|
||||||
@ -23,7 +23,7 @@ class YobbleHomeView(QWidget):
|
|||||||
# 2. Центральная область контента
|
# 2. Центральная область контента
|
||||||
self.content_stack = QStackedWidget()
|
self.content_stack = QStackedWidget()
|
||||||
self.setup_content_pages()
|
self.setup_content_pages()
|
||||||
main_layout.addWidget(self.content_stack)
|
main_layout.addWidget(self.content_stack, 1) # Растягиваем контент
|
||||||
|
|
||||||
# 3. Нижняя панель навигации
|
# 3. Нижняя панель навигации
|
||||||
bottom_bar = self.create_bottom_bar()
|
bottom_bar = self.create_bottom_bar()
|
||||||
@ -51,25 +51,21 @@ class YobbleHomeView(QWidget):
|
|||||||
return top_bar_widget
|
return top_bar_widget
|
||||||
|
|
||||||
def create_bottom_bar(self):
|
def create_bottom_bar(self):
|
||||||
"""Создает нижнюю панель навигации."""
|
"""Создает нижнюю панель навигации в стиле SwiftUI."""
|
||||||
bottom_bar_widget = QWidget()
|
bottom_bar_widget = QWidget()
|
||||||
bottom_bar_widget.setObjectName("BottomBar")
|
bottom_bar_widget.setObjectName("BottomBar")
|
||||||
# Устанавливаем высоту и убираем лишние отступы, чтобы текст не обрезался
|
|
||||||
bottom_bar_layout = QHBoxLayout(bottom_bar_widget)
|
bottom_bar_layout = QHBoxLayout(bottom_bar_widget)
|
||||||
bottom_bar_layout.setContentsMargins(10, 0, 10, 5) # Уменьшаем верхний и нижний отступы
|
bottom_bar_layout.setContentsMargins(10, 0, 10, 0)
|
||||||
bottom_bar_layout.setSpacing(10)
|
bottom_bar_layout.setSpacing(10)
|
||||||
|
|
||||||
# Создаем кнопки
|
# Создаем кнопки
|
||||||
btn_feed = self.create_tab_button("📄", "Лента", 0)
|
btn_feed = self.create_tab_button("☰", "Лента", 0)
|
||||||
btn_search = self.create_tab_button("🔍", "Поиск", 1)
|
btn_search = self.create_tab_button("🔍", "Поиск", 1)
|
||||||
|
btn_create = self.create_create_button()
|
||||||
btn_chats = self.create_tab_button("💬", "Чаты", 2)
|
btn_chats = self.create_tab_button("💬", "Чаты", 2)
|
||||||
btn_profile = self.create_tab_button("👤", "Лицо", 3)
|
btn_profile = self.create_tab_button("👤", "Лицо", 3)
|
||||||
|
|
||||||
# Центральная кнопка "Создать"
|
|
||||||
btn_create = QPushButton("+")
|
|
||||||
btn_create.setObjectName("CreateButton")
|
|
||||||
btn_create.setFixedSize(50, 50)
|
|
||||||
|
|
||||||
# Добавляем кнопки в макет
|
# Добавляем кнопки в макет
|
||||||
bottom_bar_layout.addWidget(btn_feed)
|
bottom_bar_layout.addWidget(btn_feed)
|
||||||
bottom_bar_layout.addWidget(btn_search)
|
bottom_bar_layout.addWidget(btn_search)
|
||||||
@ -77,6 +73,10 @@ class YobbleHomeView(QWidget):
|
|||||||
bottom_bar_layout.addWidget(btn_chats)
|
bottom_bar_layout.addWidget(btn_chats)
|
||||||
bottom_bar_layout.addWidget(btn_profile)
|
bottom_bar_layout.addWidget(btn_profile)
|
||||||
|
|
||||||
|
# Устанавливаем политику размеров, чтобы кнопки вкладок растягивались
|
||||||
|
for btn in [btn_feed, btn_search, btn_chats, btn_profile]:
|
||||||
|
btn.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
|
||||||
|
|
||||||
# Устанавливаем начальную активную вкладку
|
# Устанавливаем начальную активную вкладку
|
||||||
self.update_tab_selection(2) # Чаты по умолчанию
|
self.update_tab_selection(2) # Чаты по умолчанию
|
||||||
return bottom_bar_widget
|
return bottom_bar_widget
|
||||||
@ -85,10 +85,11 @@ class YobbleHomeView(QWidget):
|
|||||||
"""Фабричный метод для создания кнопок вкладок."""
|
"""Фабричный метод для создания кнопок вкладок."""
|
||||||
button = QPushButton()
|
button = QPushButton()
|
||||||
button.setObjectName("TabButton")
|
button.setObjectName("TabButton")
|
||||||
|
button.setCursor(Qt.PointingHandCursor)
|
||||||
|
|
||||||
layout = QVBoxLayout(button)
|
layout = QVBoxLayout(button)
|
||||||
layout.setContentsMargins(0, 5, 0, 5)
|
layout.setContentsMargins(0, 5, 0, 5)
|
||||||
layout.setSpacing(2)
|
layout.setSpacing(4)
|
||||||
|
|
||||||
icon_label = QLabel(icon_text)
|
icon_label = QLabel(icon_text)
|
||||||
icon_label.setAlignment(Qt.AlignCenter)
|
icon_label.setAlignment(Qt.AlignCenter)
|
||||||
@ -105,6 +106,23 @@ class YobbleHomeView(QWidget):
|
|||||||
button.clicked.connect(lambda: self.on_tab_button_clicked(index))
|
button.clicked.connect(lambda: self.on_tab_button_clicked(index))
|
||||||
return button
|
return button
|
||||||
|
|
||||||
|
def create_create_button(self):
|
||||||
|
"""Создает центральную кнопку 'Создать'."""
|
||||||
|
button = QPushButton("+")
|
||||||
|
button.setObjectName("CreateButton")
|
||||||
|
button.setFixedSize(56, 56)
|
||||||
|
button.setCursor(Qt.PointingHandCursor)
|
||||||
|
|
||||||
|
# Эффект тени
|
||||||
|
shadow = QGraphicsDropShadowEffect(self)
|
||||||
|
shadow.setBlurRadius(18)
|
||||||
|
shadow.setColor(QColor(0, 0, 0, 100))
|
||||||
|
shadow.setOffset(0, 3)
|
||||||
|
button.setGraphicsEffect(shadow)
|
||||||
|
|
||||||
|
# button.clicked.connect(self.on_create_clicked) # Подключите свой слот
|
||||||
|
return button
|
||||||
|
|
||||||
def setup_content_pages(self):
|
def setup_content_pages(self):
|
||||||
"""Создает страницы-заглушки для QStackedWidget."""
|
"""Создает страницы-заглушки для QStackedWidget."""
|
||||||
self.content_stack.addWidget(QLabel("Контент Ленты"))
|
self.content_stack.addWidget(QLabel("Контент Ленты"))
|
||||||
@ -127,6 +145,8 @@ class YobbleHomeView(QWidget):
|
|||||||
if not bottom_bar: return
|
if not bottom_bar: return
|
||||||
|
|
||||||
for button in bottom_bar.findChildren(QPushButton):
|
for button in bottom_bar.findChildren(QPushButton):
|
||||||
|
is_tab_button = button.property("tab_index") is not None
|
||||||
|
if is_tab_button:
|
||||||
if button.property("tab_index") == selected_index:
|
if button.property("tab_index") == selected_index:
|
||||||
button.setProperty("selected", True)
|
button.setProperty("selected", True)
|
||||||
else:
|
else:
|
||||||
@ -140,7 +160,7 @@ class YobbleHomeView(QWidget):
|
|||||||
"""Возвращает QSS стили для компонента."""
|
"""Возвращает QSS стили для компонента."""
|
||||||
return """
|
return """
|
||||||
YobbleHomeView {
|
YobbleHomeView {
|
||||||
background-color: white; /* Фон для основного виджета */
|
background-color: white;
|
||||||
}
|
}
|
||||||
/* Верхняя панель */
|
/* Верхняя панель */
|
||||||
#TopBar {
|
#TopBar {
|
||||||
@ -159,8 +179,10 @@ class YobbleHomeView(QWidget):
|
|||||||
|
|
||||||
/* Нижняя панель */
|
/* Нижняя панель */
|
||||||
#BottomBar {
|
#BottomBar {
|
||||||
background-color: #f5f5f5;
|
background-color: #f8f8f8;
|
||||||
border-top: 1px solid #e0e0e0;
|
border-top: 1px solid #e7e7e7;
|
||||||
|
padding-top: 5px;
|
||||||
|
padding-bottom: 15px; /* Место для тени и отступа */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Кнопки вкладок */
|
/* Кнопки вкладок */
|
||||||
@ -168,12 +190,12 @@ class YobbleHomeView(QWidget):
|
|||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
color: #888;
|
|
||||||
}
|
}
|
||||||
|
#TabButton #TabIcon { color: #888888; }
|
||||||
|
#TabButton #TabText { color: #888888; }
|
||||||
|
|
||||||
|
#TabButton[selected="true"] #TabIcon,
|
||||||
#TabButton[selected="true"] #TabText {
|
#TabButton[selected="true"] #TabText {
|
||||||
color: #007AFF; /* Яркий синий для активной вкладки */
|
|
||||||
}
|
|
||||||
#TabButton[selected="true"] #TabIcon {
|
|
||||||
color: #007AFF;
|
color: #007AFF;
|
||||||
}
|
}
|
||||||
#TabIcon { font-size: 22px; }
|
#TabIcon { font-size: 22px; }
|
||||||
@ -181,14 +203,28 @@ class YobbleHomeView(QWidget):
|
|||||||
|
|
||||||
/* Центральная кнопка "Создать" */
|
/* Центральная кнопка "Создать" */
|
||||||
#CreateButton {
|
#CreateButton {
|
||||||
background-color: #007AFF;
|
|
||||||
color: white;
|
color: white;
|
||||||
font-size: 24px;
|
font-size: 30px;
|
||||||
font-weight: bold;
|
font-weight: 300;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 25px; /* Делает ее круглой */
|
border-radius: 28px; /* 56px / 2 */
|
||||||
|
background-color: qlineargradient(
|
||||||
|
x1: 0, y1: 0, x2: 0, y2: 1,
|
||||||
|
stop: 0 #007AFF, stop: 1 #0056b3
|
||||||
|
);
|
||||||
|
/* "Приподнимаем" кнопку */
|
||||||
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
#CreateButton:hover {
|
#CreateButton:hover {
|
||||||
background-color: #0056b3;
|
background-color: qlineargradient(
|
||||||
|
x1: 0, y1: 0, x2: 0, y2: 1,
|
||||||
|
stop: 0 #0088FF, stop: 1 #0066c3
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#CreateButton:pressed {
|
||||||
|
background-color: qlineargradient(
|
||||||
|
x1: 0, y1: 0, x2: 0, y2: 1,
|
||||||
|
stop: 0 #0056b3, stop: 1 #004493
|
||||||
|
);
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
Loading…
x
Reference in New Issue
Block a user