eranheres / ultra_type

0 stars 0 forks source link

sweep: add settings submenu #43

Closed eranheres closed 9 months ago

eranheres commented 9 months ago

Add a settings submenu in the main menu and move the "Change language" and "Change practice" to this submenu Files to check: controller.py view.py

Checklist - [X] Modify `ultra_type/view.py` ✓ https://github.com/eranheres/ultra_type/commit/02f45ab860791585124bc8cda60db842720d881a [Edit](https://github.com/eranheres/ultra_type/edit/sweep/settings-submenu/ultra_type/view.py) - [X] Running GitHub Actions for `ultra_type/view.py` ✓ [Edit](https://github.com/eranheres/ultra_type/edit/sweep/settings-submenu/ultra_type/view.py) - [X] Modify `ultra_type/controller.py` ✓ https://github.com/eranheres/ultra_type/commit/73f07a18a56deb8c97d201b5402bf774e35305dd [Edit](https://github.com/eranheres/ultra_type/edit/sweep/settings-submenu/ultra_type/controller.py) - [X] Running GitHub Actions for `ultra_type/controller.py` ✓ [Edit](https://github.com/eranheres/ultra_type/edit/sweep/settings-submenu/ultra_type/controller.py) ![Flowchart](https://raw.githubusercontent.com/eranheres/ultra_type/sweep/assets/56bafe59bff43a7b92045084633144e4cccc02adafda3f1c8f015eb3620c6250_43_flowchart.svg)
sweep-mine[bot] commented 9 months ago

Here's the PR! https://github.com/eranheres/ultra_type/pull/44. See Sweep's process at dashboard.

💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: 907a495a3a)

Actions (click)

Sandbox Execution ✓

Here are the sandbox execution logs prior to making any changes:

Sandbox logs for 15da3ea
Checking ultra_type/view.py for syntax errors... ✅ ultra_type/view.py has no syntax errors! 1/1 ✓
Checking ultra_type/view.py for syntax errors...
✅ ultra_type/view.py has no syntax errors!

Sandbox passed on the latest main, so sandbox checks will be enabled for this issue.


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/eranheres/ultra_type/blob/15da3eac4422b91d72bbd2dbb31da806d963dc81/ultra_type/view.py#L1-L47 https://github.com/eranheres/ultra_type/blob/15da3eac4422b91d72bbd2dbb31da806d963dc81/ultra_type/controller.py#L8-L37 https://github.com/eranheres/ultra_type/blob/15da3eac4422b91d72bbd2dbb31da806d963dc81/ultra_type/controller.py#L74-L86 https://github.com/eranheres/ultra_type/blob/15da3eac4422b91d72bbd2dbb31da806d963dc81/ultra_type/controller.py#L37-L74

Step 2: ⌨️ Coding

--- 
+++ 
@@ -42,8 +42,14 @@
             "Practice",
             "Show Stats",
             "Change Language",
-            "Change practice",
+            "Settings",
             "Save settings"])
+
+    def get_settings_menu_selection(self):
+        header = "Settings Menu"
+        return self._display_menu(header=header, options=[
+            "Change language",
+            "Change practice"])

     def show_language_menu(self):
         return self._display_menu(header="Choose language:", options=[

Ran GitHub Actions for 02f45ab860791585124bc8cda60db842720d881a:

--- 
+++ 
@@ -28,11 +28,8 @@
             elif action == '4':
                 self._change_practice()
             elif action == '5':
-                self.model.save_stats()
-                self.model.save_setting()
+                self._settings_menu()
             elif action == '6':
-                self.model.save_stats()
-                self.model.save_setting()
                 exit(0)

     def _stats_menu(self):
@@ -80,8 +77,22 @@
             self.model.language = Hebrew()

 # run if main
+    def _settings_menu(self):
+        action = self.view.get_settings_menu_selection()
+        if action == '1':
+            self._change_lang()
+        elif action == '2':
+            self._change_practice()
+
 if __name__ == '__main__':
     model = Model()
     view = View()
     controller = Controller(model, view)
-    controller.practice()
+    controller.run()
+
+    def _settings_menu(self):
+        action = self.view.get_settings_menu_selection()
+        if action == '1':
+            self._change_lang()
+        elif action == '2':
+            self._change_practice()

Ran GitHub Actions for 73f07a18a56deb8c97d201b5402bf774e35305dd:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/settings-submenu.


🎉 Latest improvements to Sweep:


💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord