# Custom App

## If you want to use the Template to create a custom application, you can access it from this [link](https://github.com/stachenoisy/Stache-Phone-CustomApp).

{% hint style="success" %}
After installation, you need to make an edit similar to the template below in `ui/config.js` to add the application to the phone.
{% endhint %}

```javascript
       {
          id: 10, // (required)
          order: 10, // (required)
          AppName: "Test App", // (required)
          open: "nui://examplecustomapp/index.html", // App Open Name (appname or iframe name) (not required)
          MenuBtnColor: "white", // Menu Button Color (white/black). Default: "white" (It is recommended not to make changes.)
          Descp: "Sounds Good.", // Appstore Description (required)
          Size: 566231040, // App Size (Bytes) (required)
          IsVertical: true, // Is Vertical (true/false) (required)
          Type: "AppsPage", // Appstore Page Type (GamesPage, AppsPage, ArcadePage) (required)
          Version: "1.0.0", // App Version (String). Default: "1.0.0" if use "0" Disable Download App. (required)
          AppIcon: "https://appicon.com/appicon.png",  // (required)
          StoreInfo: { // Appstore Info (required)
            Price: null, // App Price (Int). Default: null if use null Disable Purchase.
            Catagory: "Test Applications", // App Catagory (String)
            Age: 12, // App Age (Int)
            RatingData: { // App Rating Data
              Rating: 3.7, // App Rating (Float) (Max: 5.0)
              RatingCount: 1.2 // App Rating Count (Float)
            },
            ChartInfo: { // App Chart Info 
              Num: 12 // App Chart Number (Int)
            },
            Screenshots: [ // App Screenshots (Array)
              "https://appscreenshots.com/appscreenshot1.png",
              "https://appscreenshots.com/appscreenshot2.png",
              // ...
            ]
          }
        },
```

You can add it by making edits on the draft.

{% hint style="warning" %}
Pay attention to the 'id' and 'order' sections. Make sure they are not the same as another application.
{% endhint %}

{% hint style="info" %}
If you want to add a default pre-installed application, use the following draft.
{% endhint %}

```javascript
        {
          id: 1, // App ID (required)
          order: 1, // App Order Number (required)
          AppName: "Test App",  // App Name (required)
          AppIcon: "https://appicon.com/appicon.png", // App Icon (required)
          Whitelist: true, // Whitelisted App (Can't be deleted) (not required)
          open: "nui://examplecustomapp/index.html", // App Open Name (appname or iframe name) (not required)
          MenuBtnColor: "white" // Menu Button Color (white/black). Default: "white" (It is recommended not to make changes.)
        },
```

{% hint style="info" %}
If you don't fill in the 'open' variable, the application will be downloaded but not opened.
{% endhint %}

{% hint style="info" %}
If you set the 'version' variable to 0, the application will not be downloaded.
{% endhint %}

## So what are the available functions.

{% hint style="warning" %}
These are the functions used for the UI Part!
{% endhint %}

<details>

<summary>STPhone.PreviewPhoto</summary>

Type: <mark style="color:purple;">(Function)</mark>

Parameters: @src, @type, @name, @time, @size

* @src (string) - <mark style="color:yellow;">Photo Image / Video Source</mark>
* @type (string) - <mark style="color:yellow;">Photo Type (Photo / Video)</mark>
* @name (string) - <mark style="color:yellow;">Photo Name / Video Name</mark>
* @time (string) - <mark style="color:yellow;">Photo Time / Video Time</mark>
* @size (string) - <mark style="color:yellow;">Photo Size / Video Size</mark>

This Function allows you to display photos on the Gallery.

</details>

<details>

<summary>STPhone.CopyText</summary>

Type: <mark style="color:purple;">(Function)</mark>

Parameters: @text

* @text(string) - <mark style="color:yellow;">Text To Copy</mark>

This Function allows you to copy a specific text.

</details>

<details>

<summary>STPhone.LockPhone</summary>

Type: <mark style="color:purple;">(Function)</mark>

This Function allows you to lock the Phone.

</details>

<details>

<summary>STPhone.ShowContact</summary>

Type: <mark style="color:purple;">(Function)</mark>

Parameters: @name, @number

* @name(string) - <mark style="color:yellow;">Contact Name (Optional)</mark>
* @number(string) - <mark style="color:yellow;">Contact Number</mark>

This Function allows you to view a Contact in the contacts or add it to the contacts if it is not attached in the contacts.

</details>

<details>

<summary>STPhone.ShowConversition</summary>

Type: <mark style="color:purple;">(Function)</mark>

Parameters: @number, @msgid

* @number(int) - <mark style="color:yellow;">Contact Number</mark>&#x20;
* @msgid(int) - <mark style="color:yellow;">Message ID (Optional)</mark>

This Function Opens your messages with a Person or creates a new message.

</details>

<details>

<summary>STPhone.TwitterShowPost</summary>

Type: <mark style="color:purple;">(Function)</mark>

Parameters: @postid

* @postid(string) - <mark style="color:yellow;">Post ID</mark>

This Function allows you to view the Twitter Post.

</details>

<details>

<summary>STPhone.FormatBytes</summary>

Type: <mark style="color:purple;">(Function)</mark>

Parameters: @bytes, @pretty

* @byte(int) - <mark style="color:yellow;">Bytes</mark>
* @pretty(boolean) - <mark style="color:yellow;">Pretty Format (ex. 10 MB / 3 GB) (optional)</mark>

This Function allows you to format the Byte type

</details>

<details>

<summary>STPhone.WalletPay</summary>

Type: <mark style="color:purple;">(Function)</mark>

Parameters: @amount, @forcereturnhomescreen

* @amount(int) - <mark style="color:yellow;">Amount</mark>
* @forcereturnhomescreen(boolean) - <mark style="color:yellow;">Force Return Home Screen (optional)</mark>

This Function allows you to pay with WalletPay.

Note: This function uses promise api.

</details>

<details>

<summary>STPhone.ViewImage</summary>

Type: <mark style="color:purple;">(Function)</mark>

Parameters: @src, @show

* @src(string) - <mark style="color:yellow;">Image Source</mark>
* @show(boolean) - <mark style="color:yellow;">Show / Hide</mark>

This function allows you to view Photos in a large format.

</details>

<details>

<summary>STPhone.OpenApp</summary>

Type: <mark style="color:purple;">(Function)</mark>

Parameters: @appname

* @appname(string) - <mark style="color:yellow;">App Name</mark>

This function allows you to open a Different Application.

</details>

<details>

<summary>STPhone.OpenModal</summary>

Type: <mark style="color:purple;">(Function)</mark>

Parameters: @title, @descp, @placeholder, @callback, @enableInput, @canceltext, @savetext, @showsavebtn

* @title(string) - <mark style="color:yellow;">Modal Title</mark>
* @descp(string) - <mark style="color:yellow;">Modal Description</mark>
* @placeholder(string) - <mark style="color:yellow;">Modal Placeholder</mark>
* @callback(function) - <mark style="color:yellow;">Modal Callback (Parameter: Input Value)</mark>
* @enableInput(boolean) - <mark style="color:yellow;">Enable Input</mark>
* @canceltext(string) - <mark style="color:yellow;">Cancel Button Text</mark>
* @savetext(string) - <mark style="color:yellow;">Save Button Text</mark>
* @showsavebtn(boolean) - <mark style="color:yellow;">Show Save Button</mark>

This function allows you to Create Modals.

</details>

<details>

<summary>STPhone.ChangePhoneBorderColor</summary>

Type: <mark style="color:purple;">(Function)</mark>

Parameters: @color

* @color(string) - <mark style="color:yellow;">Color (Hex)</mark>

This function allows you to change the case color of the phone.

</details>

<details>

<summary>STPhone.ChangePhoneSize</summary>

Type: <mark style="color:purple;">(Function)</mark>

Parameters: @ishorizontal

* @ishorizontal(boolean) - <mark style="color:yellow;">Is Horizontal Phone</mark>

This function allows you to rotate the Phone.

</details>

<details>

<summary>STPhone.GetConfig</summary>

Type: <mark style="color:purple;">(Function)</mark>

Return: <mark style="color:red;">Config File Object</mark>

</details>

<details>

<summary>STPhone.GetLanguages</summary>

Type: <mark style="color:purple;">(Function)</mark>

Return: <mark style="color:red;">Languages Array</mark>

</details>

{% hint style="warning" %}
These are the functions used for the Lua Part!
{% endhint %}

<details>

<summary>STPhone:Client:Notify</summary>

Type: <mark style="color:purple;">(Event)</mark>

Side: <mark style="color:orange;">(Client)</mark>

Parameters: App, Title, Content, Timeout, Image

* App (string) - <mark style="color:yellow;">App Name</mark>
* Title (string) - <mark style="color:yellow;">Notify Title</mark>
* Content (string) - <mark style="color:yellow;">Notify Content</mark>
* Timeout (int) - <mark style="color:yellow;">Notify Display Time</mark>
* Image (string) - <mark style="color:yellow;">Notify Image</mark>

An event that you can use to send notifications to the phone

</details>

<details>

<summary>StachePhone:RequestSMS</summary>

Type: <mark style="color:purple;">(Event)</mark>

Side: <mark style="color:orange;">(Client)</mark>

Parameters: Data

* Data (table) - <mark style="color:yellow;">SMS Data</mark>

```
Data = {
    Sender = "Bank",
    MessageID = 997468748641385,
    Message = "Thank you for joining our bank."
}
```

It is used to send SMS to the phone.

</details>

<details>

<summary>STPhone:Server:AddMoneyToCard</summary>

Type: <mark style="color:purple;">(Event)</mark>

Side: <mark style="color:orange;">(Server)</mark>

Parameters: CardID, Amount, CitizenID, Author

* CardID (string) - <mark style="color:yellow;">CardID or 'main' for cash account</mark>
* Amount (int) - <mark style="color:yellow;">Amount</mark>
* CitizenID (string) - <mark style="color:yellow;">CitizenID</mark>
* Author (string) - <mark style="color:yellow;">Author For Transactions</mark>

An event that you can use to add money to a player's wallet card

</details>

<details>

<summary>STPhone:Server:RemoveMoneyFromCard</summary>

Type: <mark style="color:purple;">(Event)</mark>

Side: <mark style="color:orange;">(Server)</mark>

Parameters: CardID, Amount, CitizenID, Author

* CardID (string) - <mark style="color:yellow;">CardID or 'main' for cash account</mark>
* Amount (int) - <mark style="color:yellow;">Amount</mark>
* CitizenID (string) - <mark style="color:yellow;">CitizenID</mark>
* Author (string) - <mark style="color:yellow;">Author For Transactions</mark>

An event that you can use to remove money to a player's wallet card

</details>
