Создание формы для добавления тренировок
This commit is contained in:
		
							parent
							
								
									ca52cec700
								
							
						
					
					
						commit
						a2709d0813
					
				| @ -12,6 +12,9 @@ | ||||
|         android:supportsRtl="true" | ||||
|         android:theme="@style/Theme.TimerT" | ||||
|         tools:targetApi="31"> | ||||
|         <activity | ||||
|             android:name=".CreatingTraining" | ||||
|             android:exported="false" /> | ||||
|         <activity | ||||
|             android:name=".timer" | ||||
|             android:exported="false" /> | ||||
|  | ||||
							
								
								
									
										53
									
								
								app/src/main/java/com/example/timert/CreatingTraining.kt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								app/src/main/java/com/example/timert/CreatingTraining.kt
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,53 @@ | ||||
| package com.example.timert | ||||
| 
 | ||||
| import android.app.AlertDialog | ||||
| import android.content.Intent | ||||
| import android.os.Bundle | ||||
| import android.widget.Button | ||||
| import android.widget.ImageButton | ||||
| import androidx.activity.enableEdgeToEdge | ||||
| import androidx.appcompat.app.AppCompatActivity | ||||
| import androidx.core.view.ViewCompat | ||||
| import androidx.core.view.WindowInsetsCompat | ||||
| 
 | ||||
| class CreatingTraining : AppCompatActivity() { | ||||
|     private var isSave = false | ||||
|     override fun onCreate(savedInstanceState: Bundle?) { | ||||
|         super.onCreate(savedInstanceState) | ||||
|         enableEdgeToEdge() | ||||
|         setContentView(R.layout.activity_creating_training) | ||||
|         ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> | ||||
|             val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) | ||||
|             v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) | ||||
|             insets | ||||
|         } | ||||
|         val buttonSave: Button = findViewById(R.id.btn_save) | ||||
|         buttonSave.setOnClickListener { | ||||
| 
 | ||||
|             isSave=true | ||||
| 
 | ||||
|         } | ||||
|         val button_on_main: Button = findViewById(R.id.btn_on_main) | ||||
|         button_on_main.setOnClickListener { | ||||
|             if(isSave==false){ | ||||
|                 AlertDialog.Builder(this) | ||||
|                     .setTitle("Изменения не сохранены") | ||||
|                     .setMessage("Продолжить без сохранения?") | ||||
|                     .setPositiveButton("Да") { _, _ -> | ||||
| 
 | ||||
|                         val intent = Intent(this, MainActivity::class.java) | ||||
|                         startActivity(intent) | ||||
|                     } | ||||
|                     .setNegativeButton("Нет") { dialog, _ -> | ||||
|                         dialog.dismiss() | ||||
|                     } | ||||
|                     .show() | ||||
|             }else{ | ||||
|                 val intent = Intent(this, MainActivity::class.java) | ||||
|                 startActivity(intent) | ||||
| 
 | ||||
|             } | ||||
|             } | ||||
| 
 | ||||
|     } | ||||
| } | ||||
| @ -18,12 +18,18 @@ class MainActivity : AppCompatActivity() { | ||||
|             v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) | ||||
|             insets | ||||
|         } | ||||
|         var button: Button = findViewById(R.id.button2) | ||||
|         var button: Button = findViewById(R.id.button1) | ||||
| 
 | ||||
|         button.setOnClickListener{ | ||||
|             val intent = Intent(this,timer::class.java) | ||||
|             startActivity(intent) | ||||
|         } | ||||
|         var button2: Button = findViewById(R.id.button2) | ||||
| 
 | ||||
|         button2.setOnClickListener{ | ||||
|             val intent = Intent(this,CreatingTraining::class.java) | ||||
|             startActivity(intent) | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| } | ||||
							
								
								
									
										9
									
								
								app/src/main/res/drawable/gradient_purpure.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								app/src/main/res/drawable/gradient_purpure.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <shape | ||||
|     xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     android:shape="rectangle"> | ||||
|     <gradient | ||||
|         android:startColor="@color/colorGradientPurpureStart" | ||||
|         android:endColor="@color/colorGradientPurpureStop" | ||||
|         android:angle="180" /> | ||||
| </shape> | ||||
							
								
								
									
										14
									
								
								app/src/main/res/drawable/green_rectangle.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								app/src/main/res/drawable/green_rectangle.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,14 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     android:shape="rectangle"> | ||||
| 
 | ||||
| 
 | ||||
|     <gradient | ||||
|         android:type="linear" | ||||
|         android:startColor="@color/colorGradientGreenStart" | ||||
|         android:endColor="@color/colorGradientGreenStop" | ||||
|         android:gradientRadius="90" /> | ||||
| 
 | ||||
| 
 | ||||
|     <corners android:radius="10dp"/> | ||||
| </shape> | ||||
							
								
								
									
										10
									
								
								app/src/main/res/drawable/ic_add_24px.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								app/src/main/res/drawable/ic_add_24px.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | ||||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     android:width="24dp" | ||||
|     android:height="24dp" | ||||
|     android:viewportWidth="24" | ||||
|     android:viewportHeight="24" | ||||
|     android:tint="?attr/colorControlNormal"> | ||||
|   <path | ||||
|       android:fillColor="@android:color/white" | ||||
|       android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/> | ||||
| </vector> | ||||
							
								
								
									
										10
									
								
								app/src/main/res/drawable/ic_remove_24px.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								app/src/main/res/drawable/ic_remove_24px.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | ||||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     android:width="24dp" | ||||
|     android:height="24dp" | ||||
|     android:viewportWidth="24" | ||||
|     android:viewportHeight="24" | ||||
|     android:tint="?attr/colorControlNormal"> | ||||
|   <path | ||||
|       android:fillColor="@android:color/white" | ||||
|       android:pathData="M19,13H5v-2h14v2z"/> | ||||
| </vector> | ||||
							
								
								
									
										183
									
								
								app/src/main/res/layout/activity_creating_training.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										183
									
								
								app/src/main/res/layout/activity_creating_training.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,183 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     xmlns:tools="http://schemas.android.com/tools" | ||||
|     android:id="@+id/main" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="match_parent" | ||||
|     android:background="@drawable/blue_gradient" | ||||
|     tools:context=".CreatingTraining"> | ||||
| 
 | ||||
|     <LinearLayout | ||||
|         android:id="@+id/linearLayout" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="130dp" | ||||
|         android:layout_marginTop="25dp" | ||||
|         android:orientation="vertical" | ||||
|         app:layout_constraintTop_toTopOf="parent"> | ||||
| 
 | ||||
|         <TextView | ||||
|             android:id="@+id/textView2" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:text="Тренировка" | ||||
|             android:textAlignment="center" | ||||
|             android:textSize="34sp" /> | ||||
| 
 | ||||
|         <EditText | ||||
|             android:id="@+id/name_training" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_marginTop="20dp" | ||||
|             android:ems="10" | ||||
|             android:inputType="text" | ||||
|             android:text="Тренировка 1" | ||||
|             android:textAlignment="center" | ||||
|             android:textSize="20sp" /> | ||||
| 
 | ||||
|     </LinearLayout> | ||||
| 
 | ||||
|     <LinearLayout | ||||
|         android:id="@+id/setting_training" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="200dp" | ||||
|         android:layout_marginTop="37dp" | ||||
|         android:orientation="vertical" | ||||
|         app:layout_constraintTop_toBottomOf="@+id/linearLayout" | ||||
|         tools:layout_editor_absoluteX="16dp"> | ||||
| 
 | ||||
|         <TextView | ||||
|             android:id="@+id/textView5" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:text="Количество подходов" | ||||
|             android:textAlignment="center" | ||||
|             android:textSize="24sp" /> | ||||
| 
 | ||||
|         <LinearLayout | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_marginBottom="20dp" | ||||
|             android:orientation="horizontal"> | ||||
| 
 | ||||
|             <ImageView | ||||
|                 android:id="@+id/del_set" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="37dp" | ||||
|                 android:layout_weight="1" | ||||
|                 app:srcCompat="@drawable/ic_remove_24px" /> | ||||
| 
 | ||||
|             <TextView | ||||
|                 android:id="@+id/numbers_of_sets" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="38dp" | ||||
|                 android:layout_weight="1" | ||||
|                 android:text="0" | ||||
|                 android:textAlignment="center" | ||||
|                 android:textSize="34sp" /> | ||||
| 
 | ||||
|             <ImageView | ||||
|                 android:id="@+id/add_set" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="37dp" | ||||
|                 android:layout_weight="1" | ||||
|                 app:srcCompat="@drawable/ic_add_24px" /> | ||||
|         </LinearLayout> | ||||
| 
 | ||||
|         <TextView | ||||
|             android:id="@+id/textView8" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:text="Отдых между подходами" | ||||
|             android:textAlignment="center" | ||||
|             android:textSize="24sp" /> | ||||
| 
 | ||||
|         <LinearLayout | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="50dp" | ||||
|             android:orientation="horizontal"> | ||||
| 
 | ||||
|             <ImageView | ||||
|                 android:id="@+id/del_res" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="37dp" | ||||
|                 android:layout_weight="1" | ||||
|                 app:srcCompat="@drawable/ic_remove_24px" /> | ||||
| 
 | ||||
|             <TextView | ||||
|                 android:id="@+id/rest_sets" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="39dp" | ||||
|                 android:layout_weight="1" | ||||
|                 android:text="0" | ||||
|                 android:textAlignment="center" | ||||
|                 android:textSize="34sp" /> | ||||
| 
 | ||||
|             <ImageView | ||||
|                 android:id="@+id/add_res" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="37dp" | ||||
|                 android:layout_weight="1" | ||||
|                 app:srcCompat="@drawable/ic_add_24px" /> | ||||
|         </LinearLayout> | ||||
| 
 | ||||
|     </LinearLayout> | ||||
| 
 | ||||
|     <FrameLayout | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="60dp" | ||||
|         android:layout_marginTop="19dp" | ||||
|         app:layout_constraintTop_toBottomOf="@+id/setting_training" | ||||
|         tools:layout_editor_absoluteX="0dp"> | ||||
| 
 | ||||
|         <Button | ||||
|             android:id="@+id/add_workout" | ||||
|             android:layout_width="176dp" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_gravity="center" | ||||
|             android:background="@drawable/green_rectangle" | ||||
|             android:gravity="center" | ||||
|             android:text="+ упражнение" | ||||
|             android:textAlignment="center" | ||||
|             android:textColor="@color/white" | ||||
|             android:textSize="16sp" /> | ||||
|     </FrameLayout> | ||||
| 
 | ||||
|     <LinearLayout | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="60dp" | ||||
|         android:layout_marginBottom="35dp" | ||||
|         android:orientation="horizontal" | ||||
|         app:layout_constraintBottom_toBottomOf="parent" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintStart_toStartOf="parent"> | ||||
| 
 | ||||
|         <Button | ||||
|             android:id="@+id/btn_on_main" | ||||
|             android:layout_width="150dp" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_gravity="center" | ||||
|             android:layout_marginLeft="20dp" | ||||
|             android:layout_marginRight="20dp" | ||||
|             android:layout_weight="1" | ||||
|             android:background="@drawable/gradient_purpure" | ||||
|             android:text="на главную" | ||||
|             android:textAlignment="center" | ||||
|             android:textColor="@color/white" /> | ||||
| 
 | ||||
|         <Button | ||||
|             android:id="@+id/btn_save" | ||||
|             android:layout_width="150dp" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_gravity="center" | ||||
|             android:layout_marginLeft="20dp" | ||||
|             android:layout_marginRight="20dp" | ||||
|             android:layout_weight="1" | ||||
|             android:background="@drawable/gradient_purpure" | ||||
|             android:text="Сохранить" | ||||
|             android:textAlignment="center" | ||||
|             android:textColor="@color/white" /> | ||||
| 
 | ||||
|     </LinearLayout> | ||||
| 
 | ||||
| </androidx.constraintlayout.widget.ConstraintLayout> | ||||
| @ -13,11 +13,18 @@ | ||||
|         android:orientation="horizontal"> | ||||
| 
 | ||||
|         <Button | ||||
|             android:id="@+id/button2" | ||||
|             android:layout_width="382dp" | ||||
|             android:id="@+id/button1" | ||||
|             android:layout_width="171dp" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_weight="1" | ||||
|             android:text="Button" /> | ||||
| 
 | ||||
|         <Button | ||||
|             android:id="@+id/button2" | ||||
|             android:layout_width="wrap_content" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_weight="1" | ||||
|             android:text="Button2" /> | ||||
|     </LinearLayout> | ||||
| </androidx.constraintlayout.widget.ConstraintLayout> | ||||
| 
 | ||||
|  | ||||
| @ -12,4 +12,7 @@ | ||||
|     <color name="colorGradientBlueStart">#17EAD9</color> | ||||
|     <color name="colorGradientBlueStop">#6078EA</color> | ||||
| 
 | ||||
|     <color name="colorGradientPurpureStart">#7C37D3</color> | ||||
|     <color name="colorGradientPurpureStop">#916AD3</color> | ||||
| 
 | ||||
| </resources> | ||||
| @ -1,3 +1,4 @@ | ||||
| <resources> | ||||
|     <string name="app_name">TimerT</string> | ||||
|     <string name="app_name">Timer</string> | ||||
|     <string name="upper_start">START</string> | ||||
| </resources> | ||||
| @ -5,5 +5,6 @@ | ||||
|         <!-- <item name="colorPrimary">@color/my_light_primary</item> --> | ||||
|     </style> | ||||
| 
 | ||||
|     <style name="Theme.TimerT" parent="Base.Theme.TimerT" /> | ||||
| 
 | ||||
|     <style name="Theme.TimerT" parent="Theme.AppCompat.Light.NoActionBar" /> | ||||
| </resources> | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user