first commit

This commit is contained in:
PeymanHonarjoo
2026-10-06 09:57:33 +03:30
parent fe4dfeb2ec
commit 268a431c1e
48 changed files with 10443 additions and 1782 deletions
+376
View File
@@ -0,0 +1,376 @@
.settings-page {
min-height: 100vh;
}
.settings-header {
animation: fadeInDown 0.4s ease-out;
}
.settings-card {
animation: fadeInUp 0.5s ease-out;
}
.settings-tabs {
position: relative;
}
.tab-btn {
position: relative;
}
.tab-btn.tab-active {
color: var(--color-primary);
}
.tab-btn .tab-indicator {
animation: slideIn 0.3s ease-out;
}
.settings-content {
animation: fadeIn 0.3s ease-out;
}
.section-header {
animation: fadeInDown 0.3s ease-out;
}
.dropzone {
position: relative;
overflow: hidden;
}
.dropzone::before {
content: '';
position: absolute;
inset: 0;
background: linear-gradient(135deg, var(--color-primary)/5 0%, transparent 50%);
opacity: 0;
transition: opacity 0.3s ease;
}
.dropzone:hover::before,
.dropzone-active::before {
opacity: 1;
}
.dropzone-active {
border-color: var(--color-primary) !important;
background-color: var(--color-primary)/10 !important;
transform: scale(1.01);
box-shadow: 0 0 0 3px var(--color-primary)/20, 0 10px 40px var(--color-primary)/10;
}
.dropzone-icon-wrapper {
animation: bounce 2s infinite;
}
.dropzone-active .dropzone-icon-wrapper {
animation: pulse 1s infinite;
}
.file-list {
animation: slideUp 0.4s ease-out;
}
.file-item {
animation: slideInRight 0.3s ease-out;
}
.file-item:nth-child(1) { animation-delay: 0.05s; }
.file-item:nth-child(2) { animation-delay: 0.1s; }
.file-item:nth-child(3) { animation-delay: 0.15s; }
.file-item:nth-child(4) { animation-delay: 0.2s; }
.file-item:nth-child(5) { animation-delay: 0.25s; }
.file-icon-wrapper {
transition: all 0.2s ease;
}
.file-item:hover .file-icon-wrapper {
background-color: var(--color-primary)/20;
transform: scale(1.05);
}
.file-remove-btn {
transition: all 0.2s ease;
}
.setting-item {
animation: fadeInUp 0.4s ease-out;
}
.setting-item:nth-child(1) { animation-delay: 0.05s; }
.setting-item:nth-child(2) { animation-delay: 0.1s; }
.setting-item:nth-child(3) { animation-delay: 0.15s; }
.setting-item:nth-child(4) { animation-delay: 0.2s; }
.form-select {
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: left 0.75rem center;
padding-left: 2.5rem;
}
.form-select:focus {
box-shadow: 0 0 0 3px var(--color-primary)/20;
}
.toggle-switch {
position: relative;
display: inline-flex;
height: 1.5rem;
width: 2.75rem;
flex-shrink: 0;
cursor: pointer;
align-items: center;
justify-content: flex-start;
padding: 0.125rem;
border-radius: 9999px;
border: 2px solid transparent;
transition: all 0.2s ease-in-out;
background-color: var(--toggle-bg);
box-sizing: border-box;
}
.toggle-switch input {
position: absolute;
opacity: 0;
width: 0;
height: 0;
}
.toggle-slider {
pointer-events: none;
display: inline-block;
height: 1.25rem;
width: 1.25rem;
border-radius: 9999px;
background-color: var(--toggle-slider);
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
position: relative;
}
.toggle-slider::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 0.5rem;
height: 0.5rem;
border-radius: 50%;
background-color: var(--toggle-slider);
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
opacity: 1;
}
.toggle-switch input:checked + .toggle-slider {
transform: translateX(-1.25rem);
background-color: var(--toggle-slider);
box-shadow: 0 2px 8px var(--color-primary)/40, 0 0 0 2px var(--color-primary)/20;
}
.toggle-switch input:checked + .toggle-slider::after {
background-color: var(--toggle-slider);
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}
.toggle-switch:has(input:checked) {
background-color: var(--color-primary);
border-color: var(--color-primary);
}
.toggle-switch.toggle-active {
background-color: var(--color-primary)/15;
border-color: var(--color-primary)/25;
}
.toggle-switch:focus-within {
outline: none;
box-shadow: 0 0 0 3px var(--color-primary)/30;
}
.toggle-switch:hover {
background-color: var(--color-primary)/10;
}
.toggle-switch:hover:has(input:checked) {
background-color: var(--color-primary);
}
.toggle-switch:hover.toggle-active {
background-color: var(--color-primary)/20;
}
@keyframes fadeInDown {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes slideUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes slideInRight {
from {
opacity: 0;
transform: translateX(20px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
@keyframes slideIn {
from {
width: 0;
opacity: 0;
}
to {
width: 1.5rem;
opacity: 1;
}
}
@keyframes bounce {
0%, 20%, 50%, 80%, 100% {
transform: translateY(0);
}
40% {
transform: translateY(-5px);
}
60% {
transform: translateY(-3px);
}
}
@keyframes pulse {
0%, 100% {
transform: scale(1);
}
50% {
transform: scale(1.1);
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
@media (max-width: 640px) {
.settings-page {
padding: 1rem;
}
.settings-card {
border-radius: 1rem;
}
.settings-tabs {
flex-direction: column;
}
.tab-btn {
justify-content: flex-start;
padding: 1rem;
}
.tab-btn .tab-indicator {
display: none;
}
.tab-btn.tab-active {
background-color: var(--color-primary)/10;
}
.dropzone {
padding: 2rem 1rem;
}
.setting-item {
flex-direction: column;
align-items: flex-start;
gap: 1rem;
}
.setting-control {
width: 100%;
justify-content: flex-end;
}
.form-select {
width: 100%;
}
}
[data-bs-theme="dark"] .dropzone-icon-wrapper svg,
[data-bs-theme="dark"] .file-icon-wrapper svg,
[data-bs-theme="dark"] .section-header svg {
stroke: var(--color-primary);
}
[data-bs-theme="dark"] .form-select {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
[data-bs-theme="dark"] .file-remove-btn:hover {
background-color: rgba(239, 68, 68, 0.15);
}
[data-bs-theme="dark"] .toggle-switch input:checked + .toggle-slider {
box-shadow: 0 1px 3px var(--color-primary)/40, 0 0 0 2px var(--color-primary)/30;
}
[data-bs-theme="dark"] .settings-card,
[data-bs-theme="dark"] .file-item,
[data-bs-theme="dark"] .setting-item {
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3), 0 2px 10px rgba(0, 0, 0, 0.2);
}
[data-bs-theme="dark"] .file-item:hover,
[data-bs-theme="dark"] .setting-item:hover {
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
}
+326
View File
@@ -0,0 +1,326 @@
<div class="settings-page max-w-3xl mx-auto px-4 py-8">
<header class="settings-header mb-8">
<h1 class="text-3xl font-semibold text-[var(--text-primary)] mb-1">تنظیمات</h1>
<p class="text-sm text-[var(--text-muted)]">مدیریت FAQ و ترجیحات برنامه</p>
</header>
<div
class="settings-card bg-[var(--card-bg)] rounded-2xl overflow-hidden shadow-[0_10px_40px_rgba(0,0,0,0.08),_0_2px_10px_rgba(0,0,0,0.04)]"
>
<nav class="settings-tabs flex bg-[var(--sidebar-hover)]" role="tablist">
<button
type="button"
class="tab-btn flex-1 flex items-center justify-center gap-2 px-4 py-3 text-sm font-medium text-[var(--text-muted)] transition-all duration-200 hover:text-[var(--text-primary)] relative"
[class.tab-active]="activeTab() === 'faq'"
(click)="selectTab('faq')"
role="tab"
[attr.aria-selected]="activeTab() === 'faq'"
>
<svg
class="w-4 h-4 transition-colors duration-200"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
<polyline points="17 8 12 3 7 8" />
<line x1="12" y1="3" x2="12" y2="15" />
</svg>
<span>آپلود FAQ</span>
@if (activeTab() === 'faq') {
<span
class="tab-indicator absolute bottom-0 left-1/2 -translate-x-1/2 w-6 h-0.5 bg-primary rounded-full"
></span>
}
</button>
<button
type="button"
class="tab-btn flex-1 flex items-center justify-center gap-2 px-4 py-3 text-sm font-medium text-[var(--text-muted)] transition-all duration-200 hover:text-[var(--text-primary)] relative"
[class.tab-active]="activeTab() === 'app'"
(click)="selectTab('app')"
role="tab"
[attr.aria-selected]="activeTab() === 'app'"
>
<svg
class="w-4 h-4 transition-colors duration-200"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="12" r="3" />
<path
d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"
/>
</svg>
<span>تنظیمات برنامه</span>
@if (activeTab() === 'app') {
<span
class="tab-indicator absolute bottom-0 left-1/2 -translate-x-1/2 w-6 h-0.5 bg-primary rounded-full"
></span>
}
</button>
</nav>
<div class="settings-content p-6">
@if (activeTab() === 'faq') {
<section class="faq-section animate-fade-in">
<div class="section-header mb-6">
<h2
class="text-xl font-semibold text-[var(--text-primary)] mb-1 flex items-center gap-2"
>
<svg
class="w-5 h-5 text-primary"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
<polyline points="17 8 12 3 7 8" />
<line x1="12" y1="3" x2="12" y2="15" />
</svg>
آپلود سند FAQ
</h2>
<p class="text-sm text-[var(--text-muted)]">
فایل‌های PDF، DOCX یا TXT خود را بکشید و رها کنید یا برای آپلود کلیک کنید.
</p>
</div>
<div
class="dropzone relative flex flex-col items-center justify-center gap-3 p-8 border-2 border-dashed border-[var(--text-muted)]/20 rounded-xl bg-[var(--dropzone-bg)] cursor-pointer transition-all duration-300 hover:border-primary/50 hover:bg-primary/5 hover:shadow-[0_10px_30px_rgba(59,130,246,0.15)]"
[class.dropzone-active]="isDragging()"
(dragover)="onDragOver($event)"
(dragleave)="onDragLeave()"
(drop)="onDrop($event)"
(click)="fileInput.click()"
role="button"
tabindex="0"
(keydown.enter)="fileInput.click()"
(keydown.space)="$event.preventDefault(); fileInput.click()"
>
<input
#fileInput
id="faq-file-input"
type="file"
class="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
accept=".pdf,.docx,.doc,.txt"
multiple
(change)="onFileSelected($event)"
/>
<div class="dropzone-icon-wrapper">
<svg
class="w-12 h-12 text-primary transition-transform duration-300"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
<polyline points="17 8 12 3 7 8" />
<line x1="12" y1="3" x2="12" y2="15" />
</svg>
</div>
<div class="dropzone-text text-center">
<p class="text-sm font-medium text-[var(--text-secondary)]">
فایل‌ها را اینجا رها کنید
</p>
<p class="text-xs text-[var(--text-muted)] mt-1">یا کلیک کنید برای انتخاب</p>
<p class="text-xs text-[var(--text-muted)] mt-2">پشتیبانی: PDF، DOCX، TXT</p>
</div>
</div>
@if (fileCount > 0) {
<div class="file-list mt-6 animate-slide-up">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-medium text-[var(--text-primary)] flex items-center gap-2">
<svg
class="w-5 h-5 text-primary"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
<polyline points="14 2 14 8 20 8" />
</svg>
فایل‌های انتخاب شده ({{ fileCount }})
</h3>
<button
type="button"
class="text-xs text-[var(--text-muted)] hover:text-[var(--text-primary)] transition-colors duration-200"
(click)="clearAllFiles()"
>
پاک کردن همه
</button>
</div>
<ul class="space-y-2">
@for (file of uploadedFiles(); track $index) {
<li
class="file-item flex items-center justify-between gap-3 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
>
<div class="flex items-center gap-3 min-w-0">
<div class="file-icon-wrapper p-2 bg-primary/10 rounded-lg shrink-0">
<svg
class="w-5 h-5 text-primary"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
<polyline points="14 2 14 8 20 8" />
</svg>
</div>
<div class="flex flex-col min-w-0">
<span class="text-sm font-medium text-[var(--text-secondary)] truncate">{{
file.name
}}</span>
<span class="text-xs text-[var(--text-muted)]">{{
formatFileSize(file.size)
}}</span>
</div>
</div>
<button
type="button"
class="file-remove-btn p-2 text-[var(--text-muted)] rounded-lg transition-all duration-200 hover:text-red-400 hover:bg-red-400/10 hover:scale-110 shrink-0"
(click)="removeFile($index)"
aria-label="حذف فایل {{ file.name }}"
>
<svg
class="w-4 h-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<line x1="18" y1="6" x2="6" y2="18" />
<line x1="6" y1="6" x2="18" y2="18" />
</svg>
</button>
</li>
}
</ul>
</div>
}
</section>
}
@if (activeTab() === 'app') {
<section class="app-section animate-fade-in">
<div class="section-header mb-6">
<h2
class="text-xl font-semibold text-[var(--text-primary)] mb-1 flex items-center gap-2"
>
<svg
class="w-5 h-5 text-primary"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="12" r="3" />
<path
d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"
/>
</svg>
تنظیمات کلی
</h2>
</div>
<div class="settings-grid space-y-3">
<div
class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
>
<div class="setting-info flex flex-col gap-1 min-w-0">
<span class="text-sm font-medium text-[var(--text-secondary)]"
>زبان رابط کاربری</span
>
<span class="text-xs text-[var(--text-muted)]"
>زبان نمایش برنامه را انتخاب کنید</span
>
</div>
<div class="setting-control shrink-0">
<select
class="form-select bg-[var(--input-bg)] text-[var(--text-secondary)] border border-[var(--input-border)] rounded-lg px-3 py-2 text-sm min-w-[140px] cursor-pointer transition-all duration-200 focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 focus:shadow-[0_0_0_3px_var(--color-primary)/20]"
[(ngModel)]="language"
>
<option value="fa">فارسی</option>
<option value="en">English</option>
</select>
</div>
</div>
<div
class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
>
<div class="setting-info flex flex-col gap-1 min-w-0">
<span class="text-sm font-medium text-[var(--text-secondary)]">اعلان‌ها</span>
<span class="text-xs text-[var(--text-muted)]">دریافت اعلان‌های برنامه</span>
</div>
<div class="setting-control shrink-0">
<label class="toggle-switch" [class.toggle-active]="notificationsEnabled()">
<input type="checkbox" [(ngModel)]="notificationsEnabled" />
<span class="toggle-slider"></span>
</label>
</div>
</div>
<div
class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
>
<div class="setting-info flex flex-col gap-1 min-w-0">
<span class="text-sm font-medium text-[var(--text-secondary)]">حالت تاریک</span>
<span class="text-xs text-[var(--text-muted)]">تغییر ظاهر برنامه به حالت تیره</span>
</div>
<div class="setting-control shrink-0">
<label class="toggle-switch" [class.toggle-active]="isDarkMode()">
<input type="checkbox" [checked]="isDarkMode()" (change)="toggleDarkMode()" />
<span class="toggle-slider"></span>
</label>
</div>
</div>
<div
class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
>
<div class="setting-info flex flex-col gap-1 min-w-0">
<span class="text-sm font-medium text-[var(--text-secondary)]">حالت RTL</span>
<span class="text-xs text-[var(--text-muted)]"
>جهت متن راست‌به‌چپ (فارسی/عربی)</span
>
</div>
<div class="setting-control shrink-0">
<label class="toggle-switch" [class.toggle-active]="isRTL()">
<input type="checkbox" [checked]="isRTL()" (change)="toggleRTL()" />
<span class="toggle-slider"></span>
</label>
</div>
</div>
</div>
</section>
}
</div>
</div>
</div>
+89
View File
@@ -0,0 +1,89 @@
import { ChangeDetectionStrategy, Component, signal, inject, computed, effect } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { ThemeService } from '../../services/theme/theme.service';
type TabId = 'faq' | 'app';
@Component({
selector: 'app-settings',
standalone: true,
imports: [CommonModule, FormsModule],
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './settings.page.html',
styleUrl: './settings.page.css',
})
export class SettingsPage {
private readonly themeService = inject(ThemeService);
readonly tabs: { id: TabId; label: string }[] = [
{ id: 'faq', label: 'آپلود FAQ' },
{ id: 'app', label: 'تنظیمات برنامه' },
];
readonly activeTab = signal<TabId>('faq');
readonly uploadedFiles = signal<File[]>([]);
readonly isDragging = signal(false);
readonly language = signal('fa');
readonly notificationsEnabled = signal(true);
readonly isDarkMode = this.themeService.isDarkMode;
readonly isRTL = signal(true);
selectTab(id: TabId): void {
this.activeTab.set(id);
}
onFileSelected(event: Event): void {
const input = event.target as HTMLInputElement;
const files = input.files ? Array.from(input.files) : [];
this.uploadedFiles.set(files);
}
onDragOver(event: DragEvent): void {
event.preventDefault();
this.isDragging.set(true);
}
onDragLeave(): void {
this.isDragging.set(false);
}
onDrop(event: DragEvent): void {
event.preventDefault();
this.isDragging.set(false);
const files = event.dataTransfer?.files ? Array.from(event.dataTransfer.files) : [];
this.uploadedFiles.set(files);
}
removeFile(index: number): void {
this.uploadedFiles.update((files) => files.filter((_, i) => i !== index));
}
clearAllFiles(): void {
this.uploadedFiles.set([]);
}
formatFileSize(bytes: number): string {
if (bytes === 0) return '0 بایت';
const k = 1024;
const sizes = ['بایت', 'کیلوبایت', 'مگابایت', 'گیگابایت'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
}
toggleDarkMode(): void {
this.themeService.toggleDarkMode();
}
toggleRTL(): void {
this.isRTL.update(val => !val);
document.documentElement.dir = this.isRTL() ? 'rtl' : 'ltr';
document.body.style.direction = this.isRTL() ? 'rtl' : 'ltr';
}
get fileCount(): number {
return this.uploadedFiles().length;
}
}