Merge branch 'master' of git.reim.ar:ReiMerc/easyeat
This commit is contained in:
commit
4856bf5403
@ -68,7 +68,13 @@ class DishesFragment : Fragment() {
|
||||
return root
|
||||
|
||||
}
|
||||
|
||||
fun DishesFragment.loadRecipes() {
|
||||
binding.dishesList.visibility = View.GONE
|
||||
binding.emptyDishesList.visibility = View.GONE
|
||||
binding.addDish.visibility = View.GONE
|
||||
binding.loading.visibility = View.VISIBLE
|
||||
|
||||
thread {
|
||||
val recipes: List<GetAllRecipesResponse>
|
||||
try {
|
||||
@ -85,6 +91,13 @@ class DishesFragment : Fragment() {
|
||||
}
|
||||
|
||||
activity?.runOnUiThread {
|
||||
binding.dishesList.visibility = View.VISIBLE
|
||||
binding.emptyDishesList.visibility = View.VISIBLE
|
||||
binding.addDish.visibility = View.VISIBLE
|
||||
binding.loading.visibility = View.GONE
|
||||
|
||||
binding.dishesList.emptyView = binding.emptyDishesList
|
||||
|
||||
val adapter = DishAdapter(requireContext(), dishes) { selectedDish ->
|
||||
// Open details activity
|
||||
val intent = Intent(requireContext(), DishDetailsActivity::class.java)
|
||||
|
@ -1,26 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/dishes_fragment_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!-- Your list view -->
|
||||
<ProgressBar
|
||||
android:id="@+id/loading"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:visibility="gone"
|
||||
android:indeterminate="true"
|
||||
/>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/dishes_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:divider="@android:color/darker_gray"
|
||||
android:dividerHeight="1dp" />
|
||||
android:dividerHeight="1dp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/empty_dishes_list"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="@string/empty_dishes_list"
|
||||
/>
|
||||
|
||||
<!-- FloatingActionButton -->
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/add_dish"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_margin="16dp"
|
||||
android:backgroundTint="@color/cyan"
|
||||
app:srcCompat="@android:drawable/ic_input_add"
|
||||
app:tint="@android:color/white"/>
|
||||
</FrameLayout>
|
||||
app:tint="@android:color/white"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
@ -57,6 +57,7 @@
|
||||
<string name="increment_multiplier_desc">Increment portion count</string>
|
||||
<string name="decrement_multiplier_desc">Decrement portion size</string>
|
||||
<string name="edit_recipe">Edit Recipe</string>
|
||||
<string name="empty_dishes_list">You have not created any dishes yet</string>
|
||||
<string-array name="units">
|
||||
<item></item>
|
||||
<item>g</item>
|
||||
|
@ -21,7 +21,7 @@ namespace API.BusinessLogic
|
||||
public async Task<IActionResult> GetRecipes(int userId)
|
||||
{
|
||||
var recipes = await _dbAccess.ReadRecipes(userId);
|
||||
if (recipes == null || recipes.Count == 0) { return new ConflictObjectResult(new { message = "Could not find any recipes" }); }
|
||||
if (recipes == null) { return new ConflictObjectResult(new { message = "Could not find any recipes" }); }
|
||||
|
||||
var recipeDtos = recipes.Select(r => new GetAllRecipesDTO
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user