A
A
Andrey Bogdanov2020-05-27 14:55:09
Functional programming
Andrey Bogdanov, 2020-05-27 14:55:09

What type will the function have?

Hello! Can you please tell me how to put these two essentially identical closures into a separate function? What type will this function have?

import Combine
import SwiftUI

struct TransitionRow: View {
    @Binding var transition: Transition
    
    var body: some View {
        HStack {
            TextField("Symbol", text: $transition.currentSymbol)
                .onReceive(Just(transition.currentSymbol)) {
                    var newValue = ""
                    if let char = $0.last {
                        newValue = String(char)
                    }
                    if self.transition.currentSymbol != newValue {
                        self.transition.currentSymbol = newValue
                    }
            }
            Text("->")
            TextField("Symbol", text: self.$transition.writeSymbol)
                .onReceive(Just(transition.writeSymbol)) {
                    var newValue = ""
                    if let last = $0.last {
                        newValue = String(last)
                    }
                    if self.transition.writeSymbol != newValue {
                        self.transition.writeSymbol = newValue
                    }
            }
        }
        .textFieldStyle(RoundedBorderTextFieldStyle())
        .multilineTextAlignment(.center)
    }
}

Answer the question

In order to leave comments, you need to log in

5 answer(s)
M
mstrepetov, 2020-05-28
@mstrepetov

This is a structure, type "TransitionRow", the successor of "View" is not a function and not a class, it will return only its value.

D
dayineyd, 2014-04-19
@dayineyd

Personally, I would recommend Wordpress. Although you have to finish it here, but it’s not difficult, you just need to install a couple of plugins (I won’t tell you which ones, but I used to look for them myself, there are a lot of them), I can name an abundant number of free templates from the pluses, and the ease of creating your own, expandable functionality due to plugins .

R
Ruslan, 2014-04-19
@Izmena

Prestashop
change theme and okami
has responsive design

A
anapievna, 2014-04-23
@anapievna

And I would advise LiveStreet CMC. This is a free engine, built on the principle of the MVC model, it helps to easily change the appearance.

G
Goldring, 2014-05-22
@Goldring

I have been using "LiveStreet" for more than a year. The engine itself is multifunctional and constantly updated. I have created more than one site with it. Try it, I think everything will work out.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question