Skip to content

Commit

Permalink
- bug fix ui about create game screen
Browse files Browse the repository at this point in the history
 - added cupertino design for create games screen
 - bug fix about loading dialog for cupertino design
  • Loading branch information
deneme committed Jan 22, 2022
1 parent 0f72867 commit 59c3a75
Show file tree
Hide file tree
Showing 8 changed files with 332 additions and 116 deletions.
23 changes: 13 additions & 10 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:get/get.dart';
import 'package:hive_flutter/hive_flutter.dart';

Expand Down Expand Up @@ -49,16 +50,18 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
SettingsDatabase settingsDatabase = Get.put(SettingsDatabase());
return GetMaterialApp(
title: 'Flutter Demo',
initialBinding: InitialBindings(),
routes: {
'/games' : (context) => const GamesScreen(),
'/settings' : (context) => const SettingsScreen(),
'profile' : (context) => const ProfileScreen()
},
theme: settingsDatabase.isDarkMode() ? CustomThemeData().darkTheme : CustomThemeData().lightTheme,
home: const IntroScreen(),
return PlatformApp(
home: GetMaterialApp(
title: 'Flutter Demo',
initialBinding: InitialBindings(),
routes: {
'/games' : (context) => const GamesScreen(),
'/settings' : (context) => const SettingsScreen(),
'profile' : (context) => const ProfileScreen()
},
theme: settingsDatabase.isDarkMode() ? CustomThemeData().darkTheme : CustomThemeData().lightTheme,
home: const IntroScreen(),
),
);
}
}
272 changes: 212 additions & 60 deletions lib/screen/create_game_screen.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'package:findgamemates/get/game_get.dart';
import 'package:findgamemates/model/game_post.dart';
import 'package:findgamemates/model/game_types.dart';
import 'package:findgamemates/theme_data.dart';
import 'package:findgamemates/utils/dialog_utils.dart';
import 'package:findgamemates/utils/utils_data.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:get/get.dart';

class CreateGameScreen extends StatefulWidget {
Expand All @@ -18,7 +21,7 @@ class _CreateGameScreenState extends State<CreateGameScreen> {
GameGet gameGet = Get.put(GameGet());
TextEditingController titleController = TextEditingController();
TextEditingController descController = TextEditingController();
List<GameType> gameTypeList = GameType.values;
List<GameType> gameTypeList = GameType.values.sublist(0,3);
late GameType selectedGameType;
List<String> gameProvinceList= UtilData.provienceList;
late String selectedGameProvince;
Expand All @@ -32,17 +35,77 @@ class _CreateGameScreenState extends State<CreateGameScreen> {

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Oyun Yaratma"),


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];
});
},
),
)
);
}

return PlatformScaffold(
appBar: PlatformAppBar(
title: Text("Oyun Yaratma",style: TextStyle(color: Colors.white),),
backgroundColor: CustomThemeData.primaryColor,
cupertino: (_, __) => CupertinoNavigationBarData(
brightness: Brightness.dark,

),
),
body: Center(
child: Container(
padding: const EdgeInsets.all(24),
child: NotificationListener<OverscrollIndicatorNotification>(
onNotification: (overScroll){
overScroll.disallowGlow();
return false;
return true;
},
child: SingleChildScrollView(
child: Column(
Expand All @@ -53,89 +116,178 @@ class _CreateGameScreenState extends State<CreateGameScreen> {
width: MediaQuery.of(context).size.width * 0.4,
height: MediaQuery.of(context).size.height * 0.2
),
ListTile(
title: Text("Oyun ismi"),
trailing: SizedBox(
width: MediaQuery.of(context).size.width*0.4,
child: TextField(
controller: titleController,
maxLines: 1,
maxLength: 20,
),
SizedBox(height: 20,),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Material(
child: Container(
width: MediaQuery.of(context).size.width*0.4,
color: CustomThemeData.backgroundColor,
alignment: Alignment.center,
child: PlatformText("Oyun ismi",)
),
),
SizedBox(
width: MediaQuery.of(context).size.width*0.4,
child: PlatformTextField(
controller: titleController,
maxLines: 1,
maxLength: 20,
),
)
],
),
),
ListTile(
title: Row(
Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const Expanded(
child: Text("Oyun açıklaması"),
Material(
child: Container(
width: MediaQuery.of(context).size.width*0.4,
alignment: Alignment.center,
color: CustomThemeData.backgroundColor,
child: PlatformText("Oyun açıklaması"),
)
),
Expanded(
child: TextField(
SizedBox(
width: MediaQuery.of(context).size.width*0.4,
child: PlatformTextField(
controller: descController,
maxLines: 10,
maxLength: 500,
decoration: const InputDecoration(
border: OutlineInputBorder(borderSide: BorderSide(color: Colors.blue, width: 1))
material: (_, __) => MaterialTextFieldData(
decoration: const InputDecoration(
border: OutlineInputBorder(borderSide: BorderSide(color: Colors.blue, width: 1))
),
),
),
)
],
)
),
),
ListTile(
title: Text("Oyun türü"),
trailing: DropdownButton(
value: selectedGameType,
onChanged: (GameType ?gameType){
setState(() {
selectedGameType = gameType!;
});
},
items: gameTypeList.map(
(e) => DropdownMenuItem(
child: Text(e == GameType.frp
? "FRP"
: e == GameType.boardGame
? "Kutu oyunu"
: e == GameType.tcg
? "TCG"
: "Hata"),
value: e,
Container(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Material(
child: Container(
width: MediaQuery.of(context).size.width*0.4,
alignment: Alignment.center,
color: CustomThemeData.backgroundColor,
child: PlatformText("Oyun türü"),
),
),
).toList(),
PlatformWidget(
material: (_, __) => Container(
width: MediaQuery.of(context).size.width*0.4,
child: DropdownButton(
value: selectedGameType,
onChanged: (GameType ?gameType){
setState(() {
selectedGameType = gameType!;
});
},
items: gameTypeList.map(
(e) => DropdownMenuItem(
child: Text(e == GameType.frp
? "FRP"
: e == GameType.boardGame
? "Kutu oyunu"
: e == GameType.tcg
? "TCG"
: "Hata"),
value: e,
),
).toList(),
),
),
cupertino: (_, __) => GestureDetector(
child: Material(
child: Container(
width: MediaQuery.of(context).size.width*0.4,
alignment: Alignment.center,
padding: const EdgeInsets.symmetric(horizontal: 30),
color: Colors.white,
child: Text(selectedGameType == GameType.frp
? "FRP"
: selectedGameType == GameType.boardGame
? "Kutu oyunu"
: selectedGameType == GameType.tcg
? "TCG"
: "Hata"),
),
),
onTap: () => cupertinoGameTypeSelector(context) ,
)
)
],
),
),
ListTile(
title: Text("Oyun Konumu"),
trailing: DropdownButton<String>(
value: selectedGameProvince,
onChanged: (String? gameProvince){
setState(() {
selectedGameProvince = gameProvince!;
});
},
items: gameProvinceList.map((e) => DropdownMenuItem(child: Text(e),value: e,)).toList(),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Material(
child: Container(
width: MediaQuery.of(context).size.width*0.4,
alignment: Alignment.center,
color: CustomThemeData.backgroundColor,
child: PlatformText("Oyun Konumu"),
),
),
PlatformWidget(
material:(_, __) => Container(
width: MediaQuery.of(context).size.width*0.4,
child: DropdownButton<String>(
value: selectedGameProvince,
onChanged: (String? gameProvince){
setState(() {
selectedGameProvince = gameProvince!;
});
},
items: gameProvinceList.map((e) => DropdownMenuItem(child: Text(e),value: e,)).toList(),
),
),
cupertino: (_,__) => GestureDetector(
child: Material(
child: Container(
width: MediaQuery.of(context).size.width*0.4,
alignment: Alignment.center,
padding: const EdgeInsets.symmetric(horizontal: 30),
color: Colors.white,
child: Text(selectedGameProvince),
),
),
onTap: () => cupertinoProvienceSelector() ,
)
)
],
),
ElevatedButton(
SizedBox(height:20,),
PlatformElevatedButton(
child: Text("Oluştur",style: TextStyle(color: Theme.of(context).scaffoldBackgroundColor),),
style: ElevatedButton.styleFrom(
primary: Theme.of(context).colorScheme.secondary,
color: Theme.of(context).colorScheme.secondary,
cupertino: (_, __) => CupertinoElevatedButtonData(
borderRadius: BorderRadius.circular(20)
),
onPressed: () async {
DialogUtils.createLoadingDialog(context, "Yükleniyor", "Oyun oluşturuluyor");
if(titleController.text.isNotEmpty && descController.text.isNotEmpty){
bool result = await gameGet.createGame(titleController.text, descController.text, selectedGameProvince, selectedGameType);
if(result){
Navigator.of(Get.overlayContext!).pop();
Navigator.of(Get.overlayContext!, rootNavigator: true).pop();
Get.back();
}else{
Navigator.of(Get.overlayContext!).pop();
Navigator.of(Get.overlayContext!, rootNavigator: true).pop();
Get.snackbar("Hata", "Bir hata oluştu");
}
}else{
Navigator.of(Get.overlayContext!).pop();
Navigator.of(Get.overlayContext!, rootNavigator: true).pop();
Get.snackbar("Hata", "Gerekli bilgileri doldurunuz lütfen");
}
},
Expand Down
Loading

0 comments on commit 59c3a75

Please sign in to comment.