You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
2.0 KiB
52 lines
2.0 KiB
// |
|
// UserInfoViewModel.swift |
|
// HPlusFit |
|
// |
|
// Created by lemo. on 2019/9/7. |
|
// Copyright © 2019 lemo. All rights reserved. |
|
// |
|
|
|
import UIKit |
|
|
|
class UserInfoViewModel: ViewModel { |
|
|
|
var relay = BehaviorRelay(value: [SectionModel<String,TableViewCellModel>]()) |
|
|
|
override init() { |
|
super.init() |
|
loadFuncationList() |
|
} |
|
|
|
func loadFuncationList() { |
|
guard let userInfo = UserDefaultsManagerFrieBoltt.getUserInfo() else { return } |
|
// 功能列表 |
|
let funcationList: [UserInfoType] = [.head, .gender, .nickname, .height, .weight, .birthday] |
|
let gender = userInfo.gender ? MultiLanguageKey_FB.femaleFB.localized : MultiLanguageKey_FB.maleFB.localized |
|
let descriptions = ["", gender, userInfo.nickname, "\(userInfo.heightCM) cm", "\(userInfo.weightKG) kg", userInfo.birthday] |
|
var items: [TableViewCellModel] = [] |
|
funcationList.enumerated().forEach { (offset, type) in |
|
let isHiddenBottomLine = offset == funcationList.count - 1 |
|
let rightIcon = offset == 0 ? userInfo.getAvatarImg : nil |
|
let cellModel = TableViewCellModel(title: type.title, isSwitch: false, description: descriptions[offset], isArrows: true, isOn: false, image: nil, isBottomLine: !isHiddenBottomLine, righeImg: rightIcon, userInfoType: type) |
|
items.append(cellModel) |
|
} |
|
relay.accept([SectionModel(model: "", items: items)]) |
|
} |
|
|
|
} |
|
|
|
enum UserInfoType { |
|
case head, gender, nickname, height, weight, birthday |
|
|
|
var title: String { |
|
switch self { |
|
case .head: return MultiLanguageKey_FB.headFB.localized |
|
case .gender: return MultiLanguageKey_FB.genderFB.localized |
|
case .nickname: return MultiLanguageKey_FB.nicknameFB.localized |
|
case .height: return MultiLanguageKey_FB.heightFB.localized |
|
case .weight: return MultiLanguageKey_FB.weightFB.localized |
|
case .birthday: return MultiLanguageKey_FB.birthdayFB.localized |
|
} |
|
} |
|
} |
|
|
|
|