aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/src/main/res/layout/tv_tunnel_list_item.xml
blob: c5dd6c37e82bb90eab7a24e6cbbd59fe3e491e8d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?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" />

        <import type="com.wireguard.android.model.ObservableTunnel" />

        <import type="com.wireguard.android.backend.Tunnel.State" />

        <variable
            name="isDeleting"
            type="androidx.databinding.ObservableBoolean" />

        <variable
            name="key"
            type="String" />

        <variable
            name="item"
            type="com.wireguard.android.model.ObservableTunnel" />
    </data>

    <!-- Rather than changing the background tint to red for deleting mode, it should instead just change the selection color -->
    <com.google.android.material.card.MaterialCardView
        android:layout_width="300dp"
        android:layout_height="150dp"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:backgroundTint="@{isDeleting ? @color/error_tag_color : item.state == State.UP ? @color/secondary_light_color : @color/primary_color}"
        android:checkable="true"
        android:focusable="true"
        app:cardCornerRadius="12dp">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="16dp">

            <com.google.android.material.textview.MaterialTextView
                android:id="@+id/tunnel_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@{item.name}"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                tools:text="@sample/interface_names.json/names/names/name" />

            <com.google.android.material.textview.MaterialTextView
                android:id="@+id/tunnel_transfer"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="@{isDeleting ? View.GONE : View.VISIBLE}"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                tools:text="rx: 200 MB, tx: 100 MB" />

            <!-- TODO: replace the "&amp;&amp; true" stuff with && isSelected() -->
            <com.google.android.material.textview.MaterialTextView
                android:id="@+id/tunnel_delete"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/tv_delete"
                android:visibility="@{isDeleting &amp;&amp; true ? View.VISIBLE : View.GONE}"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent" />

        </androidx.constraintlayout.widget.ConstraintLayout>

    </com.google.android.material.card.MaterialCardView>

</layout>