add post preview
This commit is contained in:
features
common
common
posts
client
common
server
18
features/posts/common/build.gradle
Normal file
18
features/posts/common/build.gradle
Normal file
@ -0,0 +1,18 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
id "com.android.library"
|
||||
}
|
||||
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api project(":postssystem.features.common.common")
|
||||
api project(":postssystem.features.content.common")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
47
features/posts/common/src/commonMain/kotlin/dev/inmo/postssystem/features/posts/common/Post.kt
Normal file
47
features/posts/common/src/commonMain/kotlin/dev/inmo/postssystem/features/posts/common/Post.kt
Normal file
@ -0,0 +1,47 @@
|
||||
package dev.inmo.postssystem.features.posts.common
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import dev.inmo.postssystem.features.common.common.DateTimeSerializer
|
||||
import dev.inmo.postssystem.features.content.common.ContentId
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.jvm.JvmInline
|
||||
|
||||
/**
|
||||
* Identifier of [RegisteredPost] in system
|
||||
*/
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class PostId(val long: Long) {
|
||||
override fun toString(): String = long.toString()
|
||||
}
|
||||
typealias ContentIds = List<ContentId>
|
||||
|
||||
/**
|
||||
* Base interface for creating of new post
|
||||
*
|
||||
* @see NewPost
|
||||
* @see RegisteredPost
|
||||
*/
|
||||
@Serializable
|
||||
sealed class Post {
|
||||
abstract val content: ContentIds
|
||||
}
|
||||
|
||||
/**
|
||||
* This type of [Post] should be used in case you wish to register new post in system
|
||||
*/
|
||||
@Serializable
|
||||
data class NewPost(
|
||||
override val content: ContentIds
|
||||
) : Post()
|
||||
|
||||
/**
|
||||
* Registered [Post]
|
||||
*/
|
||||
@Serializable
|
||||
data class RegisteredPost(
|
||||
val id: PostId,
|
||||
override val content: ContentIds,
|
||||
@Serializable(DateTimeSerializer::class)
|
||||
val creationDate: DateTime
|
||||
) : Post()
|
1
features/posts/common/src/main/AndroidManifest.xml
Normal file
1
features/posts/common/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1 @@
|
||||
<manifest package="dev.inmo.postssystem.features.posts.common"/>
|
Reference in New Issue
Block a user