fix switch tabbar
Code refactoring and some bugs