feat: scaffold boards drawer layout and UI resources
This commit is contained in:
@@ -2,7 +2,11 @@ package space.hackenslacker.kanbn4droid.app
|
|||||||
|
|
||||||
import androidx.test.core.app.ActivityScenario
|
import androidx.test.core.app.ActivityScenario
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
|
import androidx.test.espresso.ViewAction
|
||||||
import androidx.test.espresso.action.ViewActions.click
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
|
import androidx.test.espresso.action.GeneralSwipeAction
|
||||||
|
import androidx.test.espresso.action.Press
|
||||||
|
import androidx.test.espresso.action.Swipe
|
||||||
import androidx.test.espresso.action.ViewActions.longClick
|
import androidx.test.espresso.action.ViewActions.longClick
|
||||||
import androidx.test.espresso.action.ViewActions.replaceText
|
import androidx.test.espresso.action.ViewActions.replaceText
|
||||||
import androidx.test.espresso.action.ViewActions.swipeDown
|
import androidx.test.espresso.action.ViewActions.swipeDown
|
||||||
@@ -16,6 +20,7 @@ import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
|||||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import kotlin.math.roundToInt
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@@ -117,6 +122,38 @@ class BoardsFlowTest {
|
|||||||
onView(withText("Alpha")).check(matches(isDisplayed()))
|
onView(withText("Alpha")).check(matches(isDisplayed()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun drawerOpensAndShowsWorkspaceSection() {
|
||||||
|
MainActivity.dependencies.apiClientFactory = {
|
||||||
|
FakeBoardsApiClient(
|
||||||
|
boards = mutableListOf(BoardSummary("1", "Alpha")),
|
||||||
|
templates = emptyList(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
ActivityScenario.launch(BoardsActivity::class.java)
|
||||||
|
|
||||||
|
onView(withId(android.R.id.content)).perform(swipeFromLeftEdge())
|
||||||
|
|
||||||
|
onView(withText("Workspaces")).check(matches(isDisplayed()))
|
||||||
|
onView(withText("Alpha")).check(matches(isDisplayed()))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun swipeFromLeftEdge(): ViewAction {
|
||||||
|
return GeneralSwipeAction(
|
||||||
|
Swipe.FAST,
|
||||||
|
{ view ->
|
||||||
|
val x = (view.width * 0.02f).roundToInt().toFloat()
|
||||||
|
floatArrayOf(x, view.height * 0.5f)
|
||||||
|
},
|
||||||
|
{ view ->
|
||||||
|
val x = (view.width * 0.8f).roundToInt().toFloat()
|
||||||
|
floatArrayOf(x, view.height * 0.5f)
|
||||||
|
},
|
||||||
|
Press.FINGER,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private class InMemorySessionStore(
|
private class InMemorySessionStore(
|
||||||
private var baseUrl: String? = null,
|
private var baseUrl: String? = null,
|
||||||
) : SessionStore {
|
) : SessionStore {
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/boardsDrawerLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
@@ -19,7 +24,8 @@
|
|||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
>
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/boardsRecyclerView"
|
android:id="@+id/boardsRecyclerView"
|
||||||
@@ -56,5 +62,12 @@
|
|||||||
android:layout_margin="16dp"
|
android:layout_margin="16dp"
|
||||||
android:contentDescription="@string/create_board"
|
android:contentDescription="@string/create_board"
|
||||||
app:srcCompat="@android:drawable/ic_input_add" />
|
app:srcCompat="@android:drawable/ic_input_add" />
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
<include
|
||||||
|
layout="@layout/view_boards_drawer"
|
||||||
|
android:layout_width="@dimen/boards_drawer_max_width"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="start" />
|
||||||
|
|
||||||
|
</androidx.drawerlayout.widget.DrawerLayout>
|
||||||
|
|||||||
20
app/src/main/res/layout/item_workspace_drawer.xml
Normal file
20
app/src/main/res/layout/item_workspace_drawer.xml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<com.google.android.material.card.MaterialCardView 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="wrap_content"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
app:cardCornerRadius="12dp"
|
||||||
|
app:strokeWidth="1dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/workspaceTitleText"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1" />
|
||||||
|
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
60
app/src/main/res/layout/view_boards_drawer.xml
Normal file
60
app/src/main/res/layout/view_boards_drawer.xml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/colorSurface"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingTop="24dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:paddingBottom="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/drawerUsernameText"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/drawer_profile_unavailable"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/drawerEmailText"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:text="@string/drawer_profile_unavailable"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/drawerSettingsButton"
|
||||||
|
style="?attr/borderlessButtonStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:text="@string/drawer_settings" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/drawerWorkspacesTitle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="@string/drawer_workspaces"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Overline" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/drawerWorkspacesRecyclerView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:paddingBottom="8dp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/drawerLogoutButton"
|
||||||
|
style="?attr/materialButtonOutlinedStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/drawer_logout" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
4
app/src/main/res/values/dimens.xml
Normal file
4
app/src/main/res/values/dimens.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<dimen name="boards_drawer_max_width">360dp</dimen>
|
||||||
|
</resources>
|
||||||
@@ -84,4 +84,11 @@
|
|||||||
<string name="add">Add</string>
|
<string name="add">Add</string>
|
||||||
<string name="card_detail_comment_required">Comment is required</string>
|
<string name="card_detail_comment_required">Comment is required</string>
|
||||||
<string name="card_detail_comment_added">Comment added</string>
|
<string name="card_detail_comment_added">Comment added</string>
|
||||||
|
<string name="drawer_settings">Settings</string>
|
||||||
|
<string name="drawer_workspaces">Workspaces</string>
|
||||||
|
<string name="drawer_logout">Log out</string>
|
||||||
|
<string name="drawer_retry">Retry</string>
|
||||||
|
<string name="drawer_profile_unavailable">Profile unavailable</string>
|
||||||
|
<string name="drawer_workspaces_unavailable">Workspaces unavailable</string>
|
||||||
|
<string name="drawer_loading">Loading...</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user