mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
add navigation component + 3 empty fragments
This commit is contained in:
parent
81b43e2b1b
commit
c5ae583d97
17 changed files with 206 additions and 50 deletions
|
@ -50,6 +50,7 @@ ext {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(':feature_login')
|
||||
implementation project(':core_utils')
|
||||
|
||||
def applicationDependencies = rootProject.ext.mainApplication
|
||||
|
@ -64,6 +65,8 @@ dependencies {
|
|||
//Application dependencies
|
||||
implementation applicationDependencies.kotlin
|
||||
|
||||
implementation applicationDependencies.navigation
|
||||
implementation applicationDependencies.navigationUi
|
||||
implementation "com.android.support:appcompat-v7:$android_compat_version"
|
||||
implementation "com.android.support:design:$android_compat_version"
|
||||
implementation "com.android.support:support-v4:$android_compat_version"
|
||||
|
|
|
@ -18,7 +18,7 @@ class AndroidApplication : Application() {
|
|||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
injectMembers()
|
||||
if(BuildConfig.DEBUG) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Timber.plant(Timber.DebugTree())
|
||||
}
|
||||
}
|
||||
|
|
17
app/src/main/java/com/agileburo/anytype/FragmentA.kt
Normal file
17
app/src/main/java/com/agileburo/anytype/FragmentA.kt
Normal file
|
@ -0,0 +1,17 @@
|
|||
package com.agileburo.anytype
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
||||
class FragmentA: Fragment() {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_a, container, false)
|
||||
}
|
||||
}
|
18
app/src/main/java/com/agileburo/anytype/FragmentB.kt
Normal file
18
app/src/main/java/com/agileburo/anytype/FragmentB.kt
Normal file
|
@ -0,0 +1,18 @@
|
|||
package com.agileburo.anytype
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
||||
class FragmentB: Fragment(){
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_b, container, false)
|
||||
}
|
||||
}
|
15
app/src/main/java/com/agileburo/anytype/FragmentC.kt
Normal file
15
app/src/main/java/com/agileburo/anytype/FragmentC.kt
Normal file
|
@ -0,0 +1,15 @@
|
|||
package com.agileburo.anytype
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
|
||||
class FragmentC: Fragment(){
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
) = inflater.inflate(R.layout.fragment_c, container, false)
|
||||
}
|
|
@ -3,8 +3,9 @@ package com.agileburo.anytype
|
|||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import androidx.navigation.Navigation
|
||||
import androidx.navigation.ui.NavigationUI
|
||||
import com.agileburo.anytype.di.app.MainScreenComponent
|
||||
import com.ebolo.krichtexteditor.fragments.kRichEditorFragment
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
@ -26,14 +27,12 @@ class MainActivity : AppCompatActivity() {
|
|||
mainScreenComponent.inject(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
btnART.setOnClickListener {
|
||||
val editorFragment = kRichEditorFragment{
|
||||
}
|
||||
supportFragmentManager.beginTransaction()
|
||||
.add(R.id.container, editorFragment)
|
||||
.commit()
|
||||
|
||||
}
|
||||
NavigationUI.setupWithNavController(
|
||||
bottomNavigationView,
|
||||
Navigation.findNavController(this, R.id.fragment)
|
||||
)
|
||||
|
||||
Timber.d("Get context:$context")
|
||||
}
|
||||
}
|
||||
|
|
9
app/src/main/res/drawable/ic_docs.xml
Normal file
9
app/src/main/res/drawable/ic_docs.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M19,3h-4.18C14.4,1.84 13.3,1 12,1c-1.3,0 -2.4,0.84 -2.82,2L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM12,3c0.55,0 1,0.45 1,1s-0.45,1 -1,1 -1,-0.45 -1,-1 0.45,-1 1,-1zM12,7c1.66,0 3,1.34 3,3s-1.34,3 -3,3 -3,-1.34 -3,-3 1.34,-3 3,-3zM18,19L6,19v-1.4c0,-2 4,-3.1 6,-3.1s6,1.1 6,3.1L18,19z"/>
|
||||
</vector>
|
9
app/src/main/res/drawable/ic_profile.xml
Normal file
9
app/src/main/res/drawable/ic_profile.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M9,11.75c-0.69,0 -1.25,0.56 -1.25,1.25s0.56,1.25 1.25,1.25 1.25,-0.56 1.25,-1.25 -0.56,-1.25 -1.25,-1.25zM15,11.75c-0.69,0 -1.25,0.56 -1.25,1.25s0.56,1.25 1.25,1.25 1.25,-0.56 1.25,-1.25 -0.56,-1.25 -1.25,-1.25zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8 0,-0.29 0.02,-0.58 0.05,-0.86 2.36,-1.05 4.23,-2.98 5.21,-5.37C11.07,8.33 14.05,10 17.42,10c0.78,0 1.53,-0.09 2.25,-0.26 0.21,0.71 0.33,1.47 0.33,2.26 0,4.41 -3.59,8 -8,8z"/>
|
||||
</vector>
|
9
app/src/main/res/drawable/ic_settings.xml
Normal file
9
app/src/main/res/drawable/ic_settings.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
|
||||
</vector>
|
|
@ -7,45 +7,26 @@
|
|||
android:id="@+id/container"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnART"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:text="KRichEditor"
|
||||
app:layout_constraintBottom_toTopOf="@+id/button2"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed"/>
|
||||
<android.support.design.widget.BottomNavigationView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/bottomNavigationView"
|
||||
app:menu="@menu/bottom_navigation"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/fragment"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="395dp"
|
||||
android:layout_height="659dp"
|
||||
app:defaultNavHost="true"
|
||||
app:layout_constraintBottom_toTopOf="@+id/bottomNavigationView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navGraph="@navigation/main_navigation" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:text="Button"
|
||||
app:layout_constraintBottom_toTopOf="@+id/button3"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/btnART"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:text="Button"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button2"/>
|
||||
</android.support.constraint.ConstraintLayout>
|
18
app/src/main/res/layout/fragment_a.xml
Normal file
18
app/src/main/res/layout/fragment_a.xml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="FragmentA"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</android.support.constraint.ConstraintLayout>
|
17
app/src/main/res/layout/fragment_b.xml
Normal file
17
app/src/main/res/layout/fragment_b.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="FragmentB"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</android.support.constraint.ConstraintLayout>
|
17
app/src/main/res/layout/fragment_c.xml
Normal file
17
app/src/main/res/layout/fragment_c.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="FragmentC"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</android.support.constraint.ConstraintLayout>
|
18
app/src/main/res/menu/bottom_navigation.xml
Normal file
18
app/src/main/res/menu/bottom_navigation.xml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@+id/fragmentA"
|
||||
android:icon="@drawable/ic_docs"
|
||||
android:title="Docs" />
|
||||
|
||||
<item
|
||||
android:id="@+id/fragmentB"
|
||||
android:icon="@drawable/ic_profile"
|
||||
android:title="Profile" />
|
||||
|
||||
<item
|
||||
android:id="@+id/fragmentC"
|
||||
android:icon="@drawable/ic_settings"
|
||||
android:title="Settings" />
|
||||
</menu>
|
27
app/src/main/res/navigation/main_navigation.xml
Normal file
27
app/src/main/res/navigation/main_navigation.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main_navigation"
|
||||
app:startDestination="@id/fragmentA">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/loginFragment2"
|
||||
android:name="com.agileburo.anytype.feature_login.ui.login.LoginFragment"
|
||||
android:label="LoginFragment" />
|
||||
<fragment
|
||||
android:id="@+id/fragmentA"
|
||||
android:name="com.agileburo.anytype.FragmentA"
|
||||
android:label="FragmentA"
|
||||
tools:layout="@layout/fragment_a" />
|
||||
<fragment
|
||||
android:id="@+id/fragmentB"
|
||||
android:name="com.agileburo.anytype.FragmentB"
|
||||
android:label="FragmentB"
|
||||
tools:layout="@layout/fragment_b" />
|
||||
<fragment
|
||||
android:id="@+id/fragmentC"
|
||||
android:name="com.agileburo.anytype.FragmentC"
|
||||
android:label="FragmentC"
|
||||
tools:layout="@layout/fragment_c" />
|
||||
</navigation>
|
|
@ -41,5 +41,3 @@ task clean(type: Delete) {
|
|||
task runUnitTests(dependsOn: [':app:testDebugUnitTest']) {
|
||||
description 'Run all unit tests'
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
include ':app',
|
||||
':feature_login',
|
||||
':core_utils'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue