Stefan de Kraker
04/25/2023, 11:37 AMStefan de Kraker
04/25/2023, 11:48 AMNicklas Jensen
04/25/2023, 12:07 PMexpect
declarations in Kotlin. You can access the values of DimensionsObject
in Swift like this:
let foo = DimensionsObject.shared.radiusSmall
Stefan de Kraker
04/25/2023, 12:15 PMStefan de Kraker
04/25/2023, 12:16 PMNicklas Jensen
04/25/2023, 12:16 PM.shared
property to access the singleton instance of your object
. You can read more about this and other things about Interoperability with Swift/Objective-CStefan de Kraker
04/25/2023, 12:19 PMType 'DimensionsObject' has no member 'shared'
Nicklas Jensen
04/25/2023, 12:19 PMStefan de Kraker
04/25/2023, 12:19 PMimport shared
var body: some View {
NavigationView() {
ScrollView {
LazyVGrid(columns: columns) {
ForEach(filteredPokemon, id: \.self) {pokemon in
PokemonOverviewItemCard(pokemon: pokemon)
}
}
.padding(.horizontal, CGFloat(DimensionsObject.shared.radiusSmall))
.animation(.easeIn(duration: 0.3), value: filteredPokemon.count)
}
.refreshable { handleOnAppear() }
.searchable(text: $searchText)
.onAppear(perform: handleOnAppear)
.navigationTitle("All Pokémon")
}
.navigationViewStyle(.stack)
}
Nicklas Jensen
04/25/2023, 12:21 PMDimensionsObject().radiusSmall
This was how we used to access the properties of an object
in previous versions of Kotlin/NativeStefan de Kraker
04/25/2023, 12:21 PMNicklas Jensen
04/25/2023, 12:22 PM.shared
syntax 🤔Nicklas Jensen
04/25/2023, 12:23 PMStefan de Kraker
04/25/2023, 12:23 PMKumar
04/25/2023, 2:18 PMobject Constants {
val name = “iOS/Android”
}
we can access
Constants().name in iOS
Constants.name in android
if you build without errors.