Custom States problem

Hello, friends. My application is completely built on 1 page with a change of states. The disadvantage of this approach has been found. When you press the back button on the phone (the phone’s system button, see the screenshot), the application goes to the previous page. How to implement a return to the previous state in order to stay on the same page?