ProjectLaogai/app/src/main/java/org/mosad/seil0/projectlaogai/HomeFragment.kt

112 lines
3.8 KiB
Kotlin

/**
* ProjectLaogai
*
* Copyright 2018 <seil0@mosad.xyz>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
package org.mosad.seil0.projectlaogai
import android.annotation.SuppressLint
import android.graphics.Color
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.ScrollView
import android.widget.TextView
import ord.mosad.seil0.projectlaogai.uicomponents.LessonCardView
/**
* The "home" controller class
* contains all needed parts to display the apps home screen
*/
class HomeFragment : Fragment() {
private lateinit var txtViewMenu1: TextView
private lateinit var txtViewMenu2: TextView
private lateinit var scrollViewTimeTable: ScrollView
private lateinit var linLayoutTimeTable: LinearLayout
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view: View = inflater.inflate(R.layout.fragment_home, container, false)
// init UI elements
txtViewMenu1 = view.findViewById(R.id.txtView_Menu1)
txtViewMenu2 = view.findViewById(R.id.txtView_Menu2)
scrollViewTimeTable = view.findViewById(R.id.scrollView_TimeTable)
linLayoutTimeTable = view.findViewById(R.id.linLayout_TimeTable)
setText()
addLessons()
// Inflate the layout for this fragment
return view
}
@SuppressLint("SetTextI18n")
private fun setText() {
txtViewMenu1.text = "Buntes Pfannengemüse\nCouscous\nBlattsalat"
txtViewMenu2.text = "Riesen Currywurst\nCurryketchup\nGitterkartoffeln\nBlattsalat"
}
@SuppressLint("SetTextI18n")
private fun addLessons() {
// for each lesson to display on homescreen create a cardview
val lessonCardView1 = LessonCardView(context!!, null)
val lessonCardView2 = LessonCardView(context!!, null)
val lessonCardView3 = LessonCardView(context!!, null)
val lessonCardView4 = LessonCardView(context!!, null)
val lessonCardView5 = LessonCardView(context!!, null)
lessonCardView1.getTxtViewLesson().text = "Computernetze 1\nMayer E.\nA213"
lessonCardView1.getTxtViewTime().text = "8.00 - 9.30"
lessonCardView2.getTxtViewLesson().text = "Computernetze 1\nMayer E.\nA213"
lessonCardView2.getTxtViewTime().text = "8.00 - 9.30"
lessonCardView3.getTxtViewLesson().text = "Computernetze 1\nMayer E.\nA213"
lessonCardView3.getTxtViewTime().text = "8.00 - 9.30"
lessonCardView4.getTxtViewLesson().text = "Computernetze 1\nMayer E.\nA213"
lessonCardView4.getTxtViewTime().text = "8.00 - 9.30"
lessonCardView5.getTxtViewLesson().text = "Computernetze 1\nMayer E.\nA213"
lessonCardView5.getTxtViewTime().text = "8.00 - 9.30"
lessonCardView1.setBackgroundColor(Color.parseColor("#3F51B5"))
// ff00ddff
linLayoutTimeTable.run {
addView(lessonCardView1)
addView(lessonCardView2)
addView(lessonCardView3)
addView(lessonCardView4)
addView(lessonCardView5)
}
}
}