Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample kanban board app implementation #39

Merged
merged 16 commits into from
Nov 9, 2022
Merged

Sample kanban board app implementation #39

merged 16 commits into from
Nov 9, 2022

Conversation

7hong13
Copy link
Contributor

@7hong13 7hong13 commented Nov 1, 2022

What this PR does / why we need it?

Sample Kanban board implementation.
result:

2022-11-08.2.45.20.mov

Any background context you want to provide?

I changed TimeTicket as public and used it as a key for JsonArray, but it is just temporary try to sync with other SDKs.
we should change the structure later to improve its usability.

What are the relevant tickets?

Fixes #

Checklist

  • Added relevant tests or not required
  • Didn't break anything

@7hong13 7hong13 self-assigned this Nov 1, 2022
@codecov
Copy link

codecov bot commented Nov 2, 2022

Codecov Report

Merging #39 (48b9db4) into main (0ba49b3) will decrease coverage by 0.35%.
The diff coverage is 35.29%.

@@            Coverage Diff             @@
##             main      #39      +/-   ##
==========================================
- Coverage   78.94%   78.59%   -0.36%     
==========================================
  Files          44       44              
  Lines        1724     1733       +9     
  Branches      250      250              
==========================================
+ Hits         1361     1362       +1     
- Misses        224      232       +8     
  Partials      139      139              
Impacted Files Coverage Δ
.../main/kotlin/dev/yorkie/document/json/JsonArray.kt 60.93% <0.00%> (-9.98%) ⬇️
...main/kotlin/dev/yorkie/document/json/JsonObject.kt 90.62% <ø> (ø)
...main/kotlin/dev/yorkie/document/time/TimeTicket.kt 81.25% <85.71%> (ø)
yorkie/src/main/kotlin/dev/yorkie/core/Client.kt 84.81% <0.00%> (+0.42%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.


class KanbanActivity : AppCompatActivity() {
private lateinit var binding: ActivityKanbanBinding
private val viewModel: KanbanViewModel by lazy {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use viewModels extension here :)

private val itemsListener: (ViewGroup, Pair<String, List<String>>) -> Unit,
private val itemAddListener: (ViewGroup, String, String) -> Unit,
private val cardDeleteListener: (String) -> Unit,
) : RecyclerView.Adapter<KanbanCardAdapter.KanbanCardViewHolder>() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we are not going to use Compose... we should at least use ListAdapter.

@@ -196,6 +196,13 @@ public class Document private constructor(
return root.toJson()
}

public fun getRoot(): JsonObject {
ensureClone()
val clone = requireNotNull(clone)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made ensureClone to return the clone instance, so we can change to val clone = ensureClone()

ensureClone()
val clone = requireNotNull(clone)
val context = ChangeContext(changeID.next(), clone, null)
return JsonObject(context, clone.rootObject)
Copy link
Contributor

@skhugh skhugh Nov 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels kinda weird to me :(
we are returning a mutable JsonObject but changes will have no effect...
maybe we should consider creating a immutable read-only Json elements for this use-case. 🤔

}
} catch (e: Exception) {
// TODO(7hong): handle ConcurrentModificationException
Copy link
Contributor

@skhugh skhugh Nov 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifying a collection should not happen inside a loop.
we should use iterator.. or loop a snapshot of a collection.

Copy link
Contributor

@skhugh skhugh Nov 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed this issue on #42

import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

data class KanbanColumn(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we need new interface to use these (non-crdt) custom classes easily in the document.
since Android SDK doesn't reveal id of the JsonObject to public, I'm not sure how to get particular JsonObject in the document right now... (ex. when adding a new card to the particular column)

@7hong13 7hong13 marked this pull request as ready for review November 8, 2022 05:51
data class KanbanColumn(
val title: String,
val cards: List<Card>,
var id: TimeTicket = TimeTicket.InitialTimeTicket,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using mutable properties should be avoided when we are using Compose.

@hackerwins hackerwins merged commit b70cda5 into main Nov 9, 2022
@hackerwins hackerwins deleted the examples branch November 9, 2022 01:23
Copy link
Member

@hackerwins hackerwins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants