# Dialog

<span style="font-weight: 400;">این المان که یک المان مادر است به جای ساخت یک صفحه کامل تنها یک دایالوگ میسازد و میتواند بدون خارج شدن از محیط کنونی کاربر پیام را به کاربر نمایش دهد.</span>

**<span data-darkreader-inline-color="" style="color: #000000;">این المان موارد زیر را داراست:</span>**

- ##### <span style="font-weight: 400;"><span style="font-weight: 400;">Text :</span></span>

<span style="font-weight: 400;">متن توضیحات دایالوگ را مشخص میکند.</span>

- ##### <span style="font-weight: 400;"><span style="font-weight: 400;">Title :</span></span>

<span style="font-weight: 400;">تیتر دایالوگ را مشخص میکند.</span>

- ##### <span style="font-weight: 400;"><span style="font-weight: 400;">Onshown :</span></span>

<span style="font-weight: 400;">اکشنی که موقع نمایش داده شدن دایالوگ رخ میدهد را مشخص میکند.</span>

- ##### <span style="font-weight: 400;"><span style="font-weight: 400;">Ondismiss :</span></span>

<span style="font-weight: 400;">اکشنی که موقع dismiss شدن دایالوگ رخ میدهد را مشخص میکند.</span>

- ##### <span style="font-weight: 400;"><span style="font-weight: 400;">Background :</span></span>

<span style="font-weight: 400;">رنگ پس زمینه دایالوگ را مشخص میکند.</span>

- ##### <span style="font-weight: 400;"><span style="font-weight: 400;">TextColor :</span></span>

<span style="font-weight: 400;">.رنگ متن توضیحات دایالوگ را مشخص میکند</span>

در ادامه یک نمونه از کد dialog را مشاهده کنید:

```XML
<dialog borderCornerRadius="3">
    <frame layout="linear_vertical" width="75" height="75" gravity="center">
        <image src="http://162.55.105.137:8080/api/public/dl/IPI8gq4o" width="match_parent" selfgravity="center"></image>
    </frame>
    <frame layout="linear_vertical">
        <text renderas="html" textcolor="#E64724" text="<b>به اپسان خوش آمدید<\b>" textsize="18"
              textalignment="center"></text>
    </frame>
    <button text="تایید" borderCornerRadius="3" background="#E64724" onClick="app/closedialog"></button>
</dialog>
```

و در نتیجه کد فوق به صورت زیر اجرا میشود :

![](http://wiki.appsan.ir/uploads/images/gallery/2021-07/image-1625549733640.jpg)

- نمونه کدی از **اپدیت دیالوگ** :

```XML
<page title="">
    <text id="txtP" text="Not updated"/>

    <button text="open dialog" onclick="dialog/d1"/>
    <button text="update text" onclick="script/s1:update()"/>
    <button text="auto close dialog" onclick="dialog/d1;script/s1:autoCloseDialog()"/>

    <script id="s1">
    function update() {
    Appsan.setProperty("txtP", "text", "Updated from page");
    }

        function autoCloseDialog() {
            setTimeout(function() {
                Appsan.runAction("app/closedialog:d1");
        console.log("ran")
            }, 2000);
        }
    </script>
</page>

<bottomsheetdialog id="d1">
<text id="txt" text="Not updated"/>
<button text="Update Me" onclick="script/s2:update()"/>
<button text="Update Parent" onclick="script/s2:updateParent()"/>
<button text="close" onclick="app/closedialog"/>
<button text="close with script" onclick="script/s2:closeDialog()"/>
<script id="s2">
    function update() {
    Appsan.setProperty("txt", "text", "Updated");
    }
    function updateParent() {
    Appsan.setProperty("txtP", "text", "Updated from dialog");
    }
    function closeDialog() {
    Appsan.runAction("app/closedialog");
    }

    function autoCloseDialog() {
    setTimeout(function() {
                    Appsan.runAction("app/closedialog:d1");
    console.log("ran")
    }, 2000);
    }
</script>
</bottomsheetdialog>
```