From c6ddd6fd039e24ff609e3fb228922fbaebaa9e51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 19 Jan 2024 20:09:26 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=AA=E3=82=93=E3=81=8B=E3=82=82=E3=81=86?= =?UTF-8?q?=E5=85=A8=E9=83=A8=E5=A4=89=E3=81=88=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/MainActivity.java | 5 ++++- app/src/main/res/layout/activity_main.xml | 5 +++++ .../lacerta/feature/home/HomeTopFragment.java | 20 +++++++++++++++++++ .../src/main/res/layout/fragment_home_top.xml | 6 +++++- .../src/main/res/values-night-v27/themes.xml | 1 + .../src/main/res/values-night-v31/colors.xml | 3 +++ .../main/res/values-notnight-v31/colors.xml | 3 +++ shared/ui/src/main/res/values-v27/themes.xml | 1 + shared/ui/src/main/res/values/colors.xml | 2 ++ shared/ui/src/main/res/values/global.xml | 6 ++++++ shared/ui/src/main/res/values/themes.xml | 2 -- 11 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 shared/ui/src/main/res/values/global.xml diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index f1fa4676..6dec2e80 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -45,6 +45,9 @@ public class MainActivity extends AppCompatActivity { } // Set navigation bar color - getWindow().setNavigationBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurfaceVariant)); + getWindow().setNavigationBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer)); + + // Set status bar color + getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface)); } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 2117b2e1..3305b5e2 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -24,6 +24,11 @@ android:id="@+id/bottom_nav" android:layout_width="0dp" android:layout_height="wrap_content" + android:background="@color/colorSecondaryContainer" + app:itemIconTint="@color/colorOnSecondaryContainer" + app:itemTextColor="@color/colorOnSecondaryContainer" + app:itemActiveIndicatorStyle="@style/Lacerta.Custom.Indicator" + app:labelVisibilityMode="selected" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" diff --git a/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java b/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java index e1d3657f..257916f1 100644 --- a/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java +++ b/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java @@ -12,11 +12,13 @@ import android.view.ViewGroup; import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; +import androidx.core.content.ContextCompat; import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; import java.util.ArrayList; @@ -121,6 +123,24 @@ public class HomeTopFragment extends Fragment { // Set the title of the CollapsingToolbarLayout collapsingToolbarLayout.setTitle("Lacerta"); + + AppBarLayout appBarLayout = view.findViewById(R.id.app_bar_layout); + appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { + @Override + public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { + if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) { + // Collapsed + getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getActivity(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer)); + } else if (verticalOffset == 0) { + // Expanded + getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getActivity(), one.nem.lacerta.shared.ui.R.color.colorSurface)); + } else { + // Somewhere in between + // Here you can add a color transition if you want + } + } + }); + } String pageTitle; diff --git a/feature/home/src/main/res/layout/fragment_home_top.xml b/feature/home/src/main/res/layout/fragment_home_top.xml index cfc2b1f8..3fc0b723 100644 --- a/feature/home/src/main/res/layout/fragment_home_top.xml +++ b/feature/home/src/main/res/layout/fragment_home_top.xml @@ -1,18 +1,22 @@ + android:layout_height="match_parent" + android:background="@color/colorSurface"> @color/colorOnBackground false + false \ No newline at end of file diff --git a/shared/ui/src/main/res/values-night-v31/colors.xml b/shared/ui/src/main/res/values-night-v31/colors.xml index dfde2504..be984e38 100644 --- a/shared/ui/src/main/res/values-night-v31/colors.xml +++ b/shared/ui/src/main/res/values-night-v31/colors.xml @@ -25,4 +25,7 @@ @color/material_dynamic_neutral_variant90 @color/material_dynamic_neutral_variant30 @color/material_dynamic_neutral20 + + + @color/material_dynamic_secondary70 \ No newline at end of file diff --git a/shared/ui/src/main/res/values-notnight-v31/colors.xml b/shared/ui/src/main/res/values-notnight-v31/colors.xml index b09c84ac..cea43c34 100644 --- a/shared/ui/src/main/res/values-notnight-v31/colors.xml +++ b/shared/ui/src/main/res/values-notnight-v31/colors.xml @@ -24,4 +24,7 @@ @color/material_dynamic_neutral_variant90 @color/material_dynamic_neutral_variant30 @color/material_dynamic_neutral20 + + + @color/material_dynamic_secondary80 \ No newline at end of file diff --git a/shared/ui/src/main/res/values-v27/themes.xml b/shared/ui/src/main/res/values-v27/themes.xml index f7a979fc..da3c7be3 100644 --- a/shared/ui/src/main/res/values-v27/themes.xml +++ b/shared/ui/src/main/res/values-v27/themes.xml @@ -30,6 +30,7 @@ @color/colorOnBackground true + true \ No newline at end of file diff --git a/shared/ui/src/main/res/values/colors.xml b/shared/ui/src/main/res/values/colors.xml index 2f286f0e..a32e6b1e 100644 --- a/shared/ui/src/main/res/values/colors.xml +++ b/shared/ui/src/main/res/values/colors.xml @@ -25,4 +25,6 @@ #31312B #F3F1E8 #B8D321 + + #d2d4bc \ No newline at end of file diff --git a/shared/ui/src/main/res/values/global.xml b/shared/ui/src/main/res/values/global.xml new file mode 100644 index 00000000..49a2e771 --- /dev/null +++ b/shared/ui/src/main/res/values/global.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/shared/ui/src/main/res/values/themes.xml b/shared/ui/src/main/res/values/themes.xml index 68fccb6e..9c4f8521 100644 --- a/shared/ui/src/main/res/values/themes.xml +++ b/shared/ui/src/main/res/values/themes.xml @@ -28,8 +28,6 @@ @color/colorOutline @color/colorOnBackground - true -