Merge branch 'bottomNavigation' into develop
This commit is contained in:
@@ -1,13 +1,21 @@
|
|||||||
package com.a1.nextlocation;
|
package com.a1.nextlocation;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import com.a1.nextlocation.R;
|
import com.a1.nextlocation.R;
|
||||||
|
import com.a1.nextlocation.fragments.HomeFragment;
|
||||||
|
import com.a1.nextlocation.fragments.RouteFragment;
|
||||||
|
import com.a1.nextlocation.fragments.SettingsFragment;
|
||||||
|
import com.a1.nextlocation.fragments.StatisticFragment;
|
||||||
|
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* onCreate method that creates the main activity
|
* onCreate method that creates the main activity
|
||||||
* @param savedInstanceState the saved instance state of the app
|
* @param savedInstanceState the saved instance state of the app
|
||||||
@@ -16,5 +24,33 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
BottomNavigationView bottomNav = findViewById(R.id.navbar);
|
||||||
|
bottomNav.setOnNavigationItemSelectedListener(navListener);
|
||||||
|
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, new HomeFragment()).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private BottomNavigationView.OnNavigationItemSelectedListener navListener = item -> {
|
||||||
|
Fragment selectedFragment = null;
|
||||||
|
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.locations:
|
||||||
|
selectedFragment = new HomeFragment();
|
||||||
|
break;
|
||||||
|
case R.id.routes:
|
||||||
|
selectedFragment = new RouteFragment();
|
||||||
|
break;
|
||||||
|
case R.id.statistics:
|
||||||
|
selectedFragment = new StatisticFragment();
|
||||||
|
break;
|
||||||
|
case R.id.settings:
|
||||||
|
selectedFragment = new SettingsFragment();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, selectedFragment).commit();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
10
app/src/main/res/drawable/ic_home.xml
Normal file
10
app/src/main/res/drawable/ic_home.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z"/>
|
||||||
|
</vector>
|
||||||
10
app/src/main/res/drawable/ic_placeholder.xml
Normal file
10
app/src/main/res/drawable/ic_placeholder.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:pathData="M17.6,11.48 L19.44,8.3a0.63,0.63 0,0 0,-1.09 -0.63l-1.88,3.24a11.43,11.43 0,0 0,-8.94 0L5.65,7.67a0.63,0.63 0,0 0,-1.09 0.63L6.4,11.48A10.81,10.81 0,0 0,1 20L23,20A10.81,10.81 0,0 0,17.6 11.48ZM7,17.25A1.25,1.25 0,1 1,8.25 16,1.25 1.25,0 0,1 7,17.25ZM17,17.25A1.25,1.25 0,1 1,18.25 16,1.25 1.25,0 0,1 17,17.25Z"
|
||||||
|
android:fillColor="@android:color/white"/>
|
||||||
|
</vector>
|
||||||
@@ -6,13 +6,40 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".MainActivity">
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
<TextView
|
<FrameLayout
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/fragment_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/scroller_devider"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/scroller_devider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_marginStart="32dp"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/navbar"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
|
android:id="@+id/navbar"
|
||||||
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Hello World!"
|
android:background="@color/white"
|
||||||
|
app:itemIconTint="@color/primaryColour"
|
||||||
|
app:itemTextColor="@color/primaryColour"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:menu="@menu/navmenu"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
28
app/src/main/res/menu/navmenu.xml
Normal file
28
app/src/main/res/menu/navmenu.xml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/locations"
|
||||||
|
android:title="@string/locations"
|
||||||
|
android:icon="@drawable/ic_placeholder"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/routes"
|
||||||
|
android:title="@string/routes"
|
||||||
|
android:icon="@drawable/ic_placeholder"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/statistics"
|
||||||
|
android:title="@string/statistics"
|
||||||
|
android:icon="@drawable/ic_placeholder"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/settings"
|
||||||
|
android:title="@string/settings"
|
||||||
|
android:icon="@drawable/ic_placeholder"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</menu>
|
||||||
@@ -7,4 +7,7 @@
|
|||||||
<color name="teal_700">#FF018786</color>
|
<color name="teal_700">#FF018786</color>
|
||||||
<color name="black">#FF000000</color>
|
<color name="black">#FF000000</color>
|
||||||
<color name="white">#FFFFFFFF</color>
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
<color name="primaryColour">#FF115571</color>
|
||||||
|
<color name="secondaryColour">#FF31AFB4</color>
|
||||||
|
<color name="buttonColour">#FF14212D</color>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -2,4 +2,8 @@
|
|||||||
<string name="app_name">Next Location</string>
|
<string name="app_name">Next Location</string>
|
||||||
<!-- TODO: Remove or change this placeholder text -->
|
<!-- TODO: Remove or change this placeholder text -->
|
||||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||||
|
<string name="locations">Locaties</string>
|
||||||
|
<string name="routes">Routes</string>
|
||||||
|
<string name="statistics">Statistieken</string>
|
||||||
|
<string name="settings">Instellingen</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -2,15 +2,10 @@
|
|||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="Theme.NextLocation" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
<style name="Theme.NextLocation" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||||
<!-- Primary brand color. -->
|
<!-- Primary brand color. -->
|
||||||
<item name="colorPrimary">@color/purple_500</item>
|
<item name="colorPrimary">@color/primaryColour</item>
|
||||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
|
||||||
<item name="colorOnPrimary">@color/white</item>
|
|
||||||
<!-- Secondary brand color. -->
|
<!-- Secondary brand color. -->
|
||||||
<item name="colorSecondary">@color/teal_200</item>
|
<item name="colorSecondary">@color/secondaryColour</item>
|
||||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
|
||||||
<item name="colorOnSecondary">@color/black</item>
|
|
||||||
<!-- Status bar color. -->
|
|
||||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
|
<item name="colorButtonNormal">@color/buttonColour</item>
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user