Skip to content

Commit

Permalink
Replace Academy with new Education module
Browse files Browse the repository at this point in the history
  • Loading branch information
ealymbaev committed Oct 23, 2024
1 parent 848a429 commit d33f7b1
Show file tree
Hide file tree
Showing 18 changed files with 304 additions and 704 deletions.
84 changes: 20 additions & 64 deletions UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions UnstoppableWallet/UnstoppableWallet/Core/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class App {

let currencyManager: CurrencyManager
let networkManager: NetworkManager
let guidesManager: GuidesManager
let termsManager: TermsManager
let watchlistManager: WatchlistManager
let contactManager: ContactBookManager
Expand Down Expand Up @@ -162,7 +161,6 @@ class App {

currencyManager = CurrencyManager(storage: sharedLocalStorage)
networkManager = NetworkManager(logger: logger)
guidesManager = GuidesManager(networkManager: networkManager)
termsManager = TermsManager(userDefaultsStorage: userDefaultsStorage)

watchlistManager = WatchlistManager(storage: sharedLocalStorage, priceChangeModeManager: priceChangeModeManager)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum AppConfig {
static let mempoolSpaceUrl = "https://mempool.space"
static let guidesIndexUrl = URL(string: "https://raw.githubusercontent.com/horizontalsystems/blockchain-crypto-guides/v1.2/index.json")!
static let faqIndexUrl = URL(string: "https://raw.githubusercontent.com/horizontalsystems/unstoppable-wallet-website/master/src/faq.json")!
static let eduIndexUrl = URL(string: "https://raw.githubusercontent.com/horizontalsystems/Unstoppable-Wallet-Website/master/src/edu.json")!
static let donationAddresses: [BlockchainType: String] = [
.bitcoin: "bc1qxt5u5swx3sk6y2923whr4tvjreza43g37czv67",
.bitcoinCash: "bitcoincash:qz6sy9fq66yvfl5mvpfv3v2nqw5pervvkc425nj9g0\n",
Expand Down
95 changes: 0 additions & 95 deletions UnstoppableWallet/UnstoppableWallet/Models/Guide.swift

This file was deleted.

2 changes: 1 addition & 1 deletion UnstoppableWallet/UnstoppableWallet/Models/Stats.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import MarketKit

enum StatPage: String {
case aboutApp = "about_app"
case academy
case accountExtendedPrivateKey = "account_extended_private_key"
case accountExtendedPublicKey = "account_extended_public_key"
case addToken = "add_token"
Expand Down Expand Up @@ -50,6 +49,7 @@ enum StatPage: String {
case donate
case donateAddressList = "donate_address_list"
case doubleSpend = "double_spend"
case education
case evmAddress = "evm_address"
case evmPrivateKey = "evm_private_key"
case exportFull = "export_full"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,8 @@ struct CoinOverviewView: View {
if let guideUrl {
NavigationRow {
ThemeNavigationView {
MarkdownView(url: guideUrl)
MarkdownView(url: guideUrl).ignoresSafeArea()
}
.ignoresSafeArea()
.onFirstAppear {
stat(page: .coinOverview, event: .open(page: .guide))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import SwiftUI
import ThemeKit

struct EducationView: View {
@StateObject var viewModel = EducationViewModel()

@State var currentTabIndex = 0

var body: some View {
ThemeView {
switch viewModel.state {
case .loading:
ProgressView()
case let .loaded(categories):
VStack(spacing: 0) {
ScrollableTabHeaderView(
tabs: categories.map { $0.title },
currentTabIndex: $currentTabIndex
)

TabView(selection: $currentTabIndex) {
ForEach(categories.indices, id: \.self) { index in
SectionView(sections: categories[index].sections)
}
}
.tabViewStyle(.page(indexDisplayMode: .never))
.ignoresSafeArea(edges: .bottom)
}
case .failed:
SyncErrorView {
viewModel.onRetry()
}
}
}
.navigationBarTitle("education.title".localized)
}
}

extension EducationView {
struct SectionView: View {
let sections: [EducationViewModel.Section]

@State private var expandedIndices = Set<Int>()

var body: some View {
ScrollView {
VStack(spacing: 0) {
ForEach(sections.indices, id: \.self) { index in
let section = sections[index]
let expanded = expandedIndices.contains(index)
let last = index == sections.count - 1

VStack(spacing: 0) {
VStack(spacing: 0) {
HorizontalDivider()

HStack(spacing: .margin8) {
Text(section.title).textHeadline2().multilineTextAlignment(.leading)
Spacer()
Image(expanded ? "arrow_big_up_20" : "arrow_big_down_20")
}
.padding(.vertical, .margin12)
.padding(.horizontal, .margin16)
}
.zIndex(2)
.background(Color.themeLawrence)
.onTapGesture {
withAnimation {
if expandedIndices.contains(index) {
expandedIndices.remove(index)
} else {
expandedIndices.insert(index)
}
}
}

if expanded {
ListSection {
ForEach(section.items.indices, id: \.self) { index in
let item = section.items[index]

NavigationRow {
ThemeNavigationView {
MarkdownView(url: item.url).ignoresSafeArea()
}
.ignoresSafeArea()
.onFirstAppear {
stat(page: .education, event: .openArticle(relativeUrl: item.url.relativePath))
}
} content: {
Text(item.title).themeBody()
}
}
}
.themeListStyle(last ? .transparent : .transparentInline)
.zIndex(1)
.transition(AnyTransition.move(edge: .top).combined(with: .opacity))
}
}
.clipped()
}
}
.padding(.bottom, .margin16)
}
}
}
}
Loading

0 comments on commit d33f7b1

Please sign in to comment.