feat(ios): tab tabanlı navigasyon ve okuma durumu takibi ekle
This commit is contained in:
@@ -16,6 +16,8 @@ struct BookRemote: Codable, Identifiable, Hashable {
|
||||
let categories: [String]
|
||||
let publisher: String?
|
||||
let sourceLocale: String?
|
||||
let readingStatus: ReadingStatus?
|
||||
let readingProgress: Double?
|
||||
|
||||
init(
|
||||
remoteId: String? = nil,
|
||||
@@ -30,7 +32,9 @@ struct BookRemote: Codable, Identifiable, Hashable {
|
||||
pageCount: Int? = nil,
|
||||
categories: [String] = [],
|
||||
publisher: String? = nil,
|
||||
sourceLocale: String? = nil
|
||||
sourceLocale: String? = nil,
|
||||
readingStatus: ReadingStatus? = nil,
|
||||
readingProgress: Double? = nil
|
||||
) {
|
||||
self.remoteId = remoteId
|
||||
self.title = title
|
||||
@@ -45,6 +49,8 @@ struct BookRemote: Codable, Identifiable, Hashable {
|
||||
self.categories = categories
|
||||
self.publisher = publisher
|
||||
self.sourceLocale = sourceLocale
|
||||
self.readingStatus = readingStatus
|
||||
self.readingProgress = readingProgress
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,9 @@ final class LibraryBook {
|
||||
var language: String?
|
||||
var sourceLocale: String?
|
||||
var remotePayloadJson: String?
|
||||
// Optional tutulur ki eski store'lar migration sırasında kırılmasın.
|
||||
var statusRaw: String?
|
||||
var readingProgress: Double?
|
||||
|
||||
init(
|
||||
localId: UUID = UUID(),
|
||||
@@ -30,7 +33,9 @@ final class LibraryBook {
|
||||
dateAdded: Date = .now,
|
||||
language: String? = nil,
|
||||
sourceLocale: String? = nil,
|
||||
remotePayloadJson: String? = nil
|
||||
remotePayloadJson: String? = nil,
|
||||
statusRaw: String = ReadingStatus.wantToRead.rawValue,
|
||||
readingProgress: Double = 0
|
||||
) {
|
||||
self.localId = localId
|
||||
self.title = title
|
||||
@@ -45,6 +50,8 @@ final class LibraryBook {
|
||||
self.language = language
|
||||
self.sourceLocale = sourceLocale
|
||||
self.remotePayloadJson = remotePayloadJson
|
||||
self.statusRaw = statusRaw
|
||||
self.readingProgress = min(max(readingProgress, 0), 1)
|
||||
}
|
||||
|
||||
var authors: [String] {
|
||||
@@ -60,4 +67,14 @@ final class LibraryBook {
|
||||
.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
|
||||
.filter { !$0.isEmpty }
|
||||
}
|
||||
|
||||
var status: ReadingStatus {
|
||||
get { ReadingStatus(rawValue: statusRaw ?? "") ?? .wantToRead }
|
||||
set { statusRaw = newValue.rawValue }
|
||||
}
|
||||
|
||||
var readingProgressValue: Double {
|
||||
get { min(max(readingProgress ?? 0, 0), 1) }
|
||||
set { readingProgress = min(max(newValue, 0), 1) }
|
||||
}
|
||||
}
|
||||
|
||||
34
ios/Bookibra/Models/ReadingStatus.swift
Normal file
34
ios/Bookibra/Models/ReadingStatus.swift
Normal file
@@ -0,0 +1,34 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
enum ReadingStatus: String, CaseIterable, Codable, Identifiable {
|
||||
case wantToRead
|
||||
case reading
|
||||
case finished
|
||||
|
||||
var id: String { rawValue }
|
||||
|
||||
var title: String {
|
||||
switch self {
|
||||
case .wantToRead: return "Want to Read"
|
||||
case .reading: return "Reading"
|
||||
case .finished: return "Finished"
|
||||
}
|
||||
}
|
||||
|
||||
var symbol: String {
|
||||
switch self {
|
||||
case .wantToRead: return "bookmark"
|
||||
case .reading: return "book"
|
||||
case .finished: return "checkmark.circle"
|
||||
}
|
||||
}
|
||||
|
||||
var color: Color {
|
||||
switch self {
|
||||
case .wantToRead: return .orange
|
||||
case .reading: return .blue
|
||||
case .finished: return .green
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user