mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
Integrate page icon picker (#280)
This commit is contained in:
parent
b4a3401671
commit
ab1b602176
67 changed files with 1206 additions and 230 deletions
|
@ -1,24 +0,0 @@
|
|||
package com.agileburo.anytype.sample
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.agileburo.anytype.sample", appContext.packageName)
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package com.agileburo.anytype.sample
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.agileburo.anytype.library_page_icon_picker_widget.model.PageIconPickerView
|
||||
import com.agileburo.anytype.library_page_icon_picker_widget.ui.PageIconPickerAdapter
|
||||
import com.agileburo.anytype.library_page_icon_picker_widget.ui.PageIconPickerViewHolder
|
||||
import com.vdurmont.emoji.EmojiManager
|
||||
import kotlinx.android.synthetic.main.sample_page_icon_picker_activity.*
|
||||
|
||||
class PageIconPickerSampleActivity : AppCompatActivity(R.layout.sample_page_icon_picker_activity) {
|
||||
|
||||
private val emojis by lazy {
|
||||
EmojiManager
|
||||
.getAll()
|
||||
.map { emoji ->
|
||||
PageIconPickerView.Emoji(
|
||||
unicode = emoji.unicode
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private val pageIconPickerAdapter = PageIconPickerAdapter(
|
||||
views = listOf(
|
||||
PageIconPickerView.Action.UploadPhoto,
|
||||
PageIconPickerView.Action.PickRandomly,
|
||||
PageIconPickerView.Action.ChooseEmoji,
|
||||
PageIconPickerView.EmojiFilter
|
||||
) + emojis,
|
||||
onUploadPhotoClicked = {},
|
||||
onSetRandomEmojiClicked = {},
|
||||
onFilterQueryChanged = {}
|
||||
)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
recyler.apply {
|
||||
setItemViewCacheSize(100)
|
||||
setHasFixedSize(true)
|
||||
layoutManager = GridLayoutManager(context, PAGE_ICON_PICKER_DEFAULT_SPAN_COUNT).apply {
|
||||
spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
||||
override fun getSpanSize(position: Int) =
|
||||
when (val type = pageIconPickerAdapter.getItemViewType(position)) {
|
||||
PageIconPickerViewHolder.HOLDER_UPLOAD_PHOTO -> PAGE_ICON_PICKER_DEFAULT_SPAN_COUNT
|
||||
PageIconPickerViewHolder.HOLDER_CHOOSE_EMOJI -> PAGE_ICON_PICKER_DEFAULT_SPAN_COUNT
|
||||
PageIconPickerViewHolder.HOLDER_PICK_RANDOM_EMOJI -> PAGE_ICON_PICKER_DEFAULT_SPAN_COUNT
|
||||
PageIconPickerViewHolder.HOLDER_EMOJI_CATEGORY_HEADER -> PAGE_ICON_PICKER_DEFAULT_SPAN_COUNT
|
||||
PageIconPickerViewHolder.HOLDER_EMOJI_FILTER -> PAGE_ICON_PICKER_DEFAULT_SPAN_COUNT
|
||||
PageIconPickerViewHolder.HOLDER_EMOJI_ITEM -> 1
|
||||
else -> throw IllegalStateException("Unexpected view type: $type")
|
||||
}
|
||||
}
|
||||
}
|
||||
adapter = pageIconPickerAdapter.apply {
|
||||
setHasStableIds(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val PAGE_ICON_PICKER_DEFAULT_SPAN_COUNT = 8
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#DFDDD0" />
|
||||
<corners android:radius="6dp" />
|
||||
</shape>
|
|
@ -1,62 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#EEAFAF">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/sheet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/rectangle_debug_background"
|
||||
android:orientation="vertical"
|
||||
app:layout_behavior="@string/bottom_sheet_behavior">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginBottom="12dp">
|
||||
|
||||
<View
|
||||
android:id="@+id/dragger"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="4dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="6dp"
|
||||
android:background="@drawable/page_icon_picker_dragger_background" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="30dp"
|
||||
android:fontFamily="@font/graphik_semibold"
|
||||
android:text="Page icon"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="17sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="30dp"
|
||||
android:text="Remove"
|
||||
android:textColor="#ACA996"
|
||||
android:textSize="17sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyler"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:minHeight="100dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -1,17 +0,0 @@
|
|||
package com.agileburo.anytype.sample
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue