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/component/common/build.gradle b/component/common/build.gradle index 5ffcc098..aff0b75a 100644 --- a/component/common/build.gradle +++ b/component/common/build.gradle @@ -32,4 +32,6 @@ dependencies { testImplementation libs.junit androidTestImplementation libs.androidx.test.ext.junit androidTestImplementation libs.androidx.test.espresso.core + + implementation project(':shared:ui') } \ No newline at end of file diff --git a/component/common/src/main/res/layout/common_library_list_item.xml b/component/common/src/main/res/layout/common_library_list_item.xml new file mode 100644 index 00000000..2a9850e5 --- /dev/null +++ b/component/common/src/main/res/layout/common_library_list_item.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/feature/debug/src/main/res/layout/list_item_debug_menu.xml b/feature/debug/src/main/res/layout/list_item_debug_menu.xml index 607fd4e6..eb345aef 100644 --- a/feature/debug/src/main/res/layout/list_item_debug_menu.xml +++ b/feature/debug/src/main/res/layout/list_item_debug_menu.xml @@ -11,6 +11,7 @@ android:layout_height="wrap_content" android:textSize="16sp" android:layout_marginEnd="8dp" + android:text="Placeholder Title" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -19,6 +20,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:textSize="14sp" + android:text="Placeholder Description" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/debug_menu_item_title" /> diff --git a/feature/home/build.gradle b/feature/home/build.gradle index e3aa10e0..71b997d1 100644 --- a/feature/home/build.gradle +++ b/feature/home/build.gradle @@ -55,4 +55,6 @@ dependencies { implementation project(':model') implementation "androidx.recyclerview:recyclerview:1.3.2" + + implementation project(':component:common') } \ No newline at end of file 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 0f39aa5c..46a452d5 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 @@ -3,13 +3,24 @@ package one.nem.lacerta.feature.home; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; import android.view.View; 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; import java.util.List; @@ -34,34 +45,13 @@ public class HomeTopFragment extends Fragment { @Inject LacertaLibrary lacertaLibrary; - - // TODO: Rename parameter arguments, choose names that match - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER - private static final String ARG_PARAM1 = "param1"; - private static final String ARG_PARAM2 = "param2"; - - // TODO: Rename and change types of parameters - private String mParam1; - private String mParam2; - public HomeTopFragment() { // Required empty public constructor } - /** - * Use this factory method to create a new instance of - * this fragment using the provided parameters. - * - * @param param1 Parameter 1. - * @param param2 Parameter 2. - * @return A new instance of fragment HomeTopFragment. - */ - // TODO: Rename and change types and number of parameters - public static HomeTopFragment newInstance(String param1, String param2) { + public static HomeTopFragment newInstance() { HomeTopFragment fragment = new HomeTopFragment(); Bundle args = new Bundle(); - args.putString(ARG_PARAM1, param1); - args.putString(ARG_PARAM2, param2); fragment.setArguments(args); return fragment; } @@ -70,49 +60,58 @@ public class HomeTopFragment extends Fragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - if (getArguments() != null) { - mParam1 = getArguments().getString(ARG_PARAM1); - mParam2 = getArguments().getString(ARG_PARAM2); - - - } } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_home_top, container, false); -// List metas = document.getAllDocumentMetas(100); + ArrayList recentDocument = lacertaLibrary.getRecentDocument(10); - ArrayList listItems = lacertaLibrary.getRecentDocument(100); + Log.d("docs", Integer.toString(recentDocument.size())); - Log.d("docs", Integer.toString(listItems.size())); - - RecyclerView recyclerView = view.findViewById(R.id.item_recycler_view); + RecyclerView recyclerView = view.findViewById(R.id.home_item_recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - MyAdapter myAdapter = new MyAdapter(listItems); + ListItemAdapter listItemAdapter = new ListItemAdapter(recentDocument); - recyclerView.setAdapter(myAdapter); + recyclerView.setAdapter(listItemAdapter); return view; + } + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); - } -String pageTitle; - String pageId; - ArrayList listItems; - - String title; - String description; - - String itemId; + CollapsingToolbarLayout collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar); + Toolbar toolbar = view.findViewById(R.id.toolbar); + // Set the Toolbar + ((AppCompatActivity)getActivity()).setSupportActionBar(toolbar); + // 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 + } + } + }); + } } diff --git a/feature/home/src/main/java/one/nem/lacerta/feature/home/ListItemAdapter.java b/feature/home/src/main/java/one/nem/lacerta/feature/home/ListItemAdapter.java new file mode 100644 index 00000000..03f4a8d7 --- /dev/null +++ b/feature/home/src/main/java/one/nem/lacerta/feature/home/ListItemAdapter.java @@ -0,0 +1,59 @@ +package one.nem.lacerta.feature.home; + +import android.media.Image; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.ArrayList; + +import one.nem.lacerta.model.ListItem; + +public class ListItemAdapter extends RecyclerView.Adapter{ + + ArrayList listItems; + + public ListItemAdapter(ArrayList listItems){ + this.listItems = listItems; + } + + @NonNull + @Override + public ListItemAdapter.ListItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.component.common.R.layout.common_library_list_item, parent, false); + return new ListItemViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull ListItemAdapter.ListItemViewHolder holder, int position) { + ListItem listItem = listItems.get(position); + holder.icon.setImageResource(listItem.getItemType().getIconId()); + holder.icon.setColorFilter(one.nem.lacerta.shared.ui.R.color.colorOnSurface); + holder.title.setText(listItem.getTitle()); + holder.description.setText(listItem.getDescription()); + } + + @Override + public int getItemCount() { + return listItems.size(); + } + + public static class ListItemViewHolder extends RecyclerView.ViewHolder{ + + ImageView icon; + TextView title; + TextView description; + public ListItemViewHolder(@NonNull View itemView) { + super(itemView); + + icon = itemView.findViewById(one.nem.lacerta.component.common.R.id.item_icon); + title = itemView.findViewById(one.nem.lacerta.component.common.R.id.item_title); + description = itemView.findViewById(one.nem.lacerta.component.common.R.id.item_description); + } + } +} 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 b5c724e4..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,21 +1,50 @@ - + android:background="@color/colorSurface"> - - - - - + - + + + + + + + + + + + \ No newline at end of file diff --git a/feature/home/src/main/res/menu/drawer_menu.xml b/feature/home/src/main/res/menu/drawer_menu.xml new file mode 100644 index 00000000..0cc72028 --- /dev/null +++ b/feature/home/src/main/res/menu/drawer_menu.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/shared/ui/src/main/res/values-night-v27/themes.xml b/shared/ui/src/main/res/values-night-v27/themes.xml index c6797497..445f5b6a 100644 --- a/shared/ui/src/main/res/values-night-v27/themes.xml +++ b/shared/ui/src/main/res/values-night-v27/themes.xml @@ -30,6 +30,7 @@ @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/strings.xml b/shared/ui/src/main/res/values/strings.xml index 98ef6664..a7abe338 100644 --- a/shared/ui/src/main/res/values/strings.xml +++ b/shared/ui/src/main/res/values/strings.xml @@ -15,4 +15,5 @@ + Placeholder(TODO: Replace) \ 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 -