Commit 7c18d702 authored by jzhang's avatar jzhang

语言选择

parent 1aa6b0a4
......@@ -42,6 +42,8 @@
6989B7B82852EAB90014BB5B /* wakelock.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 6989B7B52852EAA20014BB5B /* wakelock.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
8DE79EDB672D5394BDEB806E /* Pods_BreastFeedingDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 39043640BDC7A50986C47129 /* Pods_BreastFeedingDemo.framework */; };
EA14360528E0BF1900FFBE72 /* DemoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA14360428E0BF1900FFBE72 /* DemoViewController.swift */; };
EA14360828E0CA3100FFBE72 /* LanguageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA14360628E0CA3100FFBE72 /* LanguageCell.swift */; };
EA14360928E0CA3100FFBE72 /* LanguageCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = EA14360728E0CA3100FFBE72 /* LanguageCell.xib */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -97,6 +99,8 @@
8C76E81CF245C7C738786086 /* Pods-BreastFeedingDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BreastFeedingDemo.debug.xcconfig"; path = "Target Support Files/Pods-BreastFeedingDemo/Pods-BreastFeedingDemo.debug.xcconfig"; sourceTree = "<group>"; };
A4415E51DE97A1784932289A /* Pods-BreastFeedingDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BreastFeedingDemo.release.xcconfig"; path = "Target Support Files/Pods-BreastFeedingDemo/Pods-BreastFeedingDemo.release.xcconfig"; sourceTree = "<group>"; };
EA14360428E0BF1900FFBE72 /* DemoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoViewController.swift; sourceTree = "<group>"; };
EA14360628E0CA3100FFBE72 /* LanguageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LanguageCell.swift; sourceTree = "<group>"; };
EA14360728E0CA3100FFBE72 /* LanguageCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = LanguageCell.xib; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -162,6 +166,8 @@
EA14360428E0BF1900FFBE72 /* DemoViewController.swift */,
697B07EC284F2E5C0051FC23 /* CompleteVC.swift */,
692EC419284C81700043E3EA /* ViewModel.swift */,
EA14360628E0CA3100FFBE72 /* LanguageCell.swift */,
EA14360728E0CA3100FFBE72 /* LanguageCell.xib */,
694B85C12848EB4C009BEDE1 /* Main.storyboard */,
694B85C42848EB4E009BEDE1 /* Assets.xcassets */,
694B85C62848EB4E009BEDE1 /* LaunchScreen.storyboard */,
......@@ -270,6 +276,7 @@
694B85C82848EB4E009BEDE1 /* LaunchScreen.storyboard in Resources */,
692EC421284C8D6F0043E3EA /* french.json in Resources */,
694B85C52848EB4E009BEDE1 /* Assets.xcassets in Resources */,
EA14360928E0CA3100FFBE72 /* LanguageCell.xib in Resources */,
694B85C32848EB4C009BEDE1 /* Main.storyboard in Resources */,
692EC423284C8D6F0043E3EA /* spanish.json in Resources */,
692EC422284C8D6F0043E3EA /* english.json in Resources */,
......@@ -330,6 +337,7 @@
697B07ED284F2E5C0051FC23 /* CompleteVC.swift in Sources */,
EA14360528E0BF1900FFBE72 /* DemoViewController.swift in Sources */,
692EC41A284C81700043E3EA /* ViewModel.swift in Sources */,
EA14360828E0CA3100FFBE72 /* LanguageCell.swift in Sources */,
694B85BE2848EB4C009BEDE1 /* SceneDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
......
......@@ -83,7 +83,7 @@
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="s7D-fE-2f9">
<rect key="frame" x="358" y="44" width="40" height="40"/>
<rect key="frame" x="358" y="88" width="40" height="40"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="JlQ-c6-MTE"/>
<constraint firstAttribute="width" constant="40" id="QfK-8H-GP3"/>
......@@ -121,7 +121,7 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wyh-ZZ-B5n">
<rect key="frame" x="312" y="84" width="100" height="120"/>
<rect key="frame" x="312" y="128" width="100" height="120"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" image="popup" translatesAutoresizingMaskIntoConstraints="NO" id="d65-2N-aD0">
<rect key="frame" x="60" y="0.0" width="12" height="13"/>
......@@ -143,7 +143,7 @@
<constraint firstAttribute="height" constant="1" id="6mo-Hr-Xgx"/>
</constraints>
</view>
<button opaque="NO" tag="1000" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="f1P-II-Bc9">
<button opaque="NO" tag="1000" contentMode="scaleToFill" selected="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="f1P-II-Bc9">
<rect key="frame" x="10" y="0.0" width="90" height="34.5"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
......@@ -185,7 +185,7 @@
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title=" Français" image="noselect">
<color key="titleColor" red="0.19438669089999999" green="0.17716249819999999" blue="0.19208657740000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleColor" red="0.19607843137254902" green="0.1764705882352941" blue="0.19215686274509802" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<state key="selected" image="select">
<color key="titleColor" red="0.96192914249999995" green="0.52479732040000004" blue="0.52205568550000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
......@@ -940,7 +940,7 @@
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Congratulations" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Xvm-3y-De7">
<rect key="frame" x="63.5" y="2.5" width="158.5" height="25.5"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="21"/>
<color key="textColor" red="0.96192914249999995" green="0.52479732040000004" blue="0.52205568550000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="textColor" red="0.96078431372549022" green="0.52549019607843139" blue="0.52156862745098043" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
......@@ -1004,12 +1004,28 @@
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="XVX-uo-beN" kind="relationship" relationship="rootViewController" id="yGt-cE-12x"/>
<segue destination="XVX-uo-beN" kind="relationship" relationship="rootViewController" id="M1v-Za-Qk7"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="8PS-55-tPj" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1568" y="31"/>
<point key="canvasLocation" x="-1694" y="491"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="cni-PM-PAS">
<objects>
<navigationController id="Wid-yi-NNM" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="1zp-f1-jQK">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="pST-CY-qfD"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="LNG-Ah-4cK" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1694" y="-224"/>
</scene>
</scenes>
<resources>
......
......@@ -9,10 +9,10 @@ import UIKit
class CompleteVC: UIViewController {
var vm: ViewModel?
@IBOutlet weak var containerV: UIView!
@IBOutlet var containerV: UIView!
@IBOutlet weak var titleL: UILabel!
@IBOutlet weak var btn: UIButton!
@IBOutlet var titleL: UILabel!
@IBOutlet var btn: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
overrideUserInterfaceStyle = .light
......@@ -21,7 +21,7 @@ class CompleteVC: UIViewController {
btn.setTitle(vm?.completeBtn, for: .normal)
}
@IBAction func okAction(_ sender: Any) {
@IBAction func okAction(_: Any) {
navigationController?.popToRootViewController(animated: true)
}
/*
......
......@@ -5,40 +5,76 @@
// Created by jzhang on 2022/9/26.
//
import UIKit
import Popover
import UIKit
import ZJTableViewManager
class DemoViewController: UIViewController {
fileprivate var popover: Popover!
fileprivate var manager: ZJTableViewManager!
lazy var vm: ViewModel = .init()
override func viewDidLoad() {
super.viewDidLoad()
overrideUserInterfaceStyle = .light
UIApplication.shared.isIdleTimerDisabled = true
navigationController?.setNavigationBarHidden(true, animated: false)
}
}
extension DemoViewController {
@IBAction func switchLanguageAction(_ sender: UIButton) {
let tableView = UITableView(frame: CGRect(x: 0, y: 0, width: 200, height: 135))
// tableView.isScrollEnabled = false
let tableView = UITableView(frame: CGRect(x: 0, y: 0, width: 100, height: 135))
tableView.isScrollEnabled = false
if #available(iOS 15.0, *) {
tableView.sectionHeaderTopPadding = 0
} else {
// Fallback on earlier versions
}
manager = ZJTableViewManager(tableView: tableView)
let section = ZJTableViewSection()
manager.register(LanguageCell.self, LanguageCellItem.self)
let section = ZJTableViewSection(headerHeight: 15, color: .clear)
manager.add(section: section)
for i in 0...2 {
let item = ZJTableViewItem(text: String(i) + " text text")
var currentItem: LanguageCellItem?
for i in ViewModel.Language.allCases {
let item = LanguageCellItem(language: i)
section.add(item: item)
if i == vm.language {
currentItem = item
}
item.setSelectionHandler { [weak self] (callBackItem: LanguageCellItem) in
self?.vm.language = callBackItem.language
self?.popover.dismiss()
}
}
self.popover = Popover(options: [ .type(.up), .blackOverlayColor(UIColor(white: 0.0, alpha: 0.6))])
self.popover.show(tableView, fromView: sender)
currentItem?.select()
popover = Popover(options: [.type(.down), .blackOverlayColor(UIColor(white: 0.0, alpha: 0.6))])
popover.show(tableView, fromView: sender)
}
}
func hexStringToUIColor(hex: String) -> UIColor {
var cString: String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()
if cString.hasPrefix("#") {
cString.remove(at: cString.startIndex)
}
if (cString.count) != 6 {
return UIColor.gray
}
var rgbValue: UInt64 = 0
Scanner(string: cString).scanHexInt64(&rgbValue)
return UIColor(
red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
alpha: CGFloat(1.0)
)
}
let mainColor = hexStringToUIColor(hex: "F58685")
let blackColor = hexStringToUIColor(hex: "322D31")
//
// LanguageCell.swift
// BreastFeedingDemo
//
// Created by jzhang on 2022/9/26.
//
import UIKit
import ZJTableViewManager
class LanguageCellItem: ZJTableViewItem {
var language: ViewModel.Language!
convenience init(language: ViewModel.Language) {
self.init()
self.language = language
}
}
class LanguageCell: UITableViewCell, ZJCellProtocol {
typealias ZJCellItemClass = LanguageCellItem
var item: LanguageCellItem!
@IBOutlet var titleL: UILabel!
@IBOutlet var selectImageV: UIImageView!
func cellWillAppear() {
titleL.text = item.language.rawValue
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated _: Bool) {
// super.setSelected(selected, animated: animated)
selectImageV.isHidden = !selected
titleL.textColor = selected ? mainColor : blackColor
}
}
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="KGk-i7-Jjw" customClass="LanguageCell" customModule="BreastFeedingDemo" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="134" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="134" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="select" translatesAutoresizingMaskIntoConstraints="NO" id="RO8-Z2-XOe">
<rect key="frame" x="10" y="12" width="12" height="20"/>
<constraints>
<constraint firstAttribute="width" constant="12" id="DyO-gU-0fC"/>
<constraint firstAttribute="height" constant="20" id="TNu-nH-gXU"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ssf-40-ayw">
<rect key="frame" x="26" y="0.0" width="108" height="44"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="RO8-Z2-XOe" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="Ao8-8P-Rnb"/>
<constraint firstItem="ssf-40-ayw" firstAttribute="leading" secondItem="RO8-Z2-XOe" secondAttribute="trailing" constant="4" id="DQk-9w-ZRd"/>
<constraint firstAttribute="trailing" secondItem="ssf-40-ayw" secondAttribute="trailing" id="HL1-fP-b7i"/>
<constraint firstItem="ssf-40-ayw" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="SXy-xa-W9p"/>
<constraint firstItem="RO8-Z2-XOe" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="10" id="scz-cy-JxV"/>
<constraint firstAttribute="bottom" secondItem="ssf-40-ayw" secondAttribute="bottom" id="uJF-g8-NXY"/>
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<connections>
<outlet property="selectImageV" destination="RO8-Z2-XOe" id="faS-Tz-DvP"/>
<outlet property="titleL" destination="ssf-40-ayw" id="E5W-WW-5sp"/>
</connections>
<point key="canvasLocation" x="-2.8985507246376816" y="71.651785714285708"/>
</tableViewCell>
</objects>
<resources>
<image name="select" width="14" height="11"/>
</resources>
</document>
......@@ -10,36 +10,36 @@ import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
func scene(_ scene: UIScene, willConnectTo _: UISceneSession, options _: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }
}
func sceneDidDisconnect(_ scene: UIScene) {
func sceneDidDisconnect(_: UIScene) {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}
func sceneDidBecomeActive(_ scene: UIScene) {
func sceneDidBecomeActive(_: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}
func sceneWillResignActive(_ scene: UIScene) {
func sceneWillResignActive(_: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}
func sceneWillEnterForeground(_ scene: UIScene) {
func sceneWillEnterForeground(_: UIScene) {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}
func sceneDidEnterBackground(_ scene: UIScene) {
func sceneDidEnterBackground(_: UIScene) {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
......
......@@ -10,19 +10,19 @@ import Flutter
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var titleL: UILabel!
@IBOutlet weak var stepL1: UILabel!
@IBOutlet weak var stepL2: UILabel!
@IBOutlet weak var stepL3: UILabel!
@IBOutlet weak var startBtn: UIButton!
@IBOutlet weak var panelV: UIStackView!
@IBOutlet weak var popupView: UIView!
@IBOutlet weak var switchBtn: UIButton!
@IBOutlet weak var permisionPopupV: UIView!
@IBOutlet weak var permissionTitle: UILabel!
@IBOutlet weak var permissionText: UILabel!
@IBOutlet weak var permissionOKBtn: UIButton!
@IBOutlet weak var permissionPanel: UIView!
@IBOutlet var titleL: UILabel!
@IBOutlet var stepL1: UILabel!
@IBOutlet var stepL2: UILabel!
@IBOutlet var stepL3: UILabel!
@IBOutlet var startBtn: UIButton!
@IBOutlet var panelV: UIStackView!
@IBOutlet var popupView: UIView!
@IBOutlet var switchBtn: UIButton!
@IBOutlet var permisionPopupV: UIView!
@IBOutlet var permissionTitle: UILabel!
@IBOutlet var permissionText: UILabel!
@IBOutlet var permissionOKBtn: UIButton!
@IBOutlet var permissionPanel: UIView!
var methodChannel: FlutterMethodChannel?
lazy var vm: ViewModel = .init()
var isFirstLoad: Bool = true
......@@ -32,7 +32,7 @@ class ViewController: UIViewController {
stepL1.text = vm.landingPageStep1
stepL2.text = vm.landingPageStep2
stepL3.text = vm.landingPageStep3
permissionText.text = vm.cameraText1
permissionTitle.text = vm.cameraText
permissionOKBtn.setTitle(vm.cameraButtonText, for: .normal)
......@@ -111,13 +111,13 @@ class ViewController: UIViewController {
navigationController?.pushViewController(vc, animated: true)
}
@IBAction func toSetting(_ sender: Any) {
@IBAction func toSetting(_: Any) {
if let appSettingsURL = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(appSettingsURL)
}
}
@IBAction func tapStart(_ sender: Any) {
@IBAction func tapStart(_: Any) {
if checkCameraPermission() == false {
return
}
......@@ -132,12 +132,12 @@ class ViewController: UIViewController {
navigationController?.pushViewController(scanVC, animated: true)
}
}
/// 选择语言
@IBAction func showPanel(_ sender: UIButton) {
sender.isSelected = !sender.isSelected
popupView.isHidden = !sender.isSelected
//
//
(panelV.viewWithTag(1000) as! UIButton).isSelected = false
(panelV.viewWithTag(1001) as! UIButton).isSelected = false
(panelV.viewWithTag(1002) as! UIButton).isSelected = false
......@@ -152,7 +152,7 @@ class ViewController: UIViewController {
}
}
@IBAction func dismissPermissimPanel(_ sender: Any) {
@IBAction func dismissPermissimPanel(_: Any) {
permisionPopupV.isHidden = true
}
......@@ -174,4 +174,3 @@ class ViewController: UIViewController {
updateUI()
}
}
......@@ -8,10 +8,11 @@
import Foundation
class ViewModel {
enum Language: String {
case english
case français = "french"
case español = "spanish"
/// 语言枚举,enum代表语言包文件名,rawValue代表语言选项
enum Language: String, CaseIterable {
case english = "English"
case français = "Français"
case español = "Español"
}
var env: String = "testing"
......@@ -36,7 +37,7 @@ class ViewModel {
var cameraButtonText: String?
var languagePack: [String: Any] {
let languageFile = language.rawValue.appending(".json")
let languageFile = "\(language)".appending(".json")
let path: String = Bundle.main.path(forResource: languageFile, ofType: nil)!
let nsUrl = URL(fileURLWithPath: path)
let nsData = try! Data(contentsOf: nsUrl)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment