// // WifiViewController.swift // JSONCreator // // Created by Matt Bruce on 6/27/22. // Copyright © 2022 Verizon Wireless. All rights reserved. // import Foundation import MVMCoreUI class WifiViewController: UIViewController { // MFSTLandingViewController *vc=[MFSTLandingViewController new]; // vc.isForFiveG = true; // vc.ssIDs = ssIDs; // MFSTHistoryViewController *vc2=[MFSTHistoryViewController new]; // vc2.isForFiveG = true; // NSArray *tabInfo = @[ // @{ // @"presentationStyle" : @"push", // @"itemName" : kST_OVERVIEW, // @"title" : @"kST_OVERVIEW", // @"actionType" :@"openPage", // @"appContext" : @"mobileFirstSS", // @"pageType" : DHCRegistry.PageTypeDHCLanding // }, // @{ // @"presentationStyle" : @"push", // @"itemName" : kST_HISTORY, // @"title" : kST_HISTORY, // @"actionType" : @"openPage", // @"appContext" : @"mobileFirstSS", // @"pageType" : DHCRegistry.PageTypeDHCHistoryLanding // } // ]; // NSError *error = nil; // MFSubNavManagerController *viewControllerToLoad = [[MFSubNavManagerController alloc] initWithViewControllers:@[vc,vc2] loadObject:vc.loadObject tabsInfo:tabInfo selectedIndex: 0 shouldEnableSwipeGestures:YES error:&error]; // [[MVMCoreNavigationHandler sharedNavigationHandler] pushViewController:viewControllerToLoad animated:YES]; } class PrimaryWifiViewController: UIViewController { let inset = 16.0 private lazy var stackView: UIStackView = { let stack = UIStackView(frame: .zero) stack.translatesAutoresizingMaskIntoConstraints = false stack.spacing = 16 stack.axis = .vertical stack.alignment = .leading stack.distribution = .fillProportionally return stack }() override func viewDidLoad() { super.viewDidLoad() view.addSubview(stackView) NSLayoutConstraint.constraintPinSubview(stackView, pinTop: true, topConstant: inset, pinBottom: true, bottomConstant: inset, pinLeft: true, leftConstant: inset, pinRight: true, rightConstant: inset) let primary1 = wifiWidget(for: "Primary-1", title: "", description: "", password: "123456") let primary2 = wifiWidget(for: "Primary-2", title: "", description: "", password: "123456") let secondary1 = wifiWidget(for: "Secondary-1", title: "", description: "", password: "123456") let secondary2 = wifiWidget(for: "Secondary-2", title: "", description: "", password: "123456") stackView.addArrangedSubview(primary1) stackView.addArrangedSubview(primary2) stackView.addArrangedSubview(secondary1) stackView.addArrangedSubview(secondary2) } private func wifiWidget(for wifiId: String, title: String, description: String, password: String, enabled: Bool = true) -> WifiWidget { let extraParameters: JSONValueDictionary = ["wifiId": JSONValue.init(stringLiteral: wifiId)] let editAction = ActionOpenPageModel(pageType: "editWifi", presentationStyle: "push", extraParameters: extraParameters) let enabledAction = ActionOpenPageModel(pageType: "enabledWifi", presentationStyle: "push", extraParameters: extraParameters) let shareAction = ActionShareModel(sharedText: "ssid: \(wifiId) password: \(password)", sharedType: "Text") let wifiWidgetModel = WifiWidgetModel(wifiId: wifiId, title: title, description: description, password: password, enabled: enabled, editTitle: "Edit Wi-Fi details", shareTitle: "Share Wi-Fi", enabledAction: enabledAction, editAction: editAction, shareAction: shareAction, useHorizontalMargins: true, leftPadding: inset, rightPadding: inset, useVerticalMargins: true, topPadding: inset, bottomPadding: inset) let wifiWidget = WifiWidget(frame: .zero) wifiWidget.translatesAutoresizingMaskIntoConstraints = false wifiWidget.set(with: wifiWidgetModel, nil, nil) return wifiWidget } }