Skip to content

Commit

Permalink
Merge branch 'feature/IOS-8271_project_modularization_foundation' int…
Browse files Browse the repository at this point in the history
…o feature/IOS-8290_migrate_all_remaining_bsdk_deps_to_spm

Signed-off-by: Andrey Fedorov <[email protected]>

# Conflicts:
#	TangemApp.xcodeproj/project.pbxproj
  • Loading branch information
m3g0byt3 committed Oct 22, 2024
2 parents cd2c450 + 6c9c6a7 commit 552b04f
Show file tree
Hide file tree
Showing 56 changed files with 804 additions and 235 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/update-localizations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Fetch and update translations (Lokalise)

on:
workflow_dispatch:
inputs:
langs:
description: >
Optional filter of languages to fetch and update. Pass a comma-delimited string of language codes,
like `en,fr,de` to fetch and update translations for the selected languages only.
type: string
default: "en,fr,de,ja,ru,es,uk_UA,zh-Hant,it"
update_app_localizations:
type: boolean
default: true
description: Update localizations in the main app target
update_bsdk_localizations:
type: boolean
default: false
description: Update localizations in the BlockchainSDK target

jobs:
update-localizations:
runs-on: macos-14
env:
APP_LOCALIZATIONS_DESTINATION: "Tangem/Resources/Localizations"
BSDK_LOCALIZATIONS_DESTINATION: "BlockchainSdk/Resources/Localizations"
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
with:
gpg_private_key: ${{ secrets.PGP_PRIVATE_SERVICE }}
git_user_signingkey: true
git_commit_gpgsign: true

- name: Bundle install
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Fetch and update main app localizations
if: ${{ github.event.inputs.update_app_localizations == 'true' }}
env:
LOKALISE_PROJECT_ID: ${{ secrets.LOKALISE_APP_PROJECT_ID }}
LOKALISE_API_TOKEN: ${{ secrets.LOKALISE_ACCESS_TOKEN }}
run: |
bundle exec fastlane update_translations languages:${{ github.event.inputs.langs }} destination:${{ env.APP_LOCALIZATIONS_DESTINATION }}
- name: Fetch and update BSDK localizations
if: ${{ github.event.inputs.update_bsdk_localizations == 'true' }}
env:
LOKALISE_PROJECT_ID: ${{ secrets.LOKALISE_BSDK_PROJECT_ID }}
LOKALISE_API_TOKEN: ${{ secrets.LOKALISE_ACCESS_TOKEN }}
run: |
bundle exec fastlane update_translations languages:${{ github.event.inputs.langs }} destination:${{ env.BSDK_LOCALIZATIONS_DESTINATION }}
- name: Push changes and open a pull-request
env:
GH_TOKEN: ${{ github.token }}
SOURCE_BRANCH: lokalise-translations-sync
TARGET_BRANCH: ${{ github.ref_name }}
LANGUAGES: ${{ github.event.inputs.langs }}
GH_RUN_ID: ${{ github.run_id }}
run: |
git config --global user.name "Tangem Service"
git config --global user.email "[email protected]"
git checkout -b $SOURCE_BRANCH $TARGET_BRANCH
git add "${APP_LOCALIZATIONS_DESTINATION}"
git add "${BSDK_LOCALIZATIONS_DESTINATION}"
: "${LANGUAGES:="all"}"
commit_message="Sync translations for \`${LANGUAGES}\` languages"
pr_message="[Localise] ${commit_message} (${GH_RUN_ID})"
git commit -S -m "${commit_message}"
git push --set-upstream origin $SOURCE_BRANCH --force
gh pr create --base $TARGET_BRANCH --head $SOURCE_BRANCH --title "${pr_message}" --body ""
102 changes: 55 additions & 47 deletions Modules/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,71 +3,79 @@

import PackageDescription // TODO: Andrey Fedorov - Update swift-tools-version to 6.0 after upgrade to Xcode 16.0 (IOS-8085)

// MARK: - Service Modules

/// Valid examples are `CommonUI`, `Utils`, `NetworkLayer`, `ModelData`, etc.
let serviceModules: [PackageDescription.Target] = [
.tangemTarget(
name: "TangemFoundation"
),
.tangemTarget(
name: "TangemNetworkLayerAdditions",
dependencies: [
"Moya",
"Alamofire",
]
),
]

// MARK: - Feature Modules

/// Valid examples are `Onboarding`, `Auth`, `Catalog`, etc.
let featureModules: [PackageDescription.Target] = [
// Currently there are no feature modules
]

// MARK: - Unit Test Modules

let unitTestsModules: [PackageDescription.Target] = [
.tangemTestTarget(
name: "TangemFoundationTests",
dependencies: [
"TangemFoundation",
]
),
]

// MARK: - Shim Library

let modulesShimLibraryName = "TangemModules"

let modulesShimLibrary: PackageDescription.Target = .tangemTarget(
name: modulesShimLibraryName,
dependencies: serviceModules.asDependencies() + featureModules.asDependencies()
)

// MARK: - Package

let package = Package(
name: modulesShimLibraryName,
name: modulesWrapperLibraryName,
platforms: [
.iOS(.v15),
],
products: [
.library(
name: modulesShimLibraryName,
name: modulesWrapperLibraryName,
targets: [
modulesShimLibraryName,
modulesWrapperLibraryName,
]
),
],
dependencies: [
.package(url: "https://github.com/Moya/Moya.git", .upToNextMajor(from: "15.0.0")),
.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.0.0")),
],
targets: [modulesShimLibrary] + serviceModules + featureModules + unitTestsModules
targets: [modulesWrapperLibrary] + serviceModules + featureModules + unitTestsModules
)

// MARK: - Service Modules

/// Valid examples are `CommonUI`, `Utils`, `NetworkLayer`, `ModelData`, etc.
var serviceModules: [PackageDescription.Target] {
[
.tangemTarget(
name: "TangemFoundation"
),
.tangemTarget(
name: "TangemNetworkLayerAdditions",
dependencies: [
"Moya",
"Alamofire",
]
),
]
}

// MARK: - Feature Modules

/// Valid examples are `Onboarding`, `Auth`, `Catalog`, etc.
var featureModules: [PackageDescription.Target] {
[
// Currently there are no feature modules
]
}

// MARK: - Unit Test Modules

var unitTestsModules: [PackageDescription.Target] {
[
.tangemTestTarget(
name: "TangemFoundationTests",
dependencies: [
"TangemFoundation",
]
),
]
}

// MARK: - Wrapper Library (implementation details, do not edit)

var modulesWrapperLibraryName: String { "TangemModules" }

var modulesWrapperLibrary: PackageDescription.Target {
.tangemTarget(
name: modulesWrapperLibraryName,
dependencies: serviceModules.asDependencies() + featureModules.asDependencies()
)
}

// MARK: - Private implementation

private extension PackageDescription.Target {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ extension Wallet2Config: UserWalletConfig {
case "AF35":
return cardsCount == 2 ? Assets.Cards.voltInuDouble : Assets.Cards.voltInuTriple
// Kaspa 2
case "AF25":
case "AF25", "AF61", "AF72":
return cardsCount == 2 ? Assets.Cards.kaspa2Double : Assets.Cards.kaspa2Triple
// Kaspa reseller
case "AF31":
Expand All @@ -220,6 +220,12 @@ extension Wallet2Config: UserWalletConfig {
// Peach, Air, Glass
case "AF43", "AF44", "AF45":
return Assets.Cards.peachAirGlass
// Kaspa Mint
case "AF73":
return cardsCount == 2 ? Assets.Cards.kaspaMint2 : Assets.Cards.kaspaMint3
// BTC Gold
case "AF71":
return cardsCount == 2 ? Assets.Cards.btcNew2 : Assets.Cards.btcNew3
// Tangem Wallet 2.0
default:

Expand Down
12 changes: 12 additions & 0 deletions Tangem/Common/Extensions/UIDevice+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public enum IPhoneModel {
case iPhone15Plus
case iPhone15Pro
case iPhone15ProMax
case iPhone16
case iPhone16Plus
case iPhone16Pro
case iPhone16ProMax

init?(identifier: String) {
switch identifier {
Expand Down Expand Up @@ -99,6 +103,10 @@ public enum IPhoneModel {
case "iPhone15,5": self = .iPhone15Plus
case "iPhone16,1": self = .iPhone15Pro
case "iPhone16,2": self = .iPhone15ProMax
case "iPhone17,1": self = .iPhone16Pro
case "iPhone17,2": self = .iPhone16ProMax
case "iPhone17,3": self = .iPhone16
case "iPhone17,4": self = .iPhone16Plus
default:
return nil
}
Expand Down Expand Up @@ -138,6 +146,10 @@ public enum IPhoneModel {
case .iPhone15Plus: return "iPhone 15 Plus"
case .iPhone15Pro: return "iPhone 15 Pro"
case .iPhone15ProMax: return "iPhone 15 Pro Max"
case .iPhone16: return "iPhone 16"
case .iPhone16Plus: return "iPhone 16 Plus"
case .iPhone16Pro: return "iPhone 16 Pro"
case .iPhone16ProMax: return "iPhone 16 Pro Max"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// NavigationBarHiddingView.swift
// NavigationBarHidingView.swift
// Tangem
//
// Created by Andrew Son on 08.10.24.
Expand All @@ -8,15 +8,15 @@

import SwiftUI

struct NavigationBarHiddingView<Content: View>: View {
struct NavigationBarHidingView<Content: View>: View {
var shouldWrapInNavigationView: Bool
var content: Content

var body: some View {
if #available(iOS 16.0, *) {
wrappedContent
} else {
UIAppearanceBoundaryContainerView(boundaryMarker: NavigationBarHiddingViewUIAppearanceBoundaryMarker.self) {
UIAppearanceBoundaryContainerView(boundaryMarker: NavigationBarHidingViewUIAppearanceBoundaryMarker.self) {
wrappedContent
}
}
Expand All @@ -41,7 +41,7 @@ struct NavigationBarHiddingView<Content: View>: View {
} else {
content
.onAppear {
NavigationBarHiddingViewUIAppearanceBoundaryMarker.setupUIAppearanceIfNeeded()
NavigationBarHidingViewUIAppearanceBoundaryMarker.setupUIAppearanceIfNeeded()
}
}
}
Expand All @@ -52,7 +52,7 @@ struct NavigationBarHiddingView<Content: View>: View {
}
}

private class NavigationBarHiddingViewUIAppearanceBoundaryMarker: UIViewController {
private class NavigationBarHidingViewUIAppearanceBoundaryMarker: UIViewController {
static var didSetupUIAppearance = false

@available(iOS, obsoleted: 16.0, message: "Use native 'toolbarBackground(_:for:)' instead")
Expand All @@ -62,7 +62,7 @@ private class NavigationBarHiddingViewUIAppearanceBoundaryMarker: UIViewControll
navBarAppearance.configureWithTransparentBackground()

let uiAppearance = UINavigationBar.appearance(
whenContainedInInstancesOf: [NavigationBarHiddingViewUIAppearanceBoundaryMarker.self]
whenContainedInInstancesOf: [NavigationBarHidingViewUIAppearanceBoundaryMarker.self]
)
uiAppearance.compactAppearance = navBarAppearance
uiAppearance.standardAppearance = navBarAppearance
Expand Down
2 changes: 1 addition & 1 deletion Tangem/Modules/Main/MainCoordinatorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct MainCoordinatorView: CoordinatorView {
})
}
.sheet(item: $coordinator.organizeTokensViewModel) { viewModel in
NavigationBarHiddingView(shouldWrapInNavigationView: true) {
NavigationBarHidingView(shouldWrapInNavigationView: true) {
OrganizeTokensView(viewModel: viewModel)
.navigationTitle(Localization.organizeTokensTitle)
.navigationBarTitleDisplayMode(.inline)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct MarketsTokenDetailsCoordinatorView: CoordinatorView {
private var links: some View {
NavHolder()
.navigation(item: $coordinator.exchangesListViewModel) { viewModel in
let container = NavigationBarHiddingView(shouldWrapInNavigationView: false) {
let container = NavigationBarHidingView(shouldWrapInNavigationView: false) {
MarketsTokenDetailsExchangesListView(viewModel: viewModel)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct MarketsTokenDetailsView: View {
}
.background {
backgroundColor
.ignoresSafeArea(edges: .vertical)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ struct MarketsTokenNetworkSelectorCoordinatorView: CoordinatorView {
.navigation(item: $coordinator.walletSelectorViewModel) {
WalletSelectorView(viewModel: $0)
}
.emptyNavigationLink()
}
}
Loading

0 comments on commit 552b04f

Please sign in to comment.