Geep5

Untitled

Nov 6th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 KB | None | 0 0
  1. <page>
  2. <actionBar title="Boss Party 2" />
  3.  
  4. <tabs tabsPosition="bottom">
  5. <tabStrip>
  6. <tabStripItem title="Bosses" />
  7. <tabStripItem title="Party" />
  8. <tabStripItem title="Inventory" />
  9. <tabStripItem title="Spells" />
  10. <tabStripItem title="Settings" />
  11.  
  12. </tabStrip>
  13.  
  14. <tabContentItem>
  15.  
  16. <gridLayout columns="*,120" rows="70,*">
  17. <!-- Configures the text field and ensures that pressing Return on the keyboard
  18. produces the same result as tapping the button. -->
  19. <textField col="0" row="0" hint="Type new task..." editable="true"
  20. on:returnPress="{onButtonTap}" />
  21. <button col="1" row="0" text="Add task" on:tap="{onButtonTap}" class="-primary"/>
  22.  
  23. <listView items="{todos}" on:itemTap="{onItemTap}" row="1" colSpan="2">
  24.  
  25. </listView>
  26. </gridLayout>
  27.  
  28. </tabContentItem>
  29.  
  30. <!-- Party -->
  31. <tabContentItem>
  32. <stackLayout >
  33. <listView items="{listOfWeapons}" on:itemTap="{onItemTap}">
  34. <Template let:item>
  35. <label text="{item}" />
  36. </Template>
  37. </listView>
  38. </stackLayout>
  39. </tabContentItem>
  40.  
  41. <!-- Inventory -->
  42. <tabContentItem>
  43. <stackLayout >
  44. <listView items="{listOfWeapons}" on:itemTap="{onItemTap}">
  45. <Template let:item>
  46. <label text="{item}" />
  47. </Template>
  48. </listView>
  49. </stackLayout>
  50. </tabContentItem>
  51.  
  52. <!-- Spells -->
  53. <tabContentItem>
  54. <stackLayout >
  55. <listView items="{listOfItems}" on:itemTap="{onItemTap}">
  56. <Template let:item>
  57. <label text="{item}" />
  58. </Template>
  59. </listView>
  60.  
  61. </stackLayout>
  62. </tabContentItem>
  63.  
  64.  
  65. <!-- Seettings -->
  66. <tabContentItem>
  67. <stackLayout>
  68. <label text="Goal: Clicking a button will trigger a progress " />
  69. <textField keyboardType="number"></textField>
  70.  
  71. <progress value="{currentProgress}" />
  72. <!-- <progress value="69" /> -->
  73. <button text="Button" on:tap="{onGoal}" />
  74. <label text="Goal: Clicking a button will trigger a progress bar" />
  75.  
  76. </stackLayout>
  77. </tabContentItem>
  78. </tabs>
  79. </page>
  80.  
  81. <script>
  82.  
  83.  
  84. import { Template } from 'svelte-native/components'
  85. let listOfItems = ['Gear', 'Weapons', 'Gems','Potions']
  86. let listOfWeapons = ['SSword', 'Staff', 'Bow','Relic']
  87.  
  88. const selectedIndexChanged = (e) => console.log(e.index)
  89.  
  90. let items = ["item 0", "item 1"]
  91. function selectTemplate(item, index, items) {
  92. // Your logic here
  93. return (index % 2 == 0) ? "even" : "odd";
  94. }
  95.  
  96.  
  97. let currentProgress = 49
  98. let todos = []
  99. let dones=[] //completed items go here
  100. const removeFromList = (list, item) => list.filter(t => t !== item);
  101. const addToList = (list, item) => [item, ...list]
  102. let textFieldValue = ""
  103.  
  104.  
  105. async function onItemTap(args) {
  106.  
  107.  
  108. }
  109.  
  110. function onGoal() {
  111. currentProgress = 100;
  112. }
  113.  
  114. function onButtonTap() {
  115. if (textFieldValue === "") return; // Prevents users from entering an empty string.
  116. console.log("New task added: " + textFieldValue + "."); // Logs the newly added task in the console for debugging.
  117. todos = [{ name: textFieldValue }, ...todos] // Adds tasks in the ToDo array. Newly added tasks are immediately shown on the screen.
  118. textFieldValue = ""; // Clears the text field so that users can start adding new tasks immediately.
  119. }
  120.  
  121. async function onDoneTap(args) {
  122. let result = await action("What do you want to do with this task?", "Cancel", [
  123. "Mark To Do",
  124. "Delete forever"
  125. ]);
  126.  
  127. console.log(result); // Logs the selected option for debugging.
  128. let item = dones[args.index]
  129. switch (result) {
  130. case "Mark To Do":
  131. todos = addToList(todos, item) // Places the tapped active task at the top of the completed tasks.
  132. dones = removeFromList(dones, item) // Removes the tapped active task.
  133. break;
  134. case "Delete forever":
  135. dones = removeFromList(dones, item) // Removes the tapped active task.
  136. break;
  137. case "Cancel" || undefined: // Dismisses the dialog
  138. break;
  139. }
  140. }
  141.  
  142.  
  143. </script>
  144.  
  145. <style>
  146. textField {
  147. font-size: 20;
  148. }
  149. </style>
Advertisement
Add Comment
Please, Sign In to add comment