Skip to content

Refactor: Modüler mimari, kritik hata düzeltmeleri ve dark theme tasarımı#1

Open
ecuware wants to merge 2 commits intosoftviser:mainfrom
ecuware:refactor/modular-architecture
Open

Refactor: Modüler mimari, kritik hata düzeltmeleri ve dark theme tasarımı#1
ecuware wants to merge 2 commits intosoftviser:mainfrom
ecuware:refactor/modular-architecture

Conversation

@ecuware
Copy link
Copy Markdown

@ecuware ecuware commented Apr 5, 2026

Özet

VPNKeepAwake projesi için kapsamlı refactor ve UI tasarım güncellemesi. İki commit'lik bu PR şunları içeriyor:


Commit 1: Modüler Mimari ve Kritik Hata Düzeltmeleri

🔴 Kritik Hata Düzeltmeleri

  1. Log Race Condition

    • Concurrent log yazımları dosya bozulmasına neden oluyordu
    • DispatchQueue serial queue ve defer ile dosya yazımı güvenli hale getirildi
  2. AssertionID State Confusion

    • IOPMAssertionID değeri 0 olduğunda başarısız assertion mı yoksa geçerli bir assertion ID mi olduğu ayırt edilemiyordu
    • systemAssertionCreated ve displayAssertionCreated boolean flag'leri ve UInt32.max sentinel değeri eklendi
  3. Sürüm Uyuşmazlığı

    • Kodda "1.1.0" hardcoded iken Info.plist'te "1.2.0" tanımlıydı
    • Bundle.main.infoDictionary üzerinden dinamik version okuma

🟠 Yüksek Öncelikli Düzeltmeler

  1. withMemoryRebound Safety

    • inet_ntop() dönüş değeri kontrol edilmediği için crash riski vardı
    • guard result != nil ile nil kontrolü eklendi
  2. Timer Memory Leak

    • deinit olmadığı için timer invalidation yapılamıyordu
    • deinit { allowSleep() } eklendi

🟡 Orta Öncelikli İyileştirmeler

  1. Singleton Thread Safety

    • LocalizationManager.shared aynı anda birden fazla thread tarafından erişilebilirdi
    • NSLock ile thread-safe erişim
  2. Error Handling

    • Hatalar sadece loglanıyordu
    • Notification permission denied durumunda SettingsManager.shared.notificationsEnabled = false ile auto-disable

⚪ Yapısal İyileştirmeler

  1. Hardcoded URLs

    • URL'ler hardcoded idi
    • AppConstants struct'ı oluşturuldu
  2. Single File Architecture

    • 1715 satırlık tek dosya modüler yapıya ayrıldı:
      • Sources/main.swift - 668 satır (core logic)
      • Sources/Views.swift - 644 satır (SwiftUI views)
      • Sources/AppDelegate.swift - 123 satır (AppDelegate + FloatingPanel)
      • Sources/Localization.swift - 270 satır (LocalizationManager)
      • Sources/AppConstants.swift - 13 satır (constants)

Commit 2: UI Design - Dark Theme ve Accessibility Fix

Renk Paleti

  • Background: Midnight blue (#0F172A)
  • Card Background: Slate (#1E293B)
  • Card Border: Subtle slate border (#334155)
  • Primary Gradient: Indigo to Purple (#6366F1 → #8B5CF6)
  • Connected: Emerald (#10B981 → #34D399)
  • Disconnected: Red to Orange (#EF4444 → #F97316)
  • Text: Near-white primary (#F8FAFC), muted secondary (#94A3B8)

Theme System

  • AppTheme struct'ı ile merkezi renk tanımları
  • Color(hex:) extension ile hex renk desteği
  • ConnectionStatus enum ile durum renkleri eşleştirmesi
  • Glow efektli reusable status badge'ler

İkonography

  • Gradient'li SF Symbols
  • Status indicator'larda glow efektleri
  • Subtle opacity'li card border'lar

Accessibility Fix

  • applicationDidFinishLaunching() içinde erken permission kontrolü
  • startMonitoring() içinde permission kontrolü
  • Yanlış "permission required" uyarısı önlendi

Dosya Yapısı

Dosya Açıklama
Sources/main.swift Core logic (managers, monitors, state)
Sources/Views.swift SwiftUI views ve DashboardView
Sources/AppDelegate.swift FloatingPanel ve AppDelegate
Sources/Localization.swift LocalizationManager ve Language
Sources/AppConstants.swift URL'ler ve version bilgisi
Sources/Theme.swift AppTheme ve renk extensions
build.sh Çoklu kaynak derleme desteği

Test

./build.sh
open build/VPNKeepAwake.app

Notlar

  • Build başarıyla test edildi ✅
  • Tüm değişiklikler geriye dönük uyumlu
  • Modüler yapı test yazılabilirliğini artırıyor

ecuware added 2 commits April 5, 2026 14:23
## Yapılan Değişiklikler

### 🔴 Kritik Hata Düzeltmeleri

1. **Log Race Condition (main.swift:387-400)**
   - DispatchQueue serial queue eklendi
   - Concurrent log yazımları dosya bozulmasını önlüyor
   - defer kullanılarak FileHandle temizliği sağlandı

2. **AssertionID State Confusion (main.swift:605-678)**
   - systemAssertionCreated ve displayAssertionCreated boolean flag'leri eklendi
   - UInt32.max sentinel değeri kullanıldı
   - preventSleep() ve allowSleep() arasındaki state tutarsızlığı giderildi

3. **Sürüm Uyuşmazlığı (main.swift:1458)**
   - Hardcoded "1.1.0" yerine Bundle'dan dinamik okuma
   - Info.plist CFBundleShortVersionString'e uyumlu hale getirildi

### 🟠 Yüksek Öncelikli Düzeltmeler

4. **withMemoryRebound Safety (main.swift:771)**
   - inet_ntop() dönüş değeri kontrol ediliyor
   - Nil guard eklendi

5. **Timer Memory Leak (main.swift:604)**
   - SleepManager'a deinit eklendi
   - allowSleep() çağrılarak timer cleanup sağlandı

### 🟡 Orta Öncelikli İyileştirmeler

6. **Singleton Thread Safety (main.swift:30-51)**
   - LocalizationManager'a NSLock eklendi
   - setLanguage() thread-safe hale getirildi

7. **Error Handling (main.swift:453-486)**
   - try? yerine do-catch kullanımı
   - Notification permission denied durumunda auto-disable
   - Log hataları dışında recovery mekanizması eklendi

### ⚪ Düşük Öncelikli / Yapısal İyileştirmeler

8. **Hardcoded URLs (AppConstants.swift)**
   - websiteURL, githubURL, websiteDisplayText, githubDisplayText
   - AppConstants struct'ı oluşturuldu
   - Tek merkezden yönetim

9. **Single File Architecture (1715 → 668 satır)**
   - LocalizationManager + Language → Sources/Localization.swift
   - SwiftUI Views → Sources/Views.swift
   - FloatingPanel + AppDelegate → Sources/AppDelegate.swift
   - Constants → Sources/AppConstants.swift
   - main.swift artık sadece core logic içeriyor

10. **Build Script Güncellemesi**
    - Tek dosya derleme → Sources/*.swift glob pattern
    - Çoklu kaynak dosyası desteği

## Dosya Yapısı

- Sources/main.swift         - 668 satır (core logic)
- Sources/Views.swift        - 644 satır (SwiftUI views)
- Sources/AppDelegate.swift  - 123 satır (AppDelegate + FloatingPanel)
- Sources/Localization.swift - 270 satır (LocalizationManager)
- Sources/AppConstants.swift -  13 satır (constants)

## Notlar

- Build başarıyla test edildi
- Tüm değişiklikler geriye dönük uyumlu
- Modüler yapı sayesinde test yazılabilirliği artırıldı
## Değişiklikler

### Renk Paleti
- Midnight blue background (#0F172A)
- Slate card background (#1E293B)
- Emerald connected gradient (#10B981 → #34D399)
- Red-Orange disconnected gradient (#EF4444 → #F97316)
- Indigo-Purple primary gradient (#6366F1 → #8B5CF6)
- New text hierarchy with near-white primary (#F8FAFC)

### Theme System
- AppTheme struct with centralized color definitions
- Color(hex:) extension for hex color support
- ConnectionStatus enum for status color mapping
- Reusable status badges with glow effects

### İkonography
- Custom SF Symbols with gradient styling
- Glow effects on status indicators
- Card borders with subtle opacity

### Accessibility Fix
- checkAccessibilityPermission() called in applicationDidFinishLaunching
- Prevents false "permission required" warning on app launch
- Permission check also added to startMonitoring()

## Dosyalar
- Sources/Theme.swift (new) - Theme constants and color extensions
- Sources/Views.swift - Updated with dark theme colors
- Sources/AppDelegate.swift - Early permission check on launch
- Sources/main.swift - Early permission check in startMonitoring()
@ecuware ecuware changed the title Refactor: Modüler mimari ve kritik hata düzeltmeleri Refactor: Modüler mimari, kritik hata düzeltmeleri ve dark theme tasarımı Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant