Skip to content

Commit

Permalink
feat(openfeedback-m3): support ios target.
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardPaligot committed Nov 26, 2023
1 parent ca220b6 commit bc885ec
Show file tree
Hide file tree
Showing 19 changed files with 319 additions and 200 deletions.
31 changes: 29 additions & 2 deletions openfeedback-m3/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

plugins {
id("io.openfeedback.plugins.lib.multiplatform")
id("io.openfeedback.plugins.publishing")
kotlin("native.cocoapods")
alias(libs.plugins.jetbrains.compose)
}

Expand All @@ -14,8 +14,32 @@ openfeedback {
}

kotlin {
applyDefaultHierarchyTemplate()

androidTarget()

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach { iosTarget ->
iosTarget.binaries.framework {
baseName = "OpenFeedbackM3Kit"
isStatic = true
}
}

cocoapods {
version = "1.0"
ios.deploymentTarget = "14.1"
pod("FirebaseAuth") {
linkOnly = true
}
pod("FirebaseFirestore") {
linkOnly = true
}
}

sourceSets {
val commonMain by getting {
dependencies {
Expand All @@ -27,9 +51,12 @@ kotlin {

implementation(compose.material3)
implementation(compose.ui)
}
}
val androidMain by getting {
dependencies {
implementation(compose.uiTooling)
}
}
val androidMain by getting
}
}
51 changes: 51 additions & 0 deletions openfeedback-m3/openfeedback_m3.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Pod::Spec.new do |spec|
spec.name = 'openfeedback_m3'
spec.version = '1.0'
spec.homepage = ''
spec.source = { :http=> ''}
spec.authors = ''
spec.license = ''
spec.summary = ''
spec.vendored_frameworks = 'build/cocoapods/framework/openfeedback_m3.framework'
spec.libraries = 'c++'
spec.ios.deployment_target = '14.1'
spec.dependency 'FirebaseAuth'
spec.dependency 'FirebaseFirestore'

if !Dir.exist?('build/cocoapods/framework/openfeedback_m3.framework') || Dir.empty?('build/cocoapods/framework/openfeedback_m3.framework')
raise "
Kotlin framework 'openfeedback_m3' doesn't exist yet, so a proper Xcode project can't be generated.
'pod install' should be executed after running ':generateDummyFramework' Gradle task:
./gradlew :openfeedback-m3:generateDummyFramework
Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)"
end

spec.pod_target_xcconfig = {
'KOTLIN_PROJECT_PATH' => ':openfeedback-m3',
'PRODUCT_MODULE_NAME' => 'openfeedback_m3',
}

spec.script_phases = [
{
:name => 'Build openfeedback_m3',
:execution_position => :before_compile,
:shell_path => '/bin/sh',
:script => <<-SCRIPT
if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then
echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\""
exit 0
fi
set -ev
REPO_ROOT="$PODS_TARGET_SRCROOT"
"$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \
-Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \
-Pkotlin.native.cocoapods.archs="$ARCHS" \
-Pkotlin.native.cocoapods.configuration="$CONFIGURATION"
SCRIPT
}
]
spec.resources = ['build/compose/ios/openfeedback_m3/compose-resources']
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.openfeedback.m3

import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview

@Preview
@Composable
private fun CommentInputPreview() {
MaterialTheme {
CommentInput(
value = "My comment",
onValueChange = {},
onSubmit = {}
)
}
}
Original file line number Diff line number Diff line change
@@ -1,45 +1,14 @@
package io.openfeedback.m3

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import dev.icerock.moko.resources.compose.stringResource
import io.openfeedback.MR
import io.openfeedback.viewmodels.models.UIComment
import io.openfeedback.viewmodels.models.UIDot

@Composable
internal fun CommentItems(
comments: List<UIComment>,
modifier: Modifier = Modifier,
verticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(8.dp),
commentInput: @Composable ColumnScope.() -> Unit,
comment: @Composable ColumnScope.(UIComment) -> Unit
) {
Column(
modifier = modifier,
verticalArrangement = verticalArrangement
) {
Text(
text = stringResource(MR.strings.openfeedback_comments_title),
style = MaterialTheme.typography.titleMedium
)
commentInput()
comments.forEach { uiComment ->
comment(uiComment)
}
}
}

@Preview
@Composable
private fun VoteItemsPreview() {
private fun CommentItemsPreview() {
MaterialTheme {
CommentItems(
comments = listOf(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.openfeedback.m3

import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import io.openfeedback.viewmodels.models.UIComment
import io.openfeedback.viewmodels.models.UIDot

@Preview
@Composable
private fun CommentPreview() {
MaterialTheme {
Comment(
comment = UIComment(
id = "",
voteItemId = "",
message = "Super talk and great speakers!",
createdAt = "08 August 2023",
upVotes = 8,
dots = listOf(UIDot(x = .5f, y = .5f, color = "FF00CC")),
votedByUser = true
),
onClick = {}
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.openfeedback.m3

import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview

@Preview
@Composable
internal fun LoadingPreview() {
Loading()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package io.openfeedback.m3

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.openfeedback.viewmodels.models.UIComment
import io.openfeedback.viewmodels.models.UIDot
import io.openfeedback.viewmodels.models.UISessionFeedback
import io.openfeedback.viewmodels.models.UIVoteItem

@OptIn(ExperimentalMaterial3Api::class)
@Preview
@Composable
private fun OpenFeedbackLayoutPreview() {
MaterialTheme {
OpenFeedbackLayout(
sessionFeedback = UISessionFeedback(
commentValue = "",
commentVoteItemId = "",
comments = listOf(
UIComment(
id = "",
voteItemId = "",
message = "Nice comment",
createdAt = "08 August 2023",
upVotes = 8,
dots = listOf(UIDot(x = .5f, y = .5f, color = "FF00CC")),
votedByUser = true
),
UIComment(
id = "",
voteItemId = "",
message = "Another one",
createdAt = "08 August 2023",
upVotes = 0,
dots = listOf(UIDot(x = .5f, y = .5f, color = "FF00CC")),
votedByUser = true
)
),
voteItem = listOf(
UIVoteItem(
id = "",
text = "Fun",
dots = listOf(UIDot(x = .5f, y = .5f, color = "FF00CC")),
votedByUser = true
),
UIVoteItem(
id = "",
text = "Fun",
dots = listOf(UIDot(x = .5f, y = .5f, color = "FF00CC")),
votedByUser = true
)
)
),
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
commentInput = {
CommentInput(value = "", onValueChange = {}, onSubmit = {})
},
comment = { Comment(comment = it, onClick = {}) }
) {
VoteCard(
voteModel = it,
onClick = {},
modifier = Modifier
.height(100.dp)
.fillMaxWidth()
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.openfeedback.m3

import androidx.compose.foundation.layout.size
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.openfeedback.viewmodels.models.UIDot
import io.openfeedback.viewmodels.models.UIVoteItem

@OptIn(ExperimentalMaterial3Api::class)
@Preview
@Composable
private fun VoteCardPreview() {
MaterialTheme {
VoteCard(
voteModel = UIVoteItem(
id = "",
text = "Fun",
dots = listOf(UIDot(x = .5f, y = .5f, color = "FF00CC")),
votedByUser = true
),
onClick = {},
modifier = Modifier.size(height = 100.dp, width = 200.dp)
)
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package io.openfeedback.m3

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.material3.ExperimentalMaterial3Api
Expand All @@ -15,37 +12,6 @@ import androidx.compose.ui.unit.dp
import io.openfeedback.viewmodels.models.UIDot
import io.openfeedback.viewmodels.models.UIVoteItem

@ExperimentalMaterial3Api
@Composable
internal fun VoteItems(
voteItems: List<UIVoteItem>,
modifier: Modifier = Modifier,
columnCount: Int = 2,
horizontalArrangement: Arrangement.Horizontal = Arrangement.spacedBy(8.dp),
verticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(8.dp),
content: @Composable ColumnScope.(UIVoteItem) -> Unit
) {
Row(
modifier = modifier,
horizontalArrangement = horizontalArrangement
) {
0.until(columnCount).forEach { column ->
Column(
verticalArrangement = verticalArrangement,
modifier = Modifier.weight(1f)
) {
voteItems
.filterIndexed { index, _ ->
index % columnCount == column
}
.forEach { voteItem ->
content(voteItem)
}
}
}
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Preview
@Composable
Expand Down
Loading

0 comments on commit bc885ec

Please sign in to comment.