This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text.reduce(Text(""), { | |
$0 + Text($1) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Text("Text 1") | |
+ Text("Text 2") | |
+ Text("Text 3") | |
.font(.system(size: 12)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LoginDataStore: ObservableObject { | |
@Published var username: String = "" | |
@Published var storeCode: String = "" | |
@Published var storeBadge: String = "" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LoginViewModel: ObservableObject { | |
@Published var model: Login.ViewModel = Login.ViewModel() | |
func login(request: LoginView.Request) { | |
// Worker being called here to return the response (we'll skip this part) | |
let response = Login.Response(username: "Test Username", | |
storeCode: "Test STC-CODE", | |
storeBadge: "Test Badge-1") | |
model = Login.ViewModel(username: response.username, | |
storeCode: response.storeCode, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LoginView: View { | |
@ObservedObject var vm = LoginViewModel() | |
@State private var username = "" | |
@State private var password = "" | |
var body: some View { | |
VStack { | |
Button { | |
vm.login(request: Login.Request(username: username, password: password)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol LoginPresentationLogic { | |
func presentUserData(response: Login.Response) | |
} | |
class LoginPresenter { | |
var view: LoginDisplayLogic? | |
} | |
extension LoginPresenter: LoginPresentationLogic { | |
func presentUserData(response: Login.Response) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol LoginDisplayLogic { | |
func displayUserDetail(viewModel: Login.ViewModel) | |
} | |
struct LoginViewController: View { | |
var interactor: LoginBusinessLogic? | |
@ObservedObject var loginData = LoginDataStore() | |
@State private var username = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Login { | |
struct Request { | |
var username: String | |
var password: String | |
} | |
struct Response { | |
var username: String | |
var storeCode: String | |
var storeBadge: String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol LoginBusinessLogic { | |
func login(request: NewLogin.Request) | |
} | |
class LoginInteractor { | |
var presenter: LoginPresentationLogic? | |
} | |
extension LoginInteractor: LoginBusinessLogic { | |
func login(request: Login.Request) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension LoginViewController { | |
func configureView() -> some View { | |
var view = self | |
let interactor = NewLoginInteractor() | |
let presenter = NewLoginPresenter() | |
view.interactor = interactor | |
interactor.presenter = presenter | |
presenter.view = view | |
return view |
NewerOlder