Mercurial > public > lazybear
changeset 430:c78d5b5b3bda
Minor updates
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sat, 19 Jun 2021 16:21:26 +0200 |
parents | e4ca9898b79b |
children | 871c10220a3d |
files | LazyBear/Tests/MainViewTest.swift LazyBear/Views/Company/Helpers/InsiderList.swift LazyBear/Views/Company/Helpers/StatsView.swift LazyBear/Views/Company/Helpers/TransactionList.swift LazyBear/Views/Home/TradingDates.swift LazyBear/Views/Profile/Helpers/RenameListSheet.swift LazyBear/Views/Profile/Helpers/WatchlistCreator.swift LazyBear/Views/Profile/Helpers/WatchlistCreatorList.swift LazyBear/Views/Profile/Helpers/WatchlistCreatorRow.swift LazyBear/Views/Profile/Helpers/WatchlistSheet.swift LazyBear/Views/Search/CompanyList.swift LazyBear/Views/Search/SearchView.swift |
diffstat | 12 files changed, 83 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/Tests/MainViewTest.swift Sat Jun 19 16:21:26 2021 +0200 @@ -0,0 +1,54 @@ +// +// MainViewTest.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 18/6/21. +// + +import SwiftUI + +class SheetManagement: ObservableObject { + @Published var showDetailView = false + @Published var showSubDetailview = false +} + +struct MainViewTest: View { + @StateObject var sheetManagement = SheetManagement() + + var body: some View { + VStack { + Text("Main View") + Button("Show Sheet", action: { sheetManagement.showDetailView = true }) + } + .sheet(isPresented: $sheetManagement.showDetailView) { + DetailViewTest() + .environmentObject(sheetManagement) + } + } +} + +struct DetailViewTest: View { + @EnvironmentObject var sheetManagement: SheetManagement + + var body: some View { + VStack { + Text("Detail View") + Button("Show Sub Detail View", action: { sheetManagement.showSubDetailview = true }) + } + .sheet(isPresented: $sheetManagement.showSubDetailview) { + SubDetailViewTest() + .environmentObject(sheetManagement) + } + } +} + +struct SubDetailViewTest: View { + @EnvironmentObject var sheetManagement: SheetManagement + + var body: some View { + VStack { + Text("Sub Detail View") + Button("Hide everything", action: { sheetManagement.showDetailView = false; sheetManagement.showSubDetailview = false }) + } + } +}
--- a/LazyBear/Views/Company/Helpers/InsiderList.swift Sat Jun 19 16:20:58 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/InsiderList.swift Sat Jun 19 16:21:26 2021 +0200 @@ -52,7 +52,7 @@ struct InsiderFullList: View { var insiderSummary: [InsiderRosterModel] - @Environment(\.presentationMode) private var presentationInsiderFullList + @Environment(\.presentationMode) private var insiderFullListPresentation var body: some View { NavigationView { @@ -70,7 +70,7 @@ .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .navigationBarLeading) { - Button(action: { presentationInsiderFullList.wrappedValue.dismiss() }) { + Button(action: { insiderFullListPresentation.wrappedValue.dismiss() }) { Image(systemName: "multiply") .imageScale(.large) }
--- a/LazyBear/Views/Company/Helpers/StatsView.swift Sat Jun 19 16:20:58 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/StatsView.swift Sat Jun 19 16:21:26 2021 +0200 @@ -10,7 +10,7 @@ struct StatsView: View { var keyStats: KeyStatsModel - @Environment(\.presentationMode) private var presentationStatsView + @Environment(\.presentationMode) private var statsPresentation let displayWords: DisplayWordsModel = parseJSON("DisplayWords.json") @@ -38,7 +38,7 @@ .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .navigationBarLeading) { - Button(action: { presentationStatsView.wrappedValue.dismiss() }) { + Button(action: { statsPresentation.wrappedValue.dismiss() }) { Image(systemName: "multiply") .imageScale(.large) }
--- a/LazyBear/Views/Company/Helpers/TransactionList.swift Sat Jun 19 16:20:58 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/TransactionList.swift Sat Jun 19 16:21:26 2021 +0200 @@ -56,7 +56,7 @@ struct TransactionFullList: View { var transactions: [InsiderTransactionModel] - @Environment(\.presentationMode) private var presentationTransactionFullList + @Environment(\.presentationMode) private var transactionFullListPresentation var body: some View { NavigationView { @@ -72,7 +72,7 @@ .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .navigationBarLeading) { - Button(action: { presentationTransactionFullList.wrappedValue.dismiss() }) { + Button(action: { transactionFullListPresentation.wrappedValue.dismiss() }) { Image(systemName: "multiply") .imageScale(.large) }
--- a/LazyBear/Views/Home/TradingDates.swift Sat Jun 19 16:20:58 2021 +0200 +++ b/LazyBear/Views/Home/TradingDates.swift Sat Jun 19 16:21:26 2021 +0200 @@ -10,7 +10,7 @@ struct TradingDates: View { var dates: [String] - @Environment(\.presentationMode) private var presentationTradingDates + @Environment(\.presentationMode) private var tradingDatesPresentation let columns = [GridItem(.adaptive(minimum: 100))] @@ -28,7 +28,7 @@ .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .navigationBarLeading) { - Button(action: { presentationTradingDates.wrappedValue.dismiss() }) { + Button(action: { tradingDatesPresentation.wrappedValue.dismiss() }) { Image(systemName: "multiply") .imageScale(.large) }
--- a/LazyBear/Views/Profile/Helpers/RenameListSheet.swift Sat Jun 19 16:20:58 2021 +0200 +++ b/LazyBear/Views/Profile/Helpers/RenameListSheet.swift Sat Jun 19 16:21:26 2021 +0200 @@ -10,9 +10,10 @@ struct RenameListSheet: View { var oldWatchlistName: String + @State private var newWatchlistName = String() - @Environment(\.presentationMode) private var renameListSheetPresentationMode + @Environment(\.presentationMode) private var renameListSheetPresentation @Environment(\.managedObjectContext) private var moc @FetchRequest(entity: WatchlistCompany.entity(), sortDescriptors: []) var watchlistCompanies: FetchedResults<WatchlistCompany> @@ -31,7 +32,7 @@ .navigationTitle("Rename your watchlist") .toolbar { ToolbarItem(placement: .navigationBarLeading) { - Button(action: { renameListSheetPresentationMode.wrappedValue.dismiss() }) { + Button(action: { renameListSheetPresentation.wrappedValue.dismiss() }) { Image(systemName: "multiply") } } @@ -55,7 +56,8 @@ do { try moc.save() - renameListSheetPresentationMode.wrappedValue.dismiss() + renameListSheetPresentation.wrappedValue.dismiss() + } catch { print(error.localizedDescription) } @@ -63,6 +65,8 @@ } struct RenameListSheet_Previews: PreviewProvider { + @Environment(\.presentationMode) static var presentationMode + static var previews: some View { RenameListSheet(oldWatchlistName: "Old name") }
--- a/LazyBear/Views/Profile/Helpers/WatchlistCreator.swift Sat Jun 19 16:20:58 2021 +0200 +++ b/LazyBear/Views/Profile/Helpers/WatchlistCreator.swift Sat Jun 19 16:21:26 2021 +0200 @@ -14,7 +14,7 @@ @State private var watchlistNameIsEmpty = false @Environment(\.managedObjectContext) private var moc - @Environment(\.presentationMode) private var presentationMode + @Environment(\.presentationMode) private var watchlistCreatorPresentation var body: some View { NavigationView { @@ -60,7 +60,7 @@ Alert( title: Text("Your watchlist won't be saved"), message: Text("This action can't be undo"), - primaryButton: .destructive(Text("Exit")) { presentationMode.wrappedValue.dismiss() }, + primaryButton: .destructive(Text("Exit")) { watchlistCreatorPresentation.wrappedValue.dismiss() }, secondaryButton: .cancel() ) } @@ -105,7 +105,7 @@ do { try moc.save() print("Watchlist created") - presentationMode.wrappedValue.dismiss() // Dismiss view + watchlistCreatorPresentation.wrappedValue.dismiss() // Dismiss view } catch { print(error.localizedDescription) }
--- a/LazyBear/Views/Profile/Helpers/WatchlistCreatorList.swift Sat Jun 19 16:20:58 2021 +0200 +++ b/LazyBear/Views/Profile/Helpers/WatchlistCreatorList.swift Sat Jun 19 16:21:26 2021 +0200 @@ -14,7 +14,7 @@ @State private var searchedCompany = String() @State private var companies = [SearchResponse]() - @Environment(\.presentationMode) private var presentationMode + @Environment(\.presentationMode) private var watchlistCreatorListPresentation @Environment(\.managedObjectContext) private var moc var body: some View { @@ -23,7 +23,7 @@ WatchlistCreatorSearchBar(searchedCompany: $searchedCompany) List(companies, id: \.self) { company in - WatchlistCreatorRow(company: company, presentationMode: presentationMode, watchlistCreatorClass: watchlistCreatorClass) + WatchlistCreatorRow(company: company, watchlistCreatorListPresentation: watchlistCreatorListPresentation, watchlistCreatorClass: watchlistCreatorClass) .environment(\.managedObjectContext, self.moc) } } @@ -35,7 +35,7 @@ .toolbar { ToolbarItem(placement: .navigationBarLeading) { - Button("Cancel", action: { presentationMode.wrappedValue.dismiss() }) + Button("Cancel", action: { watchlistCreatorListPresentation.wrappedValue.dismiss() }) } } }
--- a/LazyBear/Views/Profile/Helpers/WatchlistCreatorRow.swift Sat Jun 19 16:20:58 2021 +0200 +++ b/LazyBear/Views/Profile/Helpers/WatchlistCreatorRow.swift Sat Jun 19 16:21:26 2021 +0200 @@ -9,7 +9,7 @@ struct WatchlistCreatorRow: View { var company: SearchResponse - @Binding var presentationMode: PresentationMode + @Binding var watchlistCreatorListPresentation: PresentationMode @ObservedObject var watchlistCreatorClass: WatchlistCreatorClass var body: some View { @@ -41,7 +41,7 @@ */ private func saveCompany() { watchlistCreatorClass.companies.append(company) - $presentationMode.wrappedValue.dismiss() + $watchlistCreatorListPresentation.wrappedValue.dismiss() } } @@ -49,6 +49,6 @@ @Environment(\.presentationMode) static var presentationMode static var previews: some View { - WatchlistCreatorRow(company: SearchResponse(currency: "USD", exchange: nil, region: "US", securityName: "Apple Inc", symbol: "AAPL"), presentationMode: presentationMode, watchlistCreatorClass: WatchlistCreatorClass()) + WatchlistCreatorRow(company: SearchResponse(currency: "USD", exchange: nil, region: "US", securityName: "Apple Inc", symbol: "AAPL"), watchlistCreatorListPresentation: presentationMode, watchlistCreatorClass: WatchlistCreatorClass()) } }
--- a/LazyBear/Views/Profile/Helpers/WatchlistSheet.swift Sat Jun 19 16:20:58 2021 +0200 +++ b/LazyBear/Views/Profile/Helpers/WatchlistSheet.swift Sat Jun 19 16:21:26 2021 +0200 @@ -11,7 +11,7 @@ var listName: String var apiCompanies: [CompanyModel] - @Environment(\.presentationMode) private var watchlistSheetPresentationMode + @Environment(\.presentationMode) private var watchlistSheetPresentation @Environment(\.managedObjectContext) private var moc @FetchRequest(entity: WatchlistCompany.entity(), sortDescriptors: []) var watchlistCompanies: FetchedResults<WatchlistCompany> @@ -34,7 +34,7 @@ .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .navigationBarLeading) { - Button(action: {watchlistSheetPresentationMode.wrappedValue.dismiss()}) { + Button(action: {watchlistSheetPresentation.wrappedValue.dismiss()}) { Image(systemName: "multiply") } } @@ -86,7 +86,7 @@ do { try moc.save() print("List deleted") - watchlistSheetPresentationMode.wrappedValue.dismiss() /// Dismiss view + watchlistSheetPresentation.wrappedValue.dismiss() /// Dismiss view } catch { print(error.localizedDescription) }
--- a/LazyBear/Views/Search/CompanyList.swift Sat Jun 19 16:20:58 2021 +0200 +++ b/LazyBear/Views/Search/CompanyList.swift Sat Jun 19 16:21:26 2021 +0200 @@ -19,9 +19,7 @@ } } -struct CompanyList_Previews: PreviewProvider { - @Environment(\.presentationMode) static var presentationMode - +struct CompanyList_Previews: PreviewProvider { static var previews: some View { CompanyList(searchResult: [
--- a/LazyBear/Views/Search/SearchView.swift Sat Jun 19 16:20:58 2021 +0200 +++ b/LazyBear/Views/Search/SearchView.swift Sat Jun 19 16:21:26 2021 +0200 @@ -11,7 +11,7 @@ struct SearchView: View { @ObservedObject var search = Search() @State private var searchedText = String() - @Environment(\.presentationMode) private var presentationMode + @Environment(\.presentationMode) private var searchViewPresentation var body: some View { NavigationView {