diff --git a/lib/main.dart b/lib/main.dart index 0dd940c..d6bbcdf 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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'; @@ -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(), + ), ); } } diff --git a/lib/screen/create_game_screen.dart b/lib/screen/create_game_screen.dart index c666f81..95c992c 100644 --- a/lib/screen/create_game_screen.dart +++ b/lib/screen/create_game_screen.dart @@ -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 { @@ -18,7 +21,7 @@ class _CreateGameScreenState extends State { GameGet gameGet = Get.put(GameGet()); TextEditingController titleController = TextEditingController(); TextEditingController descController = TextEditingController(); - List gameTypeList = GameType.values; + List gameTypeList = GameType.values.sublist(0,3); late GameType selectedGameType; List gameProvinceList= UtilData.provienceList; late String selectedGameProvince; @@ -32,9 +35,69 @@ class _CreateGameScreenState extends State { @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( @@ -42,7 +105,7 @@ class _CreateGameScreenState extends State { child: NotificationListener( onNotification: (overScroll){ overScroll.disallowGlow(); - return false; + return true; }, child: SingleChildScrollView( child: Column( @@ -53,89 +116,178 @@ class _CreateGameScreenState extends State { 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( - 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( + 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"); } }, diff --git a/lib/screen/game_detail_screen.dart b/lib/screen/game_detail_screen.dart index 85ad662..4f26e6a 100644 --- a/lib/screen/game_detail_screen.dart +++ b/lib/screen/game_detail_screen.dart @@ -4,6 +4,7 @@ import 'package:findgamemates/theme_data.dart'; import 'package:findgamemates/view/game_detail_comments.dart'; import 'package:findgamemates/view/game_detail_input.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; import 'package:intl/intl.dart'; class GameDetailScreen extends StatefulWidget { @@ -46,9 +47,16 @@ class _GameDetailScreenState extends State { @override Widget build(BuildContext context) { - return Scaffold( + return PlatformScaffold( key: widget.key, - appBar: AppBar(title: Text(widget.gamePost.title),), + appBar: PlatformAppBar( + title: Text(widget.gamePost.title, style: TextStyle(color: Colors.white),), + cupertino: (_, __) => CupertinoNavigationBarData( + backgroundColor: CustomThemeData.primaryColor, + brightness: Brightness.dark, + noMaterialParent: true + ), + ), body: SafeArea( child: Padding( padding: const EdgeInsets.all(8.0), @@ -59,12 +67,14 @@ class _GameDetailScreenState extends State { }, child: ListView( children: [ - Text( - widget.gamePost.title, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 22, - color: CustomThemeData.primaryAccentColor, + Material( + child: PlatformText( + widget.gamePost.title, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 22, + color: CustomThemeData.primaryAccentColor, + ), ), ), const Divider(), diff --git a/lib/screen/main_screen.dart b/lib/screen/main_screen.dart index ae4428f..a918b80 100644 --- a/lib/screen/main_screen.dart +++ b/lib/screen/main_screen.dart @@ -22,7 +22,7 @@ class _MainScreenState extends State with TickerProviderStateMixin { late TabController tabController; UserDatabase userDatabase = Get.put(UserDatabase()); UserGet userGet = Get.put(UserGet()); - int iosTabBarIndex = 0; + int iosTabBarIndex = 1; @override void initState() { @@ -41,6 +41,9 @@ class _MainScreenState extends State with TickerProviderStateMixin { style: TextStyle(color: Colors.white), ), backgroundColor: CustomThemeData.primaryColor, + cupertino: (_, __) => CupertinoNavigationBarData( + brightness: Brightness.dark + ), ), body: SafeArea( child: tabController.index == 0 diff --git a/lib/utils/dialog_utils.dart b/lib/utils/dialog_utils.dart index 531dbc0..5814c69 100644 --- a/lib/utils/dialog_utils.dart +++ b/lib/utils/dialog_utils.dart @@ -1,38 +1,73 @@ +import 'dart:io'; + import 'package:findgamemates/theme_data.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; import 'package:get/get.dart'; import 'package:loading_indicator/loading_indicator.dart'; class DialogUtils{ static void createLoadingDialog(BuildContext context, String title, String desc){ - Get.defaultDialog( - title: title, - titleStyle: TextStyle( - color: CustomThemeData.cardColor, - fontWeight: FontWeight.bold - ), - barrierDismissible: false, - content: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - SizedBox( - width: MediaQuery.of(context).size.width * 0.2, - height: MediaQuery.of(context).size.height * 0.1, - child: LoadingIndicator( - indicatorType: Indicator.ballPulseRise, - colors: [ - CustomThemeData.primaryColor, - CustomThemeData.accentColor, - CustomThemeData.cardColor + if(Platform.isAndroid){ + Get.defaultDialog( + title: title, + titleStyle: TextStyle( + color: CustomThemeData.cardColor, + fontWeight: FontWeight.bold + ), + barrierDismissible: false, + content: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + SizedBox( + width: MediaQuery.of(context).size.width * 0.2, + height: MediaQuery.of(context).size.height * 0.1, + child: LoadingIndicator( + indicatorType: Indicator.ballPulseRise, + colors: [ + CustomThemeData.primaryColor, + CustomThemeData.accentColor, + CustomThemeData.cardColor + ], + ), + ), + const SizedBox(width: 20,), + Flexible(child: Text(desc)), + ], + ), + ); + }else if(Platform.isIOS){ + showCupertinoDialog( + context: context, + builder: (_) { + return CupertinoAlertDialog( + title: PlatformText(title), + content: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + SizedBox( + width: MediaQuery.of(context).size.width * 0.2, + height: MediaQuery.of(context).size.height * 0.1, + child: LoadingIndicator( + indicatorType: Indicator.ballPulseRise, + colors: [ + CustomThemeData.primaryColor, + CustomThemeData.accentColor, + CustomThemeData.cardColor + ], + ), + ), + const SizedBox(width: 20,), + Flexible(child: PlatformText(desc)), ], ), - ), - const SizedBox(width: 20,), - Flexible(child: Text(desc)), - ], - ), - ); + ); + } + ); + } + } } \ No newline at end of file diff --git a/lib/view/game_detail_input.dart b/lib/view/game_detail_input.dart index c6fe468..afa2b37 100644 --- a/lib/view/game_detail_input.dart +++ b/lib/view/game_detail_input.dart @@ -1,6 +1,7 @@ import 'package:findgamemates/get/game_get.dart'; import 'package:findgamemates/model/game_comment.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; import 'package:get/get.dart'; class GameDetailInput extends StatefulWidget { @@ -28,13 +29,18 @@ class _GameDetailInputState extends State { flex: 10, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 12), - child: TextField( + child: PlatformTextField( controller: inputController, keyboardType: TextInputType.multiline, maxLines: null, - decoration: const InputDecoration( - hintText: "Yorum", - border: OutlineInputBorder() + material: (_, __) => MaterialTextFieldData( + decoration: const InputDecoration( + hintText: "Yorum", + border: OutlineInputBorder() + ), + ), + cupertino: (_, __) => CupertinoTextFieldData( + placeholder: "Yorum" ), ), ), diff --git a/lib/view/game_screen_filter.dart b/lib/view/game_screen_filter.dart index 494ef74..9b31d4d 100644 --- a/lib/view/game_screen_filter.dart +++ b/lib/view/game_screen_filter.dart @@ -3,6 +3,7 @@ import 'package:findgamemates/model/game_types.dart'; import 'package:findgamemates/theme_data.dart'; import 'package:findgamemates/utils/utils_data.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; import 'package:get/get.dart'; class GameScreenFilter extends StatefulWidget { @@ -33,11 +34,17 @@ class _GameScreenFilterState extends State { children: [ Padding( padding: const EdgeInsets.only(left: 6,right: 6,top: 6), - child: TextField( - decoration: const InputDecoration( - hintText: "Arama", - suffixIcon: Icon(Icons.search), - border: OutlineInputBorder() + child: PlatformTextField( + material: (_, __) => MaterialTextFieldData( + decoration: const InputDecoration( + hintText: "Arama", + suffixIcon: Icon(Icons.search), + border: OutlineInputBorder() + ), + ), + cupertino: (_, __) => CupertinoTextFieldData( + placeholder: "Arama", + suffix: Icon(Icons.search) ), onChanged: (value){ currFilter = value; diff --git a/pubspec.lock b/pubspec.lock index f241ffb..3e282ab 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "32.0.0" + version: "33.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.1.0" args: dependency: transitive description: @@ -91,7 +91,7 @@ packages: name: built_value url: "https://pub.dartlang.org" source: hosted - version: "8.1.3" + version: "8.1.4" characters: dependency: transitive description: