Skip to content

Commit

Permalink
[composeApp] calculate the coypright year dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
Luki120 committed Nov 28, 2024
1 parent 2afa1be commit 4ca1aa3
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package components

import java.time.LocalDateTime

actual val copyrightYear = "${LocalDateTime.now().year}"
3 changes: 3 additions & 0 deletions composeApp/src/commonMain/kotlin/components/CopyrightYear.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package components

expect val copyrightYear: String
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import components.application
import components.copyrightYear

@Composable
fun FooterView() {
Expand Down Expand Up @@ -47,7 +48,7 @@ private fun AttributedFooterText(string: String, subString: String) {
.pointerHoverIcon(PointerIcon.Hand)
)
}
Text("© 2024 Luki120", fontSize = 10.sp, color = Color.Gray)
Text("© $copyrightYear Luki120", fontSize = 10.sp, color = Color.Gray)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package components

import java.time.LocalDateTime

actual val copyrightYear = "${LocalDateTime.now().year}"
5 changes: 5 additions & 0 deletions composeApp/src/jsMain/kotlin/components/CopyrightYear.js.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package components

import kotlin.js.Date

actual val copyrightYear = "${Date().getFullYear()}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package components

actual val copyrightYear: String = js("new Date().getFullYear().toString()")

0 comments on commit 4ca1aa3

Please sign in to comment.