fragment_demo_home.xml 15.7 KB
Newer Older
姜天宇's avatar
姜天宇 committed
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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <data>
        <import type="android.view.View"/>
        <variable
            name="viewModel"
            type="com.wmdigit.cateringdetect.demo.ui.viewmodel.DemoHomeViewModel" />
    </data>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".ui.fragment.DemoHomeFragment">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/gray_d9d9d9"
            android:padding="@dimen/dp_10">

            <!--垂直平分线-->
            <androidx.constraintlayout.widget.Guideline
                android:id="@+id/gl_v_50"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                app:layout_constraintGuide_percent="0.50"/>

            <!--水平线0.60-->
            <androidx.constraintlayout.widget.Guideline
                android:id="@+id/gl_h_60"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                app:layout_constraintGuide_percent="0.60"/>

            <!--购物车-->
            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="@dimen/dp_0"
                android:layout_height="@dimen/dp_0"
                android:layout_marginEnd="@dimen/dp_5"
                android:background="@drawable/rect_10_white"
                android:paddingTop="@dimen/dp_20"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintEnd_toStartOf="@+id/gl_v_50"
                app:layout_constraintBottom_toBottomOf="parent">

                <!--水平分割商品列表和支付栏-->
                <androidx.constraintlayout.widget.Guideline
                    android:id="@+id/gl_cart_h_88"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    app:layout_constraintGuide_percent="0.88"
                    />

                <!--垂直分割应付款和支付按钮-->
                <androidx.constraintlayout.widget.Guideline
                    android:id="@+id/gl_cart_v_75"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    app:layout_constraintGuide_percent="0.75"/>

                <!--标题栏-->
                <LinearLayout
                    android:id="@+id/ll_cart_title"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:paddingVertical="@dimen/dp_15"
                    android:paddingHorizontal="@dimen/dp_28"
                    app:layout_constraintTop_toTopOf="parent">

                    <!--名称-->
                    <TextView
                        style="@style/text_base.content"
                        android:text="@string/product_name"
                        android:layout_width="0dp"
                        android:layout_weight="48"
                        />

                    <!--单价-->
                    <TextView
                        style="@style/text_base.content"
                        android:text="@string/unit_price"
                        android:layout_width="0dp"
                        android:layout_weight="25"
                        android:gravity="center"
                        />

                    <!--数量-->
                    <TextView
                        style="@style/text_base.content"
                        android:text="@string/quantity"
                        android:layout_width="0dp"
                        android:layout_weight="25"
                        android:gravity="center"
                        />

                    <!--金额-->
                    <TextView
                        style="@style/text_base.content"
                        android:text="@string/amount"
                        android:layout_width="0dp"
                        android:layout_weight="25"
                        android:gravity="center"
                        />

                    <!--操作-->
                    <TextView
                        style="@style/text_base.content"
                        android:layout_width="0dp"
                        android:layout_weight="10"
                        android:gravity="center"
                        android:text="@string/operate"
                        />

                </LinearLayout>

                <!--分割线-->
                <View
                    android:id="@+id/split_line_1"
                    style="@style/split_line_base"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/ll_cart_title"/>

                <!--暂无购物车信息-->
                <!--<ImageView
                    android:id="@+id/img_empty_cart"
                    android:layout_width="@dimen/dp_250"
                    android:layout_height="wrap_content"
                    android:src="@drawable/bg_empty_data"
                    android:adjustViewBounds="true"
                    android:visibility="@{viewModel.shoppingCartListSize == 0 ? View.VISIBLE : View.INVISIBLE}"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintBottom_toTopOf="@+id/gl_cart_h_88"
                    app:layout_constraintTop_toBottomOf="@+id/split_line_1"/>-->
                
                <TextView
                    style="@style/text_base.content"
                    android:text="@string/no_products_in_cart"
                    android:layout_marginTop="@dimen/dp_60"
                    android:visibility="@{viewModel.shoppingCartListSize == 0 ? View.VISIBLE : View.INVISIBLE}"
                    app:layout_constraintTop_toBottomOf="@+id/split_line_1"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"/>

                <!--购物车列表-->
                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/rv_shopping_cart"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/dp_0"
                    android:visibility="@{viewModel.shoppingCartListSize == 0 ? View.INVISIBLE : View.VISIBLE}"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/split_line_1"
                    app:layout_constraintBottom_toTopOf="@+id/gl_cart_h_88"/>

                <!--应付款:-->
                <TextView
                    android:id="@+id/tv_dues"
                    style="@style/text_base.content"
                    android:layout_width="@dimen/dp_0"
                    android:layout_height="@dimen/dp_0"
                    android:text="@{viewModel.dues}"
                    android:textSize="@dimen/sp_32"
                    android:paddingStart="@dimen/dp_28"
                    android:textColor="@color/white"
                    android:gravity="center_vertical"
                    android:background="@drawable/rect_bl_10_deep_blue"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/gl_cart_h_88"
                    app:layout_constraintEnd_toStartOf="@+id/gl_cart_v_75"
                    />

                <!--清单-->
                <TextView
                    android:id="@+id/tv_clear_shopping_cart"
                    style="@style/text_base.content"
                    android:text="@string/clear_shopping_cart"
                    android:textColor="@color/white"
                    android:gravity="center_vertical"
                    android:background="@drawable/rect_bl_10_deep_blue"
                    android:layout_marginEnd="@dimen/dp_30"
                    android:visibility="@{viewModel.shoppingCartListSize == 0 ? View.INVISIBLE : View.VISIBLE}"
                    android:onClick="@{()->viewModel.deleteShoppingCart(-1)}"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/gl_cart_h_88"
                    app:layout_constraintEnd_toStartOf="@+id/gl_cart_v_75"
                    />

                <!--支付按钮-->
                <TextView
                    android:id="@+id/tv_pay"
                    style="@style/text_base.content"
                    android:layout_width="@dimen/dp_0"
                    android:layout_height="@dimen/dp_0"
                    android:text="@{viewModel.goPay}"
                    android:textSize="@dimen/sp_32"
                    android:textColor="@color/white"
                    android:gravity="center"
                    android:background="@drawable/sel_rect_br_10_red_gray"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toEndOf="@+id/gl_cart_v_75"
                    app:layout_constraintTop_toBottomOf="@id/gl_cart_h_88"
                    />

            </androidx.constraintlayout.widget.ConstraintLayout>

            <!--待识别的商品图片列表-->
            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_marginStart="@dimen/dp_5"
                android:layout_marginBottom="@dimen/dp_5"
                android:padding="@dimen/dp_5"
                android:background="@drawable/rect_10_white"
                app:layout_constraintStart_toEndOf="@+id/gl_v_50"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintBottom_toTopOf="@+id/gl_h_60"
                app:layout_constraintEnd_toEndOf="parent">

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/rv_demo_images"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"/>

            </androidx.constraintlayout.widget.ConstraintLayout>

            <!--识别结果-->
            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_marginTop="@dimen/dp_5"
                android:layout_marginStart="@dimen/dp_5"
                android:background="@drawable/rect_10_white"
                android:padding="@dimen/dp_10"
                app:layout_constraintTop_toBottomOf="@+id/gl_h_60"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toEndOf="@+id/gl_v_50">

                <androidx.constraintlayout.widget.Guideline
                    android:id="@+id/gl_result_v_70"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    app:layout_constraintGuide_percent="0.70"/>

                <!--存放识别结果的图-->
                <ImageView
                    android:id="@+id/img_result"
                    android:layout_width="@dimen/dp_0"
                    android:layout_height="@dimen/dp_0"
                    android:adjustViewBounds="true"
                    android:background="@drawable/rect_10_e0e0e0"
                    android:layout_marginEnd="@dimen/dp_5"
                    app:image="@{viewModel.detectResultBitmap}"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:layout_constraintEnd_toStartOf="@+id/gl_result_v_70"
                    app:layout_constraintBottom_toBottomOf="parent"
                    />

                <!--未选择图片时展示的图-->
                <ImageView
                    android:id="@+id/img_no_selected"
                    android:layout_width="@dimen/dp_180"
                    android:layout_height="wrap_content"
                    android:adjustViewBounds="true"
                    android:src="@drawable/ic_no_selected_image"
                    android:layout_marginTop="@dimen/dp_50"
                    android:visibility="@{viewModel.detectResultBitmap == null ? View.VISIBLE : View.INVISIBLE}"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:layout_constraintEnd_toStartOf="@+id/gl_result_v_70"
                    />

                <TextView
                    style="@style/text_base.content"
                    android:text="@string/no_image_selected"
                    android:visibility="@{viewModel.detectResultBitmap == null ? View.VISIBLE : View.INVISIBLE}"
                    app:layout_constraintTop_toBottomOf="@+id/img_no_selected"
                    app:layout_constraintStart_toStartOf="@+id/img_no_selected"
                    app:layout_constraintEnd_toEndOf="@+id/img_no_selected"/>

                <!--右侧模块-->
                <androidx.constraintlayout.widget.ConstraintLayout
                    android:layout_width="@dimen/dp_0"
                    android:layout_height="match_parent"
                    android:background="@drawable/rect_10_deep_blue"
                    android:layout_marginStart="@dimen/dp_5"
                    android:padding="@dimen/dp_20"
                    app:layout_constraintStart_toEndOf="@+id/gl_result_v_70"
                    app:layout_constraintEnd_toEndOf="parent">

                    <!--品名-->
                    <TextView
                        style="@style/text_base.content"
                        android:textColor="@color/white"
                        android:textSize="@dimen/sp_32"
                        android:textStyle="bold"
                        android:layout_marginTop="@dimen/dp_50"
                        android:text="@{viewModel.detectResultProductName}"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        />

                    <!--单价-->
                    <TextView
                        style="@style/text_base.content"
                        android:textColor="@color/white"
                        android:textSize="@dimen/sp_40"
                        android:textStyle="bold"
                        android:text="@{viewModel.detectResultUnitPrice}"
                        android:layout_marginBottom="@dimen/dp_60"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintBottom_toBottomOf="parent"
                        />

                </androidx.constraintlayout.widget.ConstraintLayout>

            </androidx.constraintlayout.widget.ConstraintLayout>


        </androidx.constraintlayout.widget.ConstraintLayout>

    </FrameLayout>
</layout>