diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/caches/deviceStreaming.xml b/.idea/caches/deviceStreaming.xml new file mode 100644 index 0000000..9e9ba09 --- /dev/null +++ b/.idea/caches/deviceStreaming.xml @@ -0,0 +1,607 @@ + + + + + + \ No newline at end of file diff --git a/.idea/easyeat.iml b/.idea/easyeat.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/easyeat.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..639900d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..d1ad635 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.idea/compiler.xml b/app/.idea/compiler.xml index b589d56..b86273d 100644 --- a/app/.idea/compiler.xml +++ b/app/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/app/.idea/misc.xml b/app/.idea/misc.xml index 097137d..2731899 100644 --- a/app/.idea/misc.xml +++ b/app/.idea/misc.xml @@ -3,7 +3,7 @@ - + diff --git a/app/app/.idea/.gitignore b/app/app/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/app/app/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/app/app/.idea/gradle.xml b/app/app/.idea/gradle.xml new file mode 100644 index 0000000..4019936 --- /dev/null +++ b/app/app/.idea/gradle.xml @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file diff --git a/app/app/.idea/migrations.xml b/app/app/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/app/app/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/app/app/.idea/misc.xml b/app/app/.idea/misc.xml new file mode 100644 index 0000000..3040d03 --- /dev/null +++ b/app/app/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/app/.idea/other.xml b/app/app/.idea/other.xml new file mode 100644 index 0000000..22069ff --- /dev/null +++ b/app/app/.idea/other.xml @@ -0,0 +1,549 @@ + + + + + + \ No newline at end of file diff --git a/app/app/.idea/vcs.xml b/app/app/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/app/app/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/app/src/main/.idea/.gitignore b/app/app/src/main/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/app/app/src/main/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/app/app/src/main/.idea/caches/deviceStreaming.xml b/app/app/src/main/.idea/caches/deviceStreaming.xml new file mode 100644 index 0000000..9e9ba09 --- /dev/null +++ b/app/app/src/main/.idea/caches/deviceStreaming.xml @@ -0,0 +1,607 @@ + + + + + + \ No newline at end of file diff --git a/app/app/src/main/.idea/misc.xml b/app/app/src/main/.idea/misc.xml new file mode 100644 index 0000000..ef89d98 --- /dev/null +++ b/app/app/src/main/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/app/src/main/.idea/modules.xml b/app/app/src/main/.idea/modules.xml new file mode 100644 index 0000000..122a905 --- /dev/null +++ b/app/app/src/main/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/app/src/main/.idea/vcs.xml b/app/app/src/main/.idea/vcs.xml new file mode 100644 index 0000000..4fce1d8 --- /dev/null +++ b/app/app/src/main/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/app/src/main/java/tech/mercantec/easyeat/MainActivity.kt b/app/app/src/main/java/tech/mercantec/easyeat/MainActivity.kt index 7f67a61..53828c0 100644 --- a/app/app/src/main/java/tech/mercantec/easyeat/MainActivity.kt +++ b/app/app/src/main/java/tech/mercantec/easyeat/MainActivity.kt @@ -1,6 +1,14 @@ package tech.mercantec.easyeat +import android.graphics.Color import android.os.Bundle +import android.view.View +import android.view.ViewGroup +import android.widget.ArrayAdapter +import android.widget.BaseAdapter +import android.widget.ListView +import android.widget.TextView +import android.widget.Toast import com.google.android.material.bottomnavigation.BottomNavigationView import androidx.appcompat.app.AppCompatActivity import androidx.navigation.findNavController @@ -8,6 +16,8 @@ import androidx.navigation.ui.AppBarConfiguration import androidx.navigation.ui.setupActionBarWithNavController import androidx.navigation.ui.setupWithNavController import tech.mercantec.easyeat.databinding.ActivityMainBinding +import tech.mercantec.easyeat.ui.home.DishAdapter +import tech.mercantec.easyeat.ui.home.models.Dish class MainActivity : AppCompatActivity() { @@ -22,8 +32,6 @@ class MainActivity : AppCompatActivity() { val navView: BottomNavigationView = binding.navView val navController = findNavController(R.id.nav_host_fragment_activity_main) - // Passing each menu ID as a set of Ids because each - // menu should be considered as top level destinations. val appBarConfiguration = AppBarConfiguration( setOf( R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications @@ -31,5 +39,27 @@ class MainActivity : AppCompatActivity() { ) setupActionBarWithNavController(navController, appBarConfiguration) navView.setupWithNavController(navController) + + val listView: ListView = findViewById(R.id.dishesList) + val listItems = arrayOf( + Dish("Spaghetti Bolognese", "Beef", 70.5), + Dish("Margherita Pizza", "Cheese", 60.0), + Dish("Chicken Curry", "Chicken", 80.2), + Dish("Vegetable Stir Fry", "Mixed Vegetables", 50.5), + Dish("Sushi", "Fish", 100.0), + Dish("Beef Tacos", "Beef", 60.8), + Dish("Lentil Soup", "Lentils", 40.5), + Dish("Pasta Alfredo", "Cream", 60.9), + Dish("Caesar Salad", "Chicken", 50.8), + Dish("Falafel Wrap", "Chickpeas", 50.2) + ) + + val listAdapter = DishAdapter(this, listItems) + listView.adapter = listAdapter + + listView.setOnItemClickListener { parent, view, position, id -> + val selectedItem = parent.getItemAtPosition(position) as Dish + Toast.makeText(this, "you selected $selectedItem.name that costs ${selectedItem.expense} kr.", Toast.LENGTH_LONG).show() + } } -} \ No newline at end of file +} diff --git a/app/app/src/main/java/tech/mercantec/easyeat/ui/home/DishAdapter.kt b/app/app/src/main/java/tech/mercantec/easyeat/ui/home/DishAdapter.kt new file mode 100644 index 0000000..6b264a0 --- /dev/null +++ b/app/app/src/main/java/tech/mercantec/easyeat/ui/home/DishAdapter.kt @@ -0,0 +1,29 @@ +package tech.mercantec.easyeat.ui.home + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ArrayAdapter +import android.widget.TextView +import tech.mercantec.easyeat.R +import tech.mercantec.easyeat.ui.home.models.Dish + +class DishAdapter(context: Context, dishes: Array) : + ArrayAdapter(context, 0, dishes) { + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + val dish = getItem(position) + val view = convertView ?: LayoutInflater.from(context).inflate(R.layout.dish_list_item, parent, false) + + val nameTextView = view.findViewById(R.id.dishName) + val ingredientTextView = view.findViewById(R.id.mainIngredient) + val expenseTextView = view.findViewById(R.id.expense) + + nameTextView.text = "Name: ${dish?.name}" + ingredientTextView.text = "Main Ingredient: ${dish?.mainIngredient}" + expenseTextView.text = "Expense: ${dish?.expense} kr" + + return view + } +} diff --git a/app/app/src/main/java/tech/mercantec/easyeat/ui/home/models/dish.kt b/app/app/src/main/java/tech/mercantec/easyeat/ui/home/models/dish.kt new file mode 100644 index 0000000..49965ad --- /dev/null +++ b/app/app/src/main/java/tech/mercantec/easyeat/ui/home/models/dish.kt @@ -0,0 +1,3 @@ +package tech.mercantec.easyeat.ui.home.models + +public data class Dish(val name: String, val mainIngredient: String, val expense: Double) diff --git a/app/app/src/main/res/layout/activity_main.xml b/app/app/src/main/res/layout/activity_main.xml index 06ea6ca..eb29570 100644 --- a/app/app/src/main/res/layout/activity_main.xml +++ b/app/app/src/main/res/layout/activity_main.xml @@ -6,28 +6,40 @@ android:layout_height="match_parent" android:paddingTop="?attr/actionBarSize"> + + + + + + + - - - \ No newline at end of file + diff --git a/app/app/src/main/res/layout/dish_list_item.xml b/app/app/src/main/res/layout/dish_list_item.xml new file mode 100644 index 0000000..419bc04 --- /dev/null +++ b/app/app/src/main/res/layout/dish_list_item.xml @@ -0,0 +1,23 @@ + + + + + + + + \ No newline at end of file diff --git a/app/app/src/main/res/menu/bottom_nav_menu.xml b/app/app/src/main/res/menu/bottom_nav_menu.xml index fb6d040..8525ec3 100644 --- a/app/app/src/main/res/menu/bottom_nav_menu.xml +++ b/app/app/src/main/res/menu/bottom_nav_menu.xml @@ -4,7 +4,7 @@ + android:title="@string/title_your_dishes" /> EasyEat MainActivity - Home + Your Dishes Dashboard Notifications Welcome to EasyEat