Login module logic modification

dev
wenlei 1 year ago
parent c74e0d9041
commit ad0e7b17c7

@ -45,6 +45,12 @@
7751D3742B43C9FA00F1F2BD /* MusicStyleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7751D3732B43C9FA00F1F2BD /* MusicStyleViewController.swift */; };
7751D3762B43E8D200F1F2BD /* MusicStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7751D3752B43E8D200F1F2BD /* MusicStyle.swift */; };
7751D3782B43EA1200F1F2BD /* SearchResultsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7751D3772B43EA1200F1F2BD /* SearchResultsController.swift */; };
7751D37A2B450BB100F1F2BD /* AgreementViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7751D3792B450BB100F1F2BD /* AgreementViewController.swift */; };
7751D37C2B4516BE00F1F2BD /* UILabel+IndieMusic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7751D37B2B4516BE00F1F2BD /* UILabel+IndieMusic.swift */; };
7751D37E2B451EA800F1F2BD /* UserDefaultKeys.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7751D37D2B451EA800F1F2BD /* UserDefaultKeys.swift */; };
7751D3802B45271600F1F2BD /* BindPhoneViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7751D37F2B45271600F1F2BD /* BindPhoneViewModel.swift */; };
7751D3862B45409000F1F2BD /* NSNotification+IndieMusic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7751D3852B45409000F1F2BD /* NSNotification+IndieMusic.swift */; };
7751D3882B45584000F1F2BD /* LaunchADManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7751D3872B45584000F1F2BD /* LaunchADManager.swift */; };
778B8A212AF8E36D0034AFD4 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 778B8A202AF8E36D0034AFD4 /* AppDelegate.swift */; };
778B8A232AF8E36D0034AFD4 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 778B8A222AF8E36D0034AFD4 /* SceneDelegate.swift */; };
778B8A282AF8E36D0034AFD4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 778B8A262AF8E36D0034AFD4 /* Main.storyboard */; };
@ -192,6 +198,13 @@
7751D3732B43C9FA00F1F2BD /* MusicStyleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicStyleViewController.swift; sourceTree = "<group>"; };
7751D3752B43E8D200F1F2BD /* MusicStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicStyle.swift; sourceTree = "<group>"; };
7751D3772B43EA1200F1F2BD /* SearchResultsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultsController.swift; sourceTree = "<group>"; };
7751D3792B450BB100F1F2BD /* AgreementViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgreementViewController.swift; sourceTree = "<group>"; };
7751D37B2B4516BE00F1F2BD /* UILabel+IndieMusic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UILabel+IndieMusic.swift"; sourceTree = "<group>"; };
7751D37D2B451EA800F1F2BD /* UserDefaultKeys.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserDefaultKeys.swift; sourceTree = "<group>"; };
7751D37F2B45271600F1F2BD /* BindPhoneViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BindPhoneViewModel.swift; sourceTree = "<group>"; };
7751D3812B45324300F1F2BD /* IndieMusic-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "IndieMusic-Bridging-Header.h"; sourceTree = "<group>"; };
7751D3852B45409000F1F2BD /* NSNotification+IndieMusic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSNotification+IndieMusic.swift"; sourceTree = "<group>"; };
7751D3872B45584000F1F2BD /* LaunchADManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchADManager.swift; sourceTree = "<group>"; };
778B8A1D2AF8E36D0034AFD4 /* IndieMusic.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = IndieMusic.app; sourceTree = BUILT_PRODUCTS_DIR; };
778B8A202AF8E36D0034AFD4 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
778B8A222AF8E36D0034AFD4 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
@ -451,13 +464,16 @@
778B8A552AF8EAD60034AFD4 /* Extensions */ = {
isa = PBXGroup;
children = (
7751D37D2B451EA800F1F2BD /* UserDefaultKeys.swift */,
778B8AA12AF8ED0E0034AFD4 /* AVPlayer.swift */,
778B8A9F2AF8ED0E0034AFD4 /* Color.swift */,
778B8AA32AF8ED0E0034AFD4 /* RxSwift+Extension */,
778B8AA62AF8ED0E0034AFD4 /* TextView.swift */,
7751D37B2B4516BE00F1F2BD /* UILabel+IndieMusic.swift */,
778B8AA72AF8ED0E0034AFD4 /* UIColor+IndieMusic.swift */,
778B8AA02AF8ED0E0034AFD4 /* UIImage+IndieMusic.swift */,
778B8AA22AF8ED0E0034AFD4 /* UIView+Borders.swift */,
7751D3852B45409000F1F2BD /* NSNotification+IndieMusic.swift */,
);
path = Extensions;
sourceTree = "<group>";
@ -471,6 +487,7 @@
778B8A962AF8ECFC0034AFD4 /* LogManager.swift */,
778B8A932AF8ECFB0034AFD4 /* Reachability.swift */,
778B8A982AF8ECFC0034AFD4 /* ThemeManager.swift */,
7751D3872B45584000F1F2BD /* LaunchADManager.swift */,
);
path = Managers;
sourceTree = "<group>";
@ -527,6 +544,7 @@
isa = PBXGroup;
children = (
778B8A602AF8ECC20034AFD4 /* RxErrorTracker */,
7751D3812B45324300F1F2BD /* IndieMusic-Bridging-Header.h */,
);
path = "Third Party";
sourceTree = "<group>";
@ -570,8 +588,10 @@
77FA0B492B0EE8F000404C5E /* PhoneCodeController.swift */,
77FA0B4F2B0EFEF400404C5E /* PhoneCodeView.swift */,
77FA0B452B0DFAFD00404C5E /* BindPhoneViewController.swift */,
7751D37F2B45271600F1F2BD /* BindPhoneViewModel.swift */,
77FA0B472B0DFB0E00404C5E /* EditBindPhoneViewController.swift */,
77FA0B432B0DFABD00404C5E /* LoginView.swift */,
7751D3792B450BB100F1F2BD /* AgreementViewController.swift */,
);
path = Login;
sourceTree = "<group>";
@ -744,6 +764,7 @@
TargetAttributes = {
778B8A1C2AF8E36D0034AFD4 = {
CreatedOnToolsVersion = 15.0;
LastSwiftMigration = 1500;
};
778B8A322AF8E36E0034AFD4 = {
CreatedOnToolsVersion = 15.0;
@ -948,7 +969,10 @@
7751D35E2B42B61100F1F2BD /* PersonInfo.swift in Sources */,
774399A82AFE28BA006F8EEA /* BlurEffectView.swift in Sources */,
778B8A852AF8ECE50034AFD4 /* SearchViewController.swift in Sources */,
7751D3802B45271600F1F2BD /* BindPhoneViewModel.swift in Sources */,
774A17F52B045F1C00F56DF1 /* Player.swift in Sources */,
7751D3882B45584000F1F2BD /* LaunchADManager.swift in Sources */,
7751D37A2B450BB100F1F2BD /* AgreementViewController.swift in Sources */,
778B8AAB2AF8ED0E0034AFD4 /* UIView+Borders.swift in Sources */,
778B8AC12AF8ED280034AFD4 /* TableView.swift in Sources */,
778B8A9C2AF8ECFC0034AFD4 /* LogManager.swift in Sources */,
@ -969,6 +993,7 @@
778B8A912AF8ECF20034AFD4 /* Album.swift in Sources */,
778B8A232AF8E36D0034AFD4 /* SceneDelegate.swift in Sources */,
778B8A6F2AF8ECD30034AFD4 /* APIConfig.swift in Sources */,
7751D37E2B451EA800F1F2BD /* UserDefaultKeys.swift in Sources */,
778B8A8E2AF8ECF20034AFD4 /* Artist.swift in Sources */,
774A17F32B0459C900F56DF1 /* PlayerViewModel.swift in Sources */,
778B8A6D2AF8ECD30034AFD4 /* Observable+Operators.swift in Sources */,
@ -986,6 +1011,7 @@
778B8A812AF8ECE50034AFD4 /* HomeTabBarViewModel.swift in Sources */,
77FA0B4A2B0EE8F000404C5E /* PhoneCodeController.swift in Sources */,
778B8AC02AF8ED280034AFD4 /* ViewController.swift in Sources */,
7751D3862B45409000F1F2BD /* NSNotification+IndieMusic.swift in Sources */,
774399A02AFA1968006F8EEA /* PlayerTabBar.swift in Sources */,
77FA0B3C2B0C55E500404C5E /* FilterView.swift in Sources */,
77FA0B5C2B147EE800404C5E /* CommentView.swift in Sources */,
@ -1011,6 +1037,7 @@
77FA0B2A2B0B5F0D00404C5E /* AudioMoreActionView.swift in Sources */,
778B8A6C2AF8ECD30034AFD4 /* Networking.swift in Sources */,
77FA0B2E2B0C485D00404C5E /* AudioMoreAction.swift in Sources */,
7751D37C2B4516BE00F1F2BD /* UILabel+IndieMusic.swift in Sources */,
778B8AAC2AF8ED0E0034AFD4 /* UIViewController+Rx.swift in Sources */,
778B8A8D2AF8ECF20034AFD4 /* APIImage.swift in Sources */,
7751D36A2B42ED6C00F1F2BD /* TimingViewController.swift in Sources */,
@ -1205,16 +1232,19 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 352QFH5MA9;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = IndieMusic/Resources/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "雀乐";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UIUserInterfaceStyle = Light;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
@ -1226,6 +1256,8 @@
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = "IndieMusic/Third Party/IndieMusic-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
@ -1237,16 +1269,19 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 352QFH5MA9;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = IndieMusic/Resources/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "雀乐";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UIUserInterfaceStyle = Light;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
@ -1258,6 +1293,7 @@
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = "IndieMusic/Third Party/IndieMusic-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};

@ -16,10 +16,12 @@ final class Application: NSObject {
var provider: IndieMusicAPI?
let navigator: Navigator
let authManager: AuthManager
let launchADManager: LaunchADManager
private override init() {
authManager = AuthManager.shared
launchADManager = LaunchADManager.shared
navigator = Navigator.default
super.init()
updateProvider()

@ -21,6 +21,7 @@ class Navigator {
enum Scene {
case tabs(viewModel: HomeTabBarViewModel)
case search(viewModel: HomeTabBarViewModel)
case journalDetail(viewModel: JournalDetailViewModel)
case safari(URL)
case safariController(URL)
@ -56,7 +57,9 @@ class Navigator {
return rootVC
case .search(let viewModel): return SearchViewController(viewModel: viewModel, navigator: self)
case .journalDetail(viewModel: let viewModel):
return JournalDetailController.init(viewModel: viewModel, navigator: self)
case .safari(let url):
UIApplication.shared.open(url, options: [:], completionHandler: nil)
@ -140,7 +143,8 @@ class Navigator {
DispatchQueue.main.async {
sender.present(target, animated: true, completion: nil)
}
default: break
default:
break
}
}

@ -9,7 +9,7 @@ import UIKit
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
class SceneDelegate: UIResponder, UIWindowSceneDelegate, WXApiDelegate {
var window: UIWindow?
@ -56,6 +56,44 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// to restore the scene back to its current state.
}
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
if let url = userActivity.webpageURL {
WXApi.handleOpen(url, delegate: self)
}
}
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
print("scene7")
print(URLContexts.first?.url)
if let context = URLContexts.first {
var options = [UIApplication.OpenURLOptionsKey: Any]()
options[.sourceApplication] = context.options.sourceApplication
options[.annotation] = context.options.annotation
options[.openInPlace] = context.options.openInPlace
if ((URLContexts.first?.url.host!)! as String) == "safepay" {
}
}
}
func onResp(_ resp: BaseResp) {
//
if let response = resp as? SendAuthResp,
let code = response.code, response.errCode == 0, response.type == 0 {
debugPrint("code: " , code)
NotificationCenter.default.post(name: .notiWecahtResp, object: resp.errCode)
}
}
}

@ -46,6 +46,16 @@ class NavigationController: UINavigationController {
UINavigationBar.appearance().compactAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
//
// navigationBar.barTintColor = UIColor.white
navigationBar.isTranslucent = false
// 线
// let image = UIImage().generateImageWithColor(color: .white)
// navigationBar.setBackgroundImage(image, for: .default)
// navigationBar.shadowImage = image
appearance.shadowColor = .clear
}
@ -93,22 +103,19 @@ extension NavigationController {
// let leftBarBtn = UIBarButtonItem(title: "", style: .plain, target: self,action: #selector(backAction))
// leftBarBtn.image = UIImage(named: "nav_back_icon")
// self.navigationItem.leftBarButtonItem = leftBarBtn
let button = UIButton.init()
button.setImage(UIImage(named:"nav_back_btn"), for: .normal)
button.setTitle("返回1", for: .normal)
button.addTarget(self, action: #selector(backAction), for: .touchUpInside)
let leftBarBtn = UIBarButtonItem(customView: button)
//
let spacer = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil,
action: nil)
spacer.width = -10
self.navigationItem.leftBarButtonItems = [spacer,leftBarBtn]
// let button = UIButton.init()
// button.setImage(UIImage(named:"nav_back_btn"), for: .normal)
//// button.setTitle("1", for: .normal)
// button.addTarget(self, action: #selector(backAction), for: .touchUpInside)
//
// let leftBarBtn = UIBarButtonItem(customView: button)
//
// //
// let spacer = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil,
// action: nil)
// spacer.width = -10
//
// self.navigationItem.leftBarButtonItem = leftBarBtn
}
super.pushViewController(viewController, animated: animated)
}

@ -9,7 +9,7 @@ import UIKit
import RxSwift
import RxCocoa
class ViewController: UIViewController {
class ViewController: UIViewController, Navigatable {
var viewModel: ViewModel?
var navigator: Navigator!
@ -120,6 +120,7 @@ class ViewController: UIViewController {
view.backgroundColor = .white
// navigationItem.leftBarButtonItem = backBarButton
updateUI()
}

@ -30,6 +30,7 @@ struct Configs {
static let aggrementUrl = environmentType.baseUrl + ""
static let universalLink = ""
static let bundleIdentifier = "cn.indie.queyue"
static let wechatURL = "https://api.weixin.qq.com"
}

@ -0,0 +1,15 @@
//
// NSNotification+IndieMusic.swift
// IndieMusic
//
// Created by WenLei on 2024/1/3.
//
import Foundation
extension Notification.Name {
///
static let notiWecahtResp = Notification.Name("notiWecahtResp")
}

@ -26,4 +26,16 @@ extension UIImage {
UIGraphicsEndImageContext()
return newImage
}
func generateImageWithColor(color:UIColor) -> UIImage{
let rect = CGRect.init(x: 0, y: 0, width: 1, height: 1)
UIGraphicsBeginImageContext(rect.size)
let context = UIGraphicsGetCurrentContext()!
context.setFillColor(color.cgColor)
context.fill(rect)
let img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img!
}
}

@ -0,0 +1,25 @@
//
// UILabel+IndieMusic.swift
// IndieMusic
//
// Created by WenLei on 2024/1/3.
//
import Foundation
import UIKit
extension UILabel {//
func addAttributed(attributedes: Array<(string: String, dic: Dictionary<NSAttributedString.Key, Any>)>) {
let attributedString = NSMutableAttributedString.init()
for attributed in attributedes {
let attr = NSAttributedString.init(string: attributed.string, attributes: attributed.dic)
attributedString.append(attr)
}
self.attributedText = attributedString
}
}

@ -0,0 +1,170 @@
//
// UserDefaultKeys.swift
// HuHeHaoTePolice
//
// Created by Willei Wang on 2018/5/7.
// Copyright © 2018 Willei Wang. All rights reserved.
//
import UIKit
protocol UserDefaultsSettable {
associatedtype defaultKeys: RawRepresentable
}
extension UserDefaultsSettable where defaultKeys.RawValue == String {
// set
static func set(_ value: String?, forKey key: defaultKeys) {
let aKey = key.rawValue
UserDefaults.standard.set(value, forKey: aKey)
}
static func set(_ value: Int?, forKey key: defaultKeys) {
let aKey = key.rawValue
UserDefaults.standard.set(value, forKey: aKey)
}
static func set(_ value: Bool?, forKey key: defaultKeys) {
let aKey = key.rawValue
UserDefaults.standard.set(value, forKey: aKey)
}
static func set(_ value: Double?, forKey key: defaultKeys) {
let aKey = key.rawValue
UserDefaults.standard.set(value, forKey: aKey)
}
static func set(_ value: Float?, forKey key: defaultKeys) {
let aKey = key.rawValue
UserDefaults.standard.set(value, forKey: aKey)
}
static func set(_ value: URL?, forKey key: defaultKeys) {
let aKey = key.rawValue
UserDefaults.standard.set(value, forKey: aKey)
}
static func set(_ value: Any?, forKey key: defaultKeys) {
let aKey = key.rawValue
UserDefaults.standard.set(value, forKey: aKey)
}
static func set<T: Encodable>(model: T?, forKey key: defaultKeys) {
let aKey = key.rawValue
UserDefaults.standard.set(model: model, forKey: aKey)
}
// get
static func string(forKey key: defaultKeys) -> String? {
let aKey = key.rawValue
return UserDefaults.standard.string(forKey: aKey)
}
static func integer(forKey key: defaultKeys) -> Int? {
let aKey = key.rawValue
return UserDefaults.standard.integer(forKey: aKey)
}
static func double(forKey key: defaultKeys) -> Double? {
let aKey = key.rawValue
return UserDefaults.standard.double(forKey: aKey)
}
static func bool(forKey key: defaultKeys) -> Bool? {
let aKey = key.rawValue
return UserDefaults.standard.bool(forKey: aKey)
}
static func float(forKey key: defaultKeys) -> Float? {
let aKey = key.rawValue
return UserDefaults.standard.float(forKey: aKey)
}
static func url(forKey key: defaultKeys) -> URL? {
let aKey = key.rawValue
return UserDefaults.standard.url(forKey: aKey)
}
static func object(forKey key: defaultKeys) -> Any? {
let aKey = key.rawValue
return UserDefaults.standard.object(forKey: aKey)
}
static func model<T: Decodable>(forKey key: defaultKeys) -> T? {
let aKey = key.rawValue
return UserDefaults.standard.model(forKey: aKey)
}
// remove
static func remove(forKey key: defaultKeys){
let aKey = key.rawValue
return UserDefaults.standard.removeObject(forKey: aKey)
}
}
/// UserDefaultsmodel
extension UserDefaults {
func set<T: Encodable>(model: T?, forKey key: String) {
if let model = model {
let encoded = try? JSONEncoder().encode(model)
UserDefaults.standard.set(encoded, forKey: key)
} else {
UserDefaults.standard.removeObject(forKey: key)
}
}
func model<T: Decodable>(forKey key: String) -> T? {
if let data = UserDefaults.standard.data(forKey: key) {
return try? JSONDecoder().decode(T.self, from: data)
}
return nil
}
}
extension UserDefaults {
//
struct AccountInfo: UserDefaultsSettable {
enum defaultKeys: String {
case userToken
case userID
}
}
struct Setting: UserDefaultsSettable {
enum defaultKeys: String {
/// Debug
case isOpenDebug
///
case currentBaseUrl
}
}
struct CustomerInfo: UserDefaultsSettable {
enum defaultKeys: String {
case pushToken
case isPrivacyPolicyAllowed
}
}
}
func removeAllDefaultKeys() {
UserDefaults.AccountInfo.remove(forKey: .userID)
}

@ -0,0 +1,120 @@
//
// LaunchADManager.swift
// IndieMusic
//
// Created by WenLei on 2024/1/3.
//
import UIKit
import XHLaunchAd
class LaunchADManager: NSObject, XHLaunchAdDelegate {
static let shared = LaunchADManager()
override init() {
super.init()
self.setupXHLaunchAd()
}
// override init() {
// super
// }
func becomeActive() {
self.setupXHLaunchAd()
}
func setupXHLaunchAd() {
photoAD()
}
func photoAD() {
XHLaunchAd.setLaunch(.launchScreen)
XHLaunchAd.setWaitDataDuration(2)
//广
let imageAdconfiguration = XHLaunchImageAdConfiguration.init()
imageAdconfiguration.duration = 4
imageAdconfiguration.frame = CGRect.init(x: 0, y: 0, width: BaseDimensions.screenWidth, height: BaseDimensions.screenHeight)
// imageAdconfiguration.imageNameOrURLString = adModel.mediaUrl ?? ""
//()
//,XHLaunchAdImageCacheInBackground,,
imageAdconfiguration.imageOption = .cacheInBackground
imageAdconfiguration.contentMode = .scaleAspectFill
// imageAdconfiguration.openModel = adModel.pointTo ?? ""
//广
imageAdconfiguration.showFinishAnimate = .fadein
//广
imageAdconfiguration.showFinishAnimateTime = 0.4
//
imageAdconfiguration.skipButtonType = .timeText
// imageAdconfiguration.customSkipView = self.skipButton()
//,广
imageAdconfiguration.showEnterForeground = false
// - "" ()
// if XHLaunchAd.checkImageInCache(with: URL.init(string: model.mediaUrl)) {
// //()
//// imageAdconfiguration.subViews = [self launchAdSubViews_alreadyView];
// }
//广
XHLaunchAd.imageAd(with: imageAdconfiguration, delegate: self)
}
func skipButton() -> UIButton {
let skipButton = UIButton.init(frame: CGRect.init(x: BaseDimensions.screenWidth - 100, y: BaseDimensions.topHeight, width: 85, height: 30))
skipButton.titleLabel?.font = UIFont.systemFont(ofSize: 14)
skipButton.layer.cornerRadius = 5.0
skipButton.layer.borderWidth = 1.5
skipButton.layer.borderColor = UIColor.lightGray.cgColor
skipButton.backgroundColor = .gray
skipButton.setTitleColor(.white, for: .normal)
skipButton.addTarget(self, action: #selector(skipAction), for: .touchUpInside)
skipButton.setTitle("跳过", for: .normal)
return skipButton
}
// @objc func skipButtonClick() {
//
// }
///
@objc func skipAction() {
XHLaunchAd.removeAnd(animated: true)
}
//
func xhLaunchAd(_ launchAd: XHLaunchAd, clickAndOpenModel openModel: Any, click clickPoint: CGPoint) {
/** openModel广广(configuration.openModel) */
// let webVC = WebViewController.init(viewModel: nil, )
// webVC.url = openModel as? String
// MainRootVc?.children.first?.navigationController?.pushViewController(webVC, animated: true)
}
func xhLaunchAdShowFinish(_ launchAd: XHLaunchAd) {
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "notiShowAD"), object: nil, userInfo: nil)
}
func xhLaunchAd(_ launchAd: XHLaunchAd, customSkip customSkipView: UIView, duration: Int) {
var button = self.skipButton()
//
button.setTitle("\(duration)跳过", for: .normal)
}
}

@ -8,6 +8,11 @@
import Foundation
import RxSwift
import RxCocoa
import SnapKit
import SwiftDate
//import Bugly
class LibsManager: NSObject {
static let shared = LibsManager()
@ -15,6 +20,13 @@ class LibsManager: NSObject {
private override init() {
super.init()
setupSwiftDate()
setupWeChatSDK()
}
func setupSwiftDate() {
let chinaTime = Region.init(calendar: Calendars.gregorian, zone: Zones.current, locale: Locales.chinese)
SwiftDate.defaultRegion = chinaTime
}
func setupLibs(with window: UIWindow? = nil) {
@ -22,4 +34,20 @@ class LibsManager: NSObject {
}
func setupXHLaunchAd() {
// 广
}
func setupWeChatSDK() {
WXApi.startLog(by: .detail) { (log) in
print("微信log\(log)")
}
WXApi.registerApp(Keys.wechat.appId, universalLink: Configs.App.universalLink)
// WXApi.checkUniversalLinkReady { (step, result) in
// print("\(step.rawValue) :\(result)")
// }
}
}

@ -12,7 +12,6 @@ class HomeNumberView: UIView {
lazy var numberLabel: UILabel = {
let numberLabel = UILabel.init()
numberLabel.font = UIFont.systemFont(ofSize: 18, weight: .medium)
numberLabel.textAlignment = .center
return numberLabel
}()
@ -20,18 +19,32 @@ class HomeNumberView: UIView {
lazy var lineView: UIView = {
let lineView = UIView.init()
lineView.backgroundColor = .init(hex: 0xB82E2E)
lineView.layer.insertSublayer(gradientLayer, at: 0)
return lineView
}()
lazy var tipsLabel: UILabel = {
let tipsLabel = UILabel.init()
tipsLabel.textAlignment = .center
tipsLabel.font = UIFont.systemFont(ofSize: 10, weight: .medium)
tipsLabel.text = "V O L"
return tipsLabel
}()
var gradientLayer: CAGradientLayer = {
let gradientLayer = CAGradientLayer.init()
gradientLayer.colors = [UIColor.init(hex: 0xFFFFFF, alpha: 0).cgColor,
UIColor.init(hex: 0xFFFFFF, alpha: 0.8).cgColor]
gradientLayer.locations = [0.0, 0.9]
gradientLayer.startPoint = CGPoint.init(x: 0 , y: 0)
gradientLayer.endPoint = CGPoint.init(x: 1, y: 0)
return gradientLayer
}()
override init(frame: CGRect) {
super.init(frame: frame)
@ -57,21 +70,24 @@ class HomeNumberView: UIView {
override func layoutSubviews() {
super.layoutSubviews()
gradientLayer.frame = lineView.bounds
numberLabel.snp.makeConstraints { make in
make.left.equalTo(self)
make.left.equalTo(self).offset(6)
make.right.equalTo(self)
make.top.equalTo(3)
}
lineView.snp.makeConstraints { make in
make.left.equalTo(self).offset(20)
make.right.equalTo(self).offset(-20)
make.left.equalTo(self).offset(6)
make.right.equalTo(self).offset(-19)
make.height.equalTo(2)
make.top.equalTo(numberLabel.snp.bottom).offset(3)
}
tipsLabel.snp.makeConstraints { make in
make.left.equalTo(self)
make.left.equalTo(self).offset(6)
make.right.equalTo(self)
make.top.equalTo(lineView.snp.bottom).offset(3)
make.bottom.equalTo(self).offset(-6)
@ -82,7 +98,16 @@ class HomeNumberView: UIView {
}
class HomeViewCell: UITableViewCell {
lazy var titleImageView: UIImageView = {
let containerView: UIView = {
let containerView = UIView.init()
containerView.layer.cornerRadius = 6
containerView.layer.masksToBounds = true
return containerView
}()
var titleImageView: UIImageView = {
let titleImageView = UIImageView.init()
titleImageView.backgroundColor = .blue
@ -91,7 +116,10 @@ class HomeViewCell: UITableViewCell {
lazy var titleLabel: UILabel = {
let titleLabel = UILabel.init()
titleLabel.font = UIFont.systemFont(ofSize: 17, weight: .medium)
titleLabel.textColor = .white
titleLabel.numberOfLines = 2
titleLabel.textColor = .primaryText()
return titleLabel
}()
@ -105,7 +133,9 @@ class HomeViewCell: UITableViewCell {
lazy var subTitleLabel: UILabel = {
let subTitleLabel = UILabel.init()
subTitleLabel.font = UIFont.systemFont(ofSize: 15)
subTitleLabel.numberOfLines = 2
subTitleLabel.textColor = .primaryText()
return subTitleLabel
}()
@ -119,7 +149,8 @@ class HomeViewCell: UITableViewCell {
lazy var commentLabel: UILabel = {
let commentLabel = UILabel.init()
commentLabel.font = UIFont.systemFont(ofSize: 12)
commentLabel.textColor = .secondaryText()
return commentLabel
}()
@ -133,6 +164,8 @@ class HomeViewCell: UITableViewCell {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
selectionStyle = .none
makeUI()
titleLabel.text = "标题标题标题标题标题标题"
@ -145,21 +178,36 @@ class HomeViewCell: UITableViewCell {
}
func makeUI() {
contentView.addSubview(titleImageView)
// contentView.layer.cornerRadius = 6
// contentView.layer.masksToBounds = true
contentView.backgroundColor = .init(hex: 0xf2f3f7)
containerView.backgroundColor = .white
contentView.addSubview(containerView)
containerView.addSubview(titleImageView)
titleImageView.addSubview(homeNumberView)
titleImageView.addSubview(titleLabel)
contentView.addSubview(subTitleLabel)
contentView.addSubview(multiUserAvatarView)
contentView.addSubview(commentLabel)
contentView.addSubview(commentCountButton)
containerView.addSubview(subTitleLabel)
containerView.addSubview(multiUserAvatarView)
containerView.addSubview(commentLabel)
containerView.addSubview(commentCountButton)
containerView.snp.makeConstraints { make in
make.left.equalTo(contentView).offset(18)
make.right.equalTo(contentView).offset(-18)
make.top.equalTo(contentView)
make.bottom.equalTo(contentView).offset(-16)
}
titleImageView.snp.makeConstraints { make in
make.left.equalTo(contentView)
make.right.equalTo(contentView)
make.top.equalTo(contentView)
make.left.equalTo(containerView)
make.right.equalTo(containerView)
make.top.equalTo(containerView)
make.height.equalTo(202)
}
@ -177,18 +225,18 @@ class HomeViewCell: UITableViewCell {
}
subTitleLabel.snp.makeConstraints { make in
make.left.equalTo(contentView).offset(12)
make.right.equalTo(contentView).offset(-12)
make.left.equalTo(containerView).offset(12)
make.right.equalTo(containerView).offset(-12)
make.top.equalTo(titleImageView.snp.bottom).offset(11)
}
multiUserAvatarView.snp.makeConstraints { make in
make.left.equalTo(contentView).offset(12)
make.bottom.equalTo(contentView).offset(-21)
make.left.equalTo(containerView).offset(12)
make.bottom.equalTo(containerView).offset(-21)
}
commentCountButton.snp.makeConstraints { make in
make.right.equalTo(contentView).offset(-2)
make.right.equalTo(containerView).offset(-2)
make.centerY.equalTo(multiUserAvatarView)
make.size.equalTo(CGSize.init(width: 40, height: 24))
}
@ -202,6 +250,23 @@ class HomeViewCell: UITableViewCell {
}
// override var frame:CGRect{
// didSet {
// let insetX: CGFloat = 18
// let insetY: CGFloat = 0.0
//
// var newFrame = frame
// newFrame.origin.x += insetX
// newFrame.origin.y += insetY
//
// newFrame.size.width -= 2*insetX
// newFrame.size.height -= 2*insetY
//
//
// super.frame = newFrame
// }
// }
//
}

@ -11,6 +11,7 @@ import RxSwift
import RxCocoa
import RxDataSources
import Kingfisher
import ETNavBarTransparent
class HomeViewController: TableViewController {
@ -43,18 +44,18 @@ class HomeViewController: TableViewController {
// self.navigationController?.pushViewController(vc, animated: true)
guard let viewModel = viewModel as? HomeViewModel else { return }
// let login = LoginViewController.init(viewModel: viewModel, navigator: navigator)
// let loginViewModel = LoginViewModel.init(provider: viewModel.provider)
// let login = LoginViewController.init(viewModel: loginViewModel, navigator: navigator)
// self.navigationController?.pushViewController(login, animated: true)
}
override func makeUI() {
super.makeUI()
view.backgroundColor = .white
let headerView = UIView.init(frame: CGRect.init(x: 0, y: 0, width: BaseDimensions.screenWidth, height: 120))
pagerView.frame = headerView.bounds
pagerView.backgroundColor = .red
@ -89,7 +90,12 @@ class HomeViewController: TableViewController {
output.itemSelected.subscribe { sectionItem in
switch sectionItem {
default: break
default:
let journalDetailViewModel = JournalDetailViewModel.init(provider: viewModel.provider)
self.navigator.show(segue: .journalDetail(viewModel: journalDetailViewModel), sender: self)
}
}.disposed(by: rx.disposeBag)
@ -161,7 +167,7 @@ extension HomeViewController {
extension HomeViewController {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 320
return 338
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {

@ -31,6 +31,7 @@ class HomeViewModel: ViewModel, ViewModelType {
input.viewWillAppear.subscribe { (_) in
}.disposed(by: rx.disposeBag)

@ -0,0 +1,176 @@
//
// AgreementViewController.swift
// IndieMusic
//
// Created by WenLei on 2024/1/3.
//
import UIKit
class AgreementViewController: UIViewController {
let containerView: UIView = {
let containerView = UIView.init()
containerView.backgroundColor = .white
containerView.layer.cornerRadius = 12
return containerView
}()
let bottomMenuView: UIView = {
let bottomMenuView = UIView.init()
return bottomMenuView
}()
let titleLabel: UILabel = {
let titleLabel = UILabel.init()
titleLabel.textAlignment = .center
titleLabel.font = UIFont.systemFont(ofSize: 16, weight: .medium)
titleLabel.textColor = .init(hex: 0x323233)
titleLabel.text = "阅读并同意以下协议"
return titleLabel
}()
let detailTextView: UITextView = {
let detailTextView = UITextView.init()
detailTextView.textAlignment = .center
detailTextView.font = UIFont.systemFont(ofSize: 12)
detailTextView.textColor = .init(hex: 0x323233)
detailTextView.tintColor = UIColor.primaryText()
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = .center
paragraphStyle.lineSpacing = 5
detailTextView.addAttributed(attributedes: [("已阅读并同意 ", [NSAttributedString.Key.foregroundColor: UIColor.secondaryText(), NSAttributedString.Key.paragraphStyle: paragraphStyle]),
("《用户协议隐私政策》", [NSAttributedString.Key.foregroundColor: UIColor.primaryText(), NSAttributedString.Key.link: URL.init(string: Configs.App.aggrementUrl) ?? "", NSAttributedString.Key.paragraphStyle: paragraphStyle, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 12, weight: .medium)]),
(" 并授权获取本机号码", [NSAttributedString.Key.foregroundColor: UIColor.secondaryText(), NSAttributedString.Key.paragraphStyle: paragraphStyle])
])
return detailTextView
}()
let cancelButton: UIButton = {
let cancelButton = UIButton.init()
cancelButton.titleLabel?.font = UIFont.systemFont(ofSize: 16)
cancelButton.setTitle("取消", for: .normal)
cancelButton.setTitleColor(UIColor.tertiaryText(), for: .normal)
cancelButton.addTarget(self, action: #selector(cancelButtonClicked), for: .touchUpInside)
return cancelButton
}()
let confirmButton: UIButton = {
let confirmButton = UIButton.init()
confirmButton.titleLabel?.font = UIFont.systemFont(ofSize: 16)
confirmButton.setTitle("已阅读并同意", for: .normal)
confirmButton.setTitleColor(UIColor.primaryText(), for: .normal)
confirmButton.addTarget(self, action: #selector(confirmButtonClick), for: .touchUpInside)
return confirmButton
}()
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
self.modalPresentationStyle = .custom
self.transitioningDelegate = self
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
makeUI()
}
func makeUI() {
view.addSubview(containerView)
containerView.addSubview(titleLabel)
containerView.addSubview(detailTextView)
containerView.addSubview(bottomMenuView)
bottomMenuView.addSubview(cancelButton)
bottomMenuView.addSubview(confirmButton)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
containerView.snp.makeConstraints { make in
make.size.equalTo(CGSize.init(width: 311, height: 174))
make.center.equalTo(view)
}
bottomMenuView.snp.makeConstraints { make in
make.left.equalTo(containerView)
make.right.equalTo(containerView)
make.bottom.equalTo(containerView)
make.height.equalTo(48)
}
titleLabel.snp.makeConstraints { make in
make.top.equalTo(containerView).offset(26)
make.left.equalTo(containerView).offset(24)
make.right.equalTo(containerView).offset(-24)
}
detailTextView.snp.makeConstraints { make in
make.left.equalTo(containerView).offset(24)
make.right.equalTo(containerView).offset(-24)
make.top.equalTo(titleLabel.snp.bottom).offset(12)
make.height.equalTo(40)
}
cancelButton.snp.makeConstraints { make in
make.left.equalTo(bottomMenuView)
make.right.equalTo(bottomMenuView.snp.centerX)
make.top.equalTo(bottomMenuView)
make.bottom.equalTo(bottomMenuView)
}
confirmButton.snp.makeConstraints { make in
make.right.equalTo(bottomMenuView)
make.left.equalTo(bottomMenuView.snp.centerX)
make.top.equalTo(bottomMenuView)
make.bottom.equalTo(bottomMenuView)
}
}
@objc func cancelButtonClicked() {
}
@objc func confirmButtonClick() {
}
}
extension AgreementViewController: UIViewControllerTransitioningDelegate {
func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
let carePresentationVC = CardPresentationController.init(presentedViewController: presented, presenting: presenting)
carePresentationVC.viewType = .tips(false)
return carePresentationVC
}
}

@ -97,7 +97,7 @@ class BindPhoneViewController: ViewController {
super.viewDidLayoutSubviews()
titleLabel.snp.makeConstraints { make in
make.top.equalTo(view).offset(BaseDimensions.topHeight + 19)
make.top.equalTo(view).offset(19)
make.left.equalTo(view).offset(24)
}

@ -0,0 +1,25 @@
//
// BindPhoneViewModel.swift
// IndieMusic
//
// Created by WenLei on 2024/1/3.
//
import Foundation
class BindPhoneViewModel: ViewModel, ViewModelType {
struct Input {
}
struct Output {
}
func transform(input: Input) -> Output {
return Output.init()
}
}

@ -59,7 +59,7 @@ class EditBindPhoneViewController: UIViewController {
super.viewDidLayoutSubviews()
titleLabel.snp.makeConstraints { make in
make.top.equalTo(view).offset(BaseDimensions.topHeight + 62)
make.top.equalTo(view).offset(62)
make.centerX.equalTo(view)
}

@ -165,15 +165,6 @@ class PhoneCodeView: UIView {
}
class OtherLoginView: UIView {
lazy var titleLabel: UILabel = {
let titleLabel = UILabel.init()
titleLabel.font = UIFont.systemFont(ofSize: 12)
titleLabel.textColor = UIColor.init(hex: 0x000000, alpha: 0.4)
titleLabel.text = "其他登录方式"
return titleLabel
}()
lazy var weChatButton: UIButton = {
let weChatButton = UIButton.init()
weChatButton.setImage(UIImage.init(named: "login_wechat_btn"), for: .normal)
@ -199,7 +190,6 @@ class OtherLoginView: UIView {
}
func makeUI() {
addSubview(titleLabel)
addSubview(weChatButton)
addSubview(appleButton)
}
@ -207,21 +197,17 @@ class OtherLoginView: UIView {
override func layoutSubviews() {
super.layoutSubviews()
titleLabel.snp.makeConstraints { make in
make.centerX.equalTo(self)
make.top.equalTo(self)
}
weChatButton.snp.makeConstraints { make in
make.right.equalTo(self.snp.centerX).offset(-12)
make.top.equalTo(titleLabel.snp.bottom).offset(20)
make.bottom.equalTo(self).offset(0)
make.top.equalTo(self)
make.bottom.equalTo(self)
}
appleButton.snp.makeConstraints { make in
make.left.equalTo(self.snp.centerX).offset(12)
make.top.equalTo(titleLabel.snp.bottom).offset(20)
make.bottom.equalTo(self).offset(0)
make.top.equalTo(self)
make.bottom.equalTo(self)
}
}
}
@ -233,13 +219,14 @@ class LoginAgreementView: UIView {
announceCheckBoxView.setImage(UIImage.init(named: "login_agreement_on")?.withRenderingMode(.alwaysTemplate), for: .selected)
announceCheckBoxView.setContentHuggingPriority(.required, for: .horizontal)
announceCheckBoxView.setContentCompressionResistancePriority(.required, for: .horizontal)
// announceCheckBoxView.addTarget(self, action: #selector(announceCheckBoxViewClick), for: .touchUpInside)
announceCheckBoxView.addTarget(self, action: #selector(announceCheckBoxViewClick), for: .touchUpInside)
return announceCheckBoxView
}()
lazy var announceTextView: UITextView = {
let announceTextView = UITextView.init()
announceTextView.backgroundColor = .clear
announceTextView.font = UIFont.systemFont(ofSize: 12)
announceTextView.textAlignment = .left
announceTextView.isScrollEnabled = false
@ -258,7 +245,7 @@ class LoginAgreementView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
// backgroundColor = .red
// backgroundColor = .clear
makeUI()
}
@ -289,6 +276,10 @@ class LoginAgreementView: UIView {
}
}
@objc func announceCheckBoxViewClick() {
self.announceCheckBoxView.isSelected.toggle()
}
}

@ -11,7 +11,8 @@ class LoginViewController: ViewController {
var backgroundImageView: UIImageView = {
let backgroundImageView = UIImageView.init(image: UIImage.init(named: "login_bakcground"))
backgroundImageView.contentMode = .scaleAspectFit
// backgroundImageView.contentMode = .bottom
return backgroundImageView
}()
@ -64,11 +65,6 @@ class LoginViewController: ViewController {
return otherLoginView
}()
override func viewDidLoad() {
super.viewDidLoad()
@ -77,7 +73,7 @@ class LoginViewController: ViewController {
if let tabbar = self.tabBarController as? HomeTabBarController {
tabbar.showTabBar(false, animated: true)
}
}
@ -99,12 +95,35 @@ class LoginViewController: ViewController {
override func bindViewModel() {
super.bindViewModel()
guard let viewModel = viewModel as? LoginViewModel else { return }
let agreementBoxSelected = loginAgreementView.announceCheckBoxView.rx.tap.map{!self.loginAgreementView.announceCheckBoxView.isSelected}.asDriver(onErrorJustReturn: false)
let input = LoginViewModel.Input.init(codeButtonTrigger: loginButton.rx.tap.asDriver(),
wechatButtonTrigger: otherLoginView.weChatButton.rx.tap.asDriver(),
appleButtonTrigger: otherLoginView.appleButton.rx.tap.asDriver(),
agreementBoxChecked: agreementBoxSelected,
notiWecahtResp: NotificationCenter.default.rx.notification(.notiWecahtResp))
let output = viewModel.transform(input: input)
_ = phoneView.phoneTextFiele.rx.textInput <-> viewModel.phone
loginButton.rx.tap.subscribe { _ in
let code = PhoneCodeController.init(viewModel: self.viewModel, navigator: self.navigator)
self.navigationController?.pushViewController(code, animated: true)
// let phoneCodeViewModel = PhoneCodeViewModel.init(phone: "+86 18551843868", provider: viewModel.provider)
// let code = PhoneCodeController.init(viewModel: phoneCodeViewModel, navigator: self.navigator)
//
// self.navigationController?.pushViewController(code, animated: true)
let bindPhoneViewModel = BindPhoneViewModel.init(provider: viewModel.provider)
let phone = BindPhoneViewController.init(viewModel: bindPhoneViewModel, navigator: self.navigator)
self.navigationController?.pushViewController(phone, animated: true)
}.disposed(by: rx.disposeBag)
@ -115,14 +134,16 @@ class LoginViewController: ViewController {
super.viewDidLayoutSubviews()
backgroundImageView.snp.makeConstraints { make in
make.bottom.equalTo(view)
make.bottom.equalTo(view).offset(-BaseDimensions.bottomHeight)
make.left.equalTo(view)
make.right.equalTo(view)
make.height.equalTo(420)
make.height.equalTo(463)
make.width.equalTo(463)
}
titleLabel.snp.makeConstraints { make in
make.top.equalTo(view).offset(BaseDimensions.topHeight + 19)
make.top.equalTo(view).offset(19)
make.left.equalTo(view).offset(24)
}

@ -8,18 +8,66 @@
import Foundation
import RxSwift
import RxCocoa
import RxViewController
class LoginViewModel: ViewModel, ViewModelType {
struct Input {
let codeButtonTrigger: Driver<Void>
let wechatButtonTrigger: Driver<Void>
let appleButtonTrigger: Driver<Void>
let agreementBoxChecked: Driver<Bool>
let notiWecahtResp: Observable<Notification>
}
struct Output {
}
let phone = BehaviorRelay(value: "")
func transform(input: Input) -> Output {
input.codeButtonTrigger.drive { _ in
}.disposed(by: rx.disposeBag)
input.wechatButtonTrigger.drive { _ in
guard WXApi.isWXAppInstalled() else {
return
}
let req = SendAuthReq.init()
req.scope = "snsapi_userinfo"
req.state = ""
WXApi.send(req) { isFinish in
}
}.disposed(by: rx.disposeBag)
input.appleButtonTrigger.drive { _ in
}.disposed(by: rx.disposeBag)
input.agreementBoxChecked.drive { isSelected in
print("agreementBoxChecked: \(isSelected)")
}.disposed(by: rx.disposeBag)
phone.subscribe { phone in
print("phone: \(phone)")
}.disposed(by: rx.disposeBag)
return Output.init()
}

@ -6,6 +6,8 @@
//
import UIKit
import RxSwift
import RxCocoa
import CRBoxInputView
class PhoneCodeController: ViewController {
@ -55,50 +57,24 @@ class PhoneCodeController: ViewController {
return codeButton
}()
var isLogining: Bool = false
//
var remainingSeconds: Int = 0 {
willSet {
codeButton.setTitle("\(newValue)秒后重新获取", for: .normal)
if newValue <= 0 {
codeButton.setTitle("重新获取验证码", for: .normal)
isCounting = false
}
}
}
var countdownTimer: Timer?
var isCounting = false {
willSet {
if newValue {
countdownTimer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(updateTime), userInfo: nil, repeats: true)
remainingSeconds = 60
codeButton.setTitleColor(UIColor.lightGray, for: .normal)
} else {
countdownTimer?.invalidate()
countdownTimer = nil
// codeButton.setTitleColor(themeTextColor, for: .normal)
}
codeButton.isEnabled = !newValue
}
}
let boxInputText = PublishSubject<(String?, Bool)>.init()
override func viewDidLoad() {
super.viewDidLoad()
boxInputView.textDidChangeblock = { (text, isFinish) in
if isFinish {
if self.isLogining == false {
// self.loginAction()
}
let agress = AgreementViewController.init()
self.present(agress, animated: true)
}
self.boxInputText.onNext((text, isFinish))
}
tipsLabel.text = "验证码已发送至 +86"
}
@ -115,8 +91,35 @@ class PhoneCodeController: ViewController {
override func bindViewModel() {
super.bindViewModel()
guard let viewModel = viewModel as? PhoneCodeViewModel else { return }
let input = PhoneCodeViewModel.Input.init(codeButtonTrigger: codeButton.rx.tap.asObservable(),
boxInputText: boxInputText)
let output = viewModel.transform(input: input)
output.countdownText
.bind(to: codeButton.rx.title(for: .normal))
.disposed(by: rx.disposeBag)
output.isButtonEnabled
.drive(onNext: { isEnabled in
self.codeButton.isEnabled = isEnabled
self.codeButton.setTitleColor(isEnabled ? UIColor.primaryText() : UIColor.tertiaryText(), for: .normal)
})
.disposed(by: rx.disposeBag)
output.tipsText.drive(self.tipsLabel.rx.text).disposed(by: rx.disposeBag)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
titleLabel.snp.makeConstraints { make in
make.top.equalTo(view).offset(BaseDimensions.topHeight + 19)
make.top.equalTo(view).offset(19)
make.left.equalTo(view).offset(24)
}
@ -138,11 +141,5 @@ class PhoneCodeController: ViewController {
make.top.equalTo(boxInputView.snp.bottom).offset(24)
}
}
@objc func updateTime(timer: Timer) {
remainingSeconds -= 1
}
}

@ -10,18 +10,74 @@ import RxSwift
import RxCocoa
class PhoneCodeViewModel: ViewModel, ViewModelType {
struct Input {
let codeButtonTrigger: Observable<Void>
let boxInputText: PublishSubject<(String?, Bool)>
}
struct Output {
let countdownText: Observable<String>
let isButtonEnabled: Driver<Bool>
let tipsText: Driver<String>
}
private var remainingSeconds = 59
private var tipsText = "验证码已发送至 "
init(phone: String, provider: IndieMusicAPI) {
super.init(provider: provider)
self.tipsText = "验证码已发送至 \(phone)"
}
func transform(input: Input) -> Output {
let startImmediately = Observable.just(Void())
let startCountdown = Observable.merge(startImmediately, input.codeButtonTrigger)
.do(onNext: { [weak self] _ in
self?.remainingSeconds = 59
})
let timer = startCountdown
.flatMapLatest { _ in
Observable<Int>.interval(.seconds(1), scheduler: MainScheduler.instance)
.startWith(0)
.skip(1)
.take(self.remainingSeconds + 1)
}
.share()
let countdownText = timer
.map { [weak self] in
guard let self = self else { return "重新获取" }
let seconds = self.remainingSeconds - $0
print("倒计时\(seconds) \(self.remainingSeconds) ")
return seconds <= 0 ? "重新获取" : "\(seconds)s"
}
let isButtonEnabled = timer
.map { $0 >= self.remainingSeconds }.asDriver(onErrorJustReturn: false)
let tipsText = Driver<String>.just(self.tipsText)
input.boxInputText.subscribe(onNext: { (text, isFinish) in
print("text: \(text) isFinish: \(isFinish) ")
}).disposed(by: rx.disposeBag)
return Output.init()
return Output(countdownText: countdownText,
isButtonEnabled: isButtonEnabled,
tipsText: tipsText)
}
}

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22130"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
@ -11,10 +14,33 @@
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="launch_slogn" translatesAutoresizingMaskIntoConstraints="NO" id="b5a-Lv-tbj">
<rect key="frame" x="151.66666666666666" y="279" width="90" height="90"/>
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="launch_icon" translatesAutoresizingMaskIntoConstraints="NO" id="Vhs-1v-WXg">
<rect key="frame" x="135.66666666666666" y="384" width="121.99999999999997" height="18"/>
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="login_bakcground" translatesAutoresizingMaskIntoConstraints="NO" id="Adv-Ys-NiE">
<rect key="frame" x="0.0" y="477" width="393" height="375"/>
<constraints>
<constraint firstAttribute="height" constant="375" id="wva-Ot-qwI"/>
</constraints>
</imageView>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="b5a-Lv-tbj" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="11N-3o-WeP"/>
<constraint firstItem="Adv-Ys-NiE" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="54V-4a-dFa"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="Adv-Ys-NiE" secondAttribute="trailing" id="I9P-XA-sxf"/>
<constraint firstAttribute="bottom" secondItem="Adv-Ys-NiE" secondAttribute="bottom" id="Oow-0p-dSW"/>
<constraint firstItem="Vhs-1v-WXg" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="P8g-BJ-XbI"/>
<constraint firstItem="Vhs-1v-WXg" firstAttribute="top" secondItem="b5a-Lv-tbj" secondAttribute="bottom" constant="15" id="oU6-ns-oci"/>
<constraint firstItem="b5a-Lv-tbj" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" constant="-102" id="pmX-4G-0eI"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
@ -22,4 +48,12 @@
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<image name="launch_icon" width="122" height="18"/>
<image name="launch_slogn" width="90" height="90"/>
<image name="login_bakcground" width="375" height="352"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>

@ -10,6 +10,9 @@ import RxSwift
import RxCocoa
protocol IndieMusicAPI {
func wechatAccessToken(appid: String, secret: String, code: String, grantType: String) -> Single<EmptyModel>
func login(dic: [String: Any]) -> Single<EmptyModel>

@ -16,12 +16,16 @@ protocol ProductAPIType {
enum APIConfig {
case wechatAccessToken([String: Any])
case login([String: Any])
}
extension APIConfig: TargetType {
var path: String {
switch self {
case .wechatAccessToken:
return "sns/oauth2/access_token"
case .login:
return ""
}
@ -29,6 +33,8 @@ extension APIConfig: TargetType {
var method: Moya.Method {
switch self {
case .wechatAccessToken:
return .get
case .login:
return .post
}
@ -36,6 +42,8 @@ extension APIConfig: TargetType {
var parameterEncoding: ParameterEncoding {
switch self {
case .wechatAccessToken:
return URLEncoding.default
case .login:
return JSONEncoding.default
}
@ -44,13 +52,28 @@ extension APIConfig: TargetType {
//
var task: Task {
var parameters: [String: Any] = [:]
return .requestParameters(parameters: parameters, encoding: parameterEncoding)
switch self {
case .wechatAccessToken:
return .requestPlain
case .login(let dic):
parameters = dic
return .requestParameters(parameters: parameters, encoding: parameterEncoding)
}
}
var baseURL: URL {
switch self {
case .wechatAccessToken:
return URL(string: Configs.App.wechatURL)!
case .login:
return URL(string: Configs.App.environmentType.baseUrl)!
}
}
var headers : [String : String]? {

@ -29,8 +29,6 @@ enum ApiError: Error {
}
class RestApi: IndieMusicAPI {
let indieMusicProvider: IndieMusicNetworking
@ -65,9 +63,22 @@ extension RestApi {
extension RestApi {
func wechatAccessToken(appid: String, secret: String, code: String, grantType: String) -> RxSwift.Single<EmptyModel> {
let dic = ["appid": appid,
"secret": secret,
"code": code,
"grant_type": grantType
]
return requestObject(.wechatAccessToken(dic), with: "data", type: EmptyModel.self)
}
func login(dic: [String: Any]) -> Single<EmptyModel> {
return requestObject(.login(dic), with: "data", type: EmptyModel.self)
}
}

@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "launch_icon.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 11 KiB

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "launch_slogn.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

@ -0,0 +1,4 @@
<svg width="90" height="90" viewBox="0 0 90 90" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="90" height="90" rx="18" fill="white" fill-opacity="0.95" style="fill:white;fill-opacity:0.95;"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M44.4774 28.4919C44.4774 24.3327 46.8916 20.8375 50.6842 19.8333C51.3977 19.6443 52.1442 19.5439 52.9153 19.5439C56.0936 19.5439 58.8642 21.2571 60.4316 23.8032C60.4784 23.8789 62.6295 27.088 62.6295 31.8753C62.6295 33.2255 62.461 34.5368 62.1469 35.7867C62.1346 35.8469 62.1286 35.9085 62.1286 35.973C62.1286 36.4856 62.5383 36.9012 63.0438 36.9012C63.3246 36.9012 63.5751 36.7736 63.7421 36.5702C63.7648 36.5458 63.7846 36.5196 63.8029 36.4918C65.4755 34.272 66.4682 31.4998 66.4682 28.4919C66.4682 21.2062 60.6442 15.3 53.4601 15.3C53.3979 15.3 53.3357 15.3 53.2735 15.3029C51.6479 15.3247 50.0934 15.6502 48.6639 16.225C43.8527 18.1604 40.4523 22.9207 40.4523 28.4919C40.4523 34.5973 45.1957 40.9327 48.5318 44.2838C48.7049 44.4563 48.878 44.6272 49.0554 44.7981C49.8569 45.5708 50.6825 46.2911 51.5264 46.9592C51.7891 47.167 52.0548 47.3701 52.3204 47.5688C52.6861 47.8458 52.9214 48.2876 52.9214 48.7848C52.9214 49.7324 52.089 50.3838 51.1851 50.2841C47.7486 49.7962 44.5292 48.6201 41.6667 46.8961C41.187 46.6067 40.7165 46.3035 40.258 45.9818H40.2565C37.321 43.9422 34.8211 41.3023 32.9344 38.2358C30.5393 34.3444 29.1262 29.768 29.0472 24.8607C29.0457 24.7175 29.0443 24.5727 29.0443 24.4282C29.0443 22.7595 29.1991 21.1263 29.4936 19.5439C26.9814 22.6503 25.16 26.3539 24.2722 30.4129C23.8714 32.2418 23.6604 34.1444 23.6604 36.0947C23.6604 40.7635 24.8686 45.146 26.9845 48.9373C24.1811 46.9345 21.7889 44.3779 19.9646 41.4223C19.2936 40.3371 18.6986 39.1994 18.1902 38.0143C18.1006 38.8948 18.055 39.7891 18.055 40.6941C18.055 44.1038 18.7001 47.3611 19.8718 50.3472C20.9693 53.1411 22.5282 55.6965 24.4528 57.9192C23.6407 57.8207 22.818 57.7607 21.9849 57.7407C21.7768 57.7361 21.5688 57.7329 21.361 57.7329C19.2374 57.7329 17.1732 57.993 15.2 58.4856C19.9053 59.7495 24.0808 62.3325 27.323 65.819C31.9586 70.7496 38.7553 74.7 47.8502 74.7C56.3401 74.7 71 69.5026 71 57.9915C71 53.6675 68.8552 48.9793 62.6488 46.1506C52.3375 41.451 44.4774 34.8646 44.4774 28.4919Z" fill="black" fill-opacity="0.95" style="fill:black;fill-opacity:0.95;"/>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 308 KiB

After

Width:  |  Height:  |  Size: 8.1 MiB

@ -2,6 +2,13 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
@ -25,5 +32,11 @@
<array>
<string>audio</string>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>weixin</string>
<string>weixinULAPI</string>
<string>weixinURLParamsAPI</string>
</array>
</dict>
</plist>

@ -0,0 +1,6 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#import "WXApi.h"
#import "WXApiObject.h"

@ -15,6 +15,10 @@ target 'IndieMusic' do
pod 'KeychainAccess'
pod 'FSPagerView'
pod 'CRBoxInputView', '1.2.1'
pod 'ETNavBarTransparent'
pod 'WechatOpenSDK-XCFramework'
pod 'SwiftDate'
pod 'XHLaunchAd'
pod 'NSObject+Rx'

Loading…
Cancel
Save