| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?xml version="1.0" encoding="utf-8"?>
- <layout 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">
- <data>
- <import type="android.view.View"/>
- <!-- Ссылка на наш Data Class внизу файла MainActivity.kt -->
- <variable name="weather" type="com.example.weather.WeatherInfo" />
- <variable name="isLoading" type="Boolean" />
- </data>
- <androidx.constraintlayout.widget.ConstraintLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:padding="16dp">
- <EditText
- android:id="@+id/etCity"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:hint="City (e.g. Paris)"
- android:text="London"
- app:layout_constraintEnd_toStartOf="@+id/btnSearch"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
- <Button
- android:id="@+id/btnSearch"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Search"
- android:onClick="onGetWeatherClick"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
- <!-- Прогресс бар, виден если isLoading == true -->
- <ProgressBar
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:visibility="@{isLoading ? View.VISIBLE : View.GONE}"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/etCity" />
- <!-- Контейнер погоды, виден если данные есть и не грузимся -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:gravity="center"
- android:visibility="@{!isLoading && weather != null ? View.VISIBLE : View.GONE}"
- app:layout_constraintTop_toBottomOf="@+id/etCity"
- app:layout_constraintBottom_toBottomOf="parent">
- <TextView
- android:text="@{weather.temperature}"
- android:textSize="60sp"
- android:textStyle="bold"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- tools:text="20°C"/>
- <ImageView
- android:layout_width="120dp"
- android:layout_height="120dp"
- app:imageUrl="@{weather.iconUrl}"
- tools:src="@android:drawable/ic_menu_camera"/>
- <TextView
- android:text="@{weather.description}"
- android:textSize="24sp"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- tools:text="Sunny"/>
- <TextView
- android:text="@{weather.humidity}"
- android:layout_marginTop="10dp"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:gravity="center_vertical"
- android:layout_marginTop="10dp">
- <TextView
- android:text="@{weather.windInfo}"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- tools:text="Wind: 5 m/s"/>
- <!-- Стрелка ветра -->
- <ImageView
- android:layout_width="30dp"
- android:layout_height="30dp"
- android:src="@android:drawable/arrow_up_float"
- app:tint="#555"
- app:rotationAngle="@{weather.windRotation}"
- android:layout_marginStart="8dp"/>
- </LinearLayout>
- </LinearLayout>
- </androidx.constraintlayout.widget.ConstraintLayout>
- </layout>
|