Skip to content

Commit

Permalink
- changed ui main screen for cupertino
Browse files Browse the repository at this point in the history
 - bug fix about navigation screens
 - bug fix about not registered users nickname
  • Loading branch information
deneme committed Jan 23, 2022
1 parent 59c3a75 commit 13c794f
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 105 deletions.
1 change: 1 addition & 0 deletions lib/data/firebase/firebase_user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class FirebaseUser extends GetxService{
//await databaseReference.child(firebaseAuth.currentUser!.uid.toString()).child("username").set(username);
var checkTakenUsername = await collectionReference.where('displayName',isEqualTo: username).get();
if(checkTakenUsername.size == 0){
await firebaseAuth.currentUser?.updateDisplayName(username);
await collectionReference.doc(firebaseAuth.currentUser!.uid.toString()).update({"displayName": username});
}else{
return false;
Expand Down
2 changes: 1 addition & 1 deletion lib/model/game_types.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
enum GameType{
all,
frp,
boardGame,
tcg,
all,
}
106 changes: 53 additions & 53 deletions lib/screen/create_game_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,62 +33,62 @@ class _CreateGameScreenState extends State<CreateGameScreen> {
super.initState();
}

@override
Widget build(BuildContext context) {
void cupertinoGameTypeSelector(context){
showCupertinoModalPopup(
context: context,
builder: (_) => Container(
color: Colors.white,
width: 300,
alignment: Alignment.center,
height: MediaQuery.of(context).size.height * 0.2,
child: CupertinoPicker(
itemExtent: 30,
children: gameTypeList.map(
(e) => DropdownMenuItem(
child: Center(
child: Text(e == GameType.frp
? "FRP"
: e == GameType.boardGame
? "Kutu oyunu"
: "TCG"),
),
value: e,
),
).toList(),
onSelectedItemChanged: (int index) {
setState(() {
selectedGameType = gameTypeList[index];
});
},
),
)
);
}

void cupertinoProvienceSelector(){
showCupertinoModalPopup(
context: context,
builder: (_) => Container(
color: Colors.white,
width: 300,
alignment: Alignment.center,
height: MediaQuery.of(context).size.height * 0.4,
child: CupertinoPicker(
itemExtent: 30,
children: gameProvinceList.map((e) => Center(child: Text(e))).toList(),
onSelectedItemChanged: (int index) {
setState(() {
selectedGameProvince = gameProvinceList[index];
});
},
),
)
);
}

void cupertinoGameTypeSelector(context){
showCupertinoModalPopup(
context: context,
builder: (_) => Container(
color: Colors.white,
width: 300,
alignment: Alignment.center,
height: MediaQuery.of(context).size.height * 0.2,
child: CupertinoPicker(
itemExtent: 30,
children: gameTypeList.map(
(e) => DropdownMenuItem(
child: Center(
child: Text(e == GameType.frp
? "FRP"
: e == GameType.boardGame
? "Kutu oyunu"
: "TCG"),
),
value: e,
),
).toList(),
onSelectedItemChanged: (int index) {
setState(() {
selectedGameType = gameTypeList[index];
});
},
),
)
);
}
@override
Widget build(BuildContext context) {

void cupertinoProvienceSelector(){
showCupertinoModalPopup(
context: context,
builder: (_) => Container(
color: Colors.white,
width: 300,
alignment: Alignment.center,
height: MediaQuery.of(context).size.height * 0.4,
child: CupertinoPicker(
itemExtent: 30,
children: gameProvinceList.map((e) => Center(child: Text(e))).toList(),
onSelectedItemChanged: (int index) {
setState(() {
selectedGameProvince = gameProvinceList[index];
});
},
),
)
);
}

return PlatformScaffold(
appBar: PlatformAppBar(
Expand Down
4 changes: 2 additions & 2 deletions lib/screen/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class _LoginScreenState extends State<LoginScreen> {
DialogUtils.createLoadingDialog(context, "Yükleniyor", "Uygulamaya giriş yapılmaya çalışılıyor");
if( _formKey.currentState!.validate()){
LoginResponse loginResponse = await userGet.loginUser(LoginRequest(mail: mailController.text, passHash: passController.text));
Navigator.of(Get.overlayContext!).pop();
Navigator.of(Get.overlayContext!, rootNavigator: true).pop();
if(loginResponse == LoginResponse.successful){
Get.offAll(const MainScreen());
} else if(loginResponse == LoginResponse.userNotFound){
Expand All @@ -154,7 +154,7 @@ class _LoginScreenState extends State<LoginScreen> {
Get.snackbar("Hata", "Hata oluştu");
}
}else{
Navigator.of(Get.overlayContext!).pop();
Navigator.of(Get.overlayContext!, rootNavigator: true).pop();
}
}

Expand Down
7 changes: 6 additions & 1 deletion lib/screen/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
void checkUsername() {
if (userDatabase.getUser()!.displayName == null) {
TextEditingController controller = TextEditingController();
bool isLoading = false;
bool isErrorShort = false;
bool isErrorTaken = false;
bool isSuccess = false;
Expand Down Expand Up @@ -160,7 +161,10 @@ class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
setState(() {
isErrorShort = true;
});
} else if( isLoading) {

} else {
isLoading = true;
bool response = await userGet.setUsername(controller.text);
if (response) {
setState(() {
Expand All @@ -169,7 +173,8 @@ class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
isSuccess = true;
});
Future.delayed(Duration(seconds: 2), () {
Navigator.of(Get.overlayContext!).pop();
isLoading = false;
Navigator.of(Get.overlayContext!, rootNavigator: true).pop();
});
} else {
setState(() {
Expand Down
11 changes: 2 additions & 9 deletions lib/screen/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,9 @@ class _SettingsScreenState extends State<SettingsScreen> {
barrierDismissible: false
);
bool logout = await userGet.logoutUser();
Navigator.of(Get.overlayContext!).pop();
Navigator.of(Get.overlayContext!, rootNavigator: true).pop();
if(logout){
Navigator.pushReplacement(
context,
platformPageRoute(
context: context,
material: (_, __) => MaterialPageRouteData((_) => LoginScreen(), RouteSettings(), true, false),
cupertino: (_,__) => CupertinoPageRouteData((_) => LoginScreen(), RouteSettings(), true, false)
)
);
Get.off(const LoginScreen());
}else{
Get.snackbar("İşlem Başarısız", "Çıkış işlemi başarısız oldu");
}
Expand Down
Loading

0 comments on commit 13c794f

Please sign in to comment.