LiTranslate-iOS/LiTranslate/Presentation/BookmarksView.swift

56 lines
1.8 KiB
Swift
Raw Permalink Normal View History

2022-09-10 19:46:05 +02:00
//
// BookmarksView.swift
// LiTranslate
//
// Created by Viktor Kalyniuk on 18.08.2022.
//
import SwiftUI
struct BookmarksView: View {
@EnvironmentObject private var bookmarksData: BookmarksData
@Binding var tabSelection: Int
var body: some View {
List {
Color(uiColor: Colors.UIColors.Background.main)
.frame(height: 1)
.frame(maxWidth: .infinity)
.listRowInsets(EdgeInsets())
.listRowSeparatorTint(.clear)
.listRowSeparator(.hidden)
.listRowBackground(Colors.Background.mainView)
2022-09-10 19:46:05 +02:00
ForEach(bookmarksData.array, id: \.self) { bookmark in
let bookmarkModel = BookmarkModel(
inputLanguage: bookmark.inputLanguage,
outputLanguage: bookmark.outputLanguage,
inputText: bookmark.inputText,
outputText: bookmark.outputText)
BookmarkView(tabSelection: $tabSelection,
bookmarkModel: bookmarkModel)
.listRowBackground(Color.clear)
2022-09-10 19:46:05 +02:00
.buttonStyle(.plain)
.background(Colors.Background.primaryView)
.cornerRadius(CGFloat(Numbers.twentyFive))
.listRowSeparator(.hidden)
2022-09-10 19:46:05 +02:00
}
.onDelete { IndexSet in
bookmarksData.array.remove(atOffsets: IndexSet)
}
}
.environment(\.defaultMinListRowHeight, 1)
.modifier(ScrollContentBackgroundModifier())
2022-09-10 19:46:05 +02:00
.background(Color(uiColor: .systemGray5))
.listStyle(.sidebar)
2022-09-10 19:46:05 +02:00
}
}
struct BookmarksView_Previews: PreviewProvider {
static var previews: some View {
BookmarksView(tabSelection: .constant(2))
.environmentObject(BookmarksData())
}
}