diff --git a/README.md b/README.md index 588241a..0565b69 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # back4appgraphqldemo -Flutter-Back4app Connection Template +A new Flutter application. ## Getting Started diff --git a/ios/Flutter/Generated.xcconfig b/ios/Flutter/Generated.xcconfig index 4809c73..e228f26 100644 --- a/ios/Flutter/Generated.xcconfig +++ b/ios/Flutter/Generated.xcconfig @@ -1,6 +1,6 @@ // This is a generated file; do not edit or check into version control. FLUTTER_ROOT=C:\flutter -FLUTTER_APPLICATION_PATH=D:\AndroidStudioProjects\back4app_graphql_demo +FLUTTER_APPLICATION_PATH=D:\AndroidStudioProjects\back4app_graphql_demo - Copy FLUTTER_TARGET=lib\main.dart FLUTTER_BUILD_DIR=build SYMROOT=${SOURCE_ROOT}/../build\ios diff --git a/ios/Flutter/flutter_export_environment.sh b/ios/Flutter/flutter_export_environment.sh index 86147cb..e9a366a 100644 --- a/ios/Flutter/flutter_export_environment.sh +++ b/ios/Flutter/flutter_export_environment.sh @@ -1,7 +1,7 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. export "FLUTTER_ROOT=C:\flutter" -export "FLUTTER_APPLICATION_PATH=D:\AndroidStudioProjects\back4app_graphql_demo" +export "FLUTTER_APPLICATION_PATH=D:\AndroidStudioProjects\back4app_graphql_demo - Copy" export "FLUTTER_TARGET=lib\main.dart" export "FLUTTER_BUILD_DIR=build" export "SYMROOT=${SOURCE_ROOT}/../build\ios" diff --git a/lib/add_date-time.dart b/lib/add_date-time.dart new file mode 100644 index 0000000..ad56c10 --- /dev/null +++ b/lib/add_date-time.dart @@ -0,0 +1,106 @@ +import 'package:back4appgraphqldemo/database_utils.dart'; +import 'package:flutter/material.dart'; + +class AddDateTime extends StatefulWidget { + + @override + _AddDateTimeState createState() => _AddDateTimeState(); +} + +class _AddDateTimeState extends State { + TextEditingController dateTime = TextEditingController(); + DatabaseUtils utils = DatabaseUtils(); + TextEditingController objectIdController =TextEditingController(); + + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + appBar: AppBar( + title: Text('Complex Muatation'), + ), + body: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 8.0), + child: TextField( + decoration: InputDecoration( + filled: true, + fillColor: Colors.white, + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.yellow, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.blue, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + hintText: 'ObjectId of row', + ), + controller: objectIdController, + // onChanged: (text){}, + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 8.0), + child: TextField( + decoration: InputDecoration( + filled: true, + fillColor: Colors.white, + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.yellow, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.blue, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + hintText: 'Enter Date Time', + ), + // onChanged: (text){}, + controller: dateTime, + ), + ), + SizedBox( + height: 20.0, + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 15.0, vertical: 7.0), + child: FlatButton( + color: Colors.green, + onPressed: (){ + utils = DatabaseUtils(); + utils.addDateTime(objectIdController.text.trim(), + dateTime.text.trim() + ); + }, + child: Center( + child: Text( + 'Done', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ), + ), + + ], + ), + ), + ); + } +} diff --git a/lib/add_geopointer.dart b/lib/add_geopointer.dart new file mode 100644 index 0000000..82d3ee9 --- /dev/null +++ b/lib/add_geopointer.dart @@ -0,0 +1,138 @@ +import 'package:back4appgraphqldemo/database_utils.dart'; +import 'package:flutter/material.dart'; + +class AddGeoPointer extends StatefulWidget { + @override + _AddGeoPointerState createState() => _AddGeoPointerState(); +} + +class _AddGeoPointerState extends State { + DatabaseUtils utils; + + TextEditingController latitudeController = TextEditingController(); + + TextEditingController longitudeController = TextEditingController(); + + TextEditingController objectIdController = TextEditingController(); + + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + appBar: AppBar( + title: Text('Complex Muatation'), + ), + body: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 14.0, vertical: 8.0), + child: TextField( + controller: objectIdController, + decoration: InputDecoration( + filled: true, + fillColor: Colors.white, + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.yellow, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.blue, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + hintText: 'ObjectId of row', + ), + onChanged: (text) {}, + ), + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 14.0, vertical: 8.0), + child: TextField( + controller: latitudeController, + decoration: InputDecoration( + filled: true, + fillColor: Colors.white, + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.yellow, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.blue, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + hintText: 'Enter Latitude', + ), + onChanged: (text) {}, + ), + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 14.0, vertical: 8.0), + child: TextField( + controller: longitudeController, + decoration: InputDecoration( + filled: true, + fillColor: Colors.white, + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.yellow, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.blue, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + hintText: 'Enter Longitude', + ), + onChanged: (text) {}, + ), + ), + SizedBox( + height: 20.0, + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 15.0, vertical: 7.0), + child: FlatButton( + color: Colors.green, + onPressed: () { + utils = DatabaseUtils(); + utils.addGeoPointers( + objectIdController.text.trim(), + latitudeController.text.trim(), + longitudeController.text.trim()); + }, + child: Center( + child: Text( + 'Done', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/add_pointer.dart b/lib/add_pointer.dart new file mode 100644 index 0000000..55f9903 --- /dev/null +++ b/lib/add_pointer.dart @@ -0,0 +1,128 @@ +import 'package:back4appgraphqldemo/database_utils.dart'; +import 'package:flutter/material.dart'; + +class AddPointer extends StatefulWidget { + @override + _AddPointerState createState() => _AddPointerState(); +} + +class _AddPointerState extends State { + TextEditingController pointerController = TextEditingController(); + + TextEditingController objectIdController = TextEditingController(); + + DatabaseUtils utils; + + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + appBar: AppBar( + title: Text('Complex Muatation'), + ), + body: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 14.0, vertical: 8.0), + child: TextField( + controller: objectIdController, + decoration: InputDecoration( + filled: true, + fillColor: Colors.white, + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.yellow, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.blue, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + hintText: 'ObjectId of row', + ), + onChanged: (text) {}, + ), + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 14.0, vertical: 8.0), + child: TextField( + controller: pointerController, + decoration: InputDecoration( + filled: true, + fillColor: Colors.white, + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.yellow, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.blue, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + hintText: 'ObjectId of pointer', + ), + onChanged: (text) {}, + ), + ), + SizedBox( + height: 20.0, + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 15.0, vertical: 7.0), + child: FlatButton( + color: Colors.green, + onPressed: () { + utils = DatabaseUtils(); + utils.addPointers(objectIdController.text.trim(), + pointerController.text.trim()); + }, + child: Center( + child: Text( + 'Done', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ), + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 15.0, vertical: 7.0), + child: FlatButton( + color: Colors.green, + onPressed: () { + utils = DatabaseUtils(); + utils.deletePointers( + objectIdController.text.trim(), + pointerController.text.trim() + ); + }, + child: Center( + child: Text( + 'Delete', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/add_relation.dart b/lib/add_relation.dart new file mode 100644 index 0000000..f24f3b1 --- /dev/null +++ b/lib/add_relation.dart @@ -0,0 +1,122 @@ +import 'package:back4appgraphqldemo/database_utils.dart'; +import 'package:flutter/material.dart'; + +class AddRelation extends StatefulWidget { + + @override + _AddRelationState createState() => _AddRelationState(); +} + +class _AddRelationState extends State { + TextEditingController relationController = TextEditingController(); + + TextEditingController objectIdController = TextEditingController(); + + DatabaseUtils utils = DatabaseUtils(); + + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + appBar: AppBar( + title: Text('Complex Muatation'), + ), + body: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 8.0), + child: TextField( + controller: objectIdController, + decoration: InputDecoration( + filled: true, + fillColor: Colors.white, + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.yellow, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.blue, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + hintText: 'ObjectId of row', + ), + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 8.0), + child: TextField( + controller: relationController, + decoration: InputDecoration( + filled: true, + fillColor: Colors.white, + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.yellow, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.blue, + width: 2, + ), + borderRadius: BorderRadius.circular(15.0), + ), + hintText: 'ObjectId of Relation', + ), + onChanged: (text){}, + ), + ), + SizedBox( + height: 20.0, + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 15.0, vertical: 7.0), + child: FlatButton( + color: Colors.green, + onPressed: (){ + utils = DatabaseUtils(); + utils.addRelation(objectIdController.text.trim(),relationController.text.trim()); + }, + child: Center( + child: Text( + 'Done', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ), + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 15.0, vertical: 7.0), + child: FlatButton( + color: Colors.green, + onPressed: (){ + utils = DatabaseUtils(); + utils.deleteRelation(objectIdController.text.trim(),relationController.text.trim()); + }, + child: Center( + child: Text( + 'Delete', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/app_ui.dart b/lib/app_ui.dart index 48b509c..fbbddaa 100644 --- a/lib/app_ui.dart +++ b/lib/app_ui.dart @@ -1,3 +1,4 @@ +import 'package:back4appgraphqldemo/mutation_options.dart'; import 'package:back4appgraphqldemo/main.dart'; import 'package:flutter/material.dart'; @@ -31,19 +32,37 @@ class _AppUIState extends State { floatingActionButton: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ + FloatingActionButton( + heroTag: 'complex_mutation', + child: Text( + 'CM', + style: TextStyle( + color: Colors.white, + ), + ), + onPressed: () { + Navigator.of(context).push(MaterialPageRoute( + builder: (context)=>ComplexMutationPage() + ),); + }), + SizedBox( + width: 10.0, + ), FloatingActionButton( heroTag: 'query_page', - child: Text('Q', + child: Text( + 'Q', style: TextStyle( color: Colors.white, ), ), - onPressed: (){ - Navigator.pushReplacement(context, MaterialPageRoute( - builder: ((context){ - return MyApp(); - }) - )); + onPressed: () { + Navigator.pushReplacement( + context, + MaterialPageRoute(builder: ((context) { + return MyApp(); + }),), + ); }, ), ], diff --git a/lib/consonents.dart b/lib/constants.dart similarity index 66% rename from lib/consonents.dart rename to lib/constants.dart index 3fa9f1b..543321e 100644 --- a/lib/consonents.dart +++ b/lib/constants.dart @@ -2,5 +2,4 @@ import 'package:flutter/material.dart'; String kParseApplicationId= ""; String kParseClientKey = ""; -String kParseMasterKey = ""; -String kUrl= ""; +String kParseMasterKey = ""; \ No newline at end of file diff --git a/lib/database_utils.dart b/lib/database_utils.dart new file mode 100644 index 0000000..fc5b487 --- /dev/null +++ b/lib/database_utils.dart @@ -0,0 +1,123 @@ +import 'package:back4appgraphqldemo/graphql_configration.dart'; +import 'package:graphql_flutter/graphql_flutter.dart'; + +class DatabaseUtils{ + + final String langName,saveFormat,objectId; + + DatabaseUtils({this.langName="",this.saveFormat="",this.objectId=""}); + + String delete=''' + mutation DELETE_LANGUAGES(\$id: ID!){ + deleteLanguage(input: {id:\$id}){ + language{ + name, + id + } + } + } + '''; + + String addData=''' + mutation CREATE_LANGUAGES(\$input: CreateLanguageFieldsInput){ + createLanguage(input: {fields: \$input}){ + language{ + name, + saveFormat + } + } + } + '''; + String update=''' + mutation UPDATE_LANGUAGES(\$id: ID!,\$input: UpdateLanguageFieldsInput){ + updateLanguage(input: {id:\$id, fields:\$input}){ + language{ + name, + id + } + } + } + '''; + + Future sendData() async{ + + final variable ={ + "input":{ + "name" : langName, + "saveFormat" : saveFormat, + } + }; + print('sendingData'); + + GraphQlConfiguration configuration = GraphQlConfiguration(); + GraphQLClient client = configuration.clientToQuery(); + + QueryResult queryResult = await client.query( + QueryOptions(documentNode: gql(addData), variables: variable), + ); + return queryResult; + + } + Future updateData() async{ + final variable={ + "id":objectId, + "input":{ + "name" : langName + } + }; + + GraphQlConfiguration configuration = GraphQlConfiguration(); + GraphQLClient client = configuration.clientToQuery(); + + QueryResult queryResult = await client.query( + QueryOptions(documentNode: gql(update), variables: variable), + ); + return queryResult; + } + + + Future deleteData() async{ + final variable={ + "id":objectId, + }; + + GraphQlConfiguration configuration = GraphQlConfiguration(); + GraphQLClient client = configuration.clientToQuery(); + + QueryResult queryResult = await client.query( + QueryOptions(documentNode: gql(delete), variables: variable), + ); + + return queryResult; + } + + Future addPointers(String rowObjectId, String pointersId) async{ + print('addPointers'); + //code for add/update Pointers + } + + Future deletePointers(String rowObjectId, String pointersId) async{ + //code for delete Pointer. + print('delete Pinters'); + } + Future addRelation(String rowObjectId, String relationId) async{ + //code for add/update Relation. + print('addRelation'); + } + + Future deleteRelation(String rowObjectId, String relationId) async{ + print('deleteRelation'); + //code for delete Relation + } + + Future addGeoPointers(String rowObjectId, String latitude, String longitude) async{ + print('add GeoPointers'); + //code for add/update Geopointers + } + + Future addDateTime(String rowObjectId, String dateTime) async{ + print('addDateTime'); + //code for add/update date-time + } + +} \ No newline at end of file diff --git a/lib/graphql_configration.dart b/lib/graphql_configration.dart index 552226e..5c4ead0 100644 --- a/lib/graphql_configration.dart +++ b/lib/graphql_configration.dart @@ -1,8 +1,8 @@ -import 'package:back4appgraphqldemo/consonents.dart'; +import 'package:back4appgraphqldemo/constants.dart'; import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; -import 'consonents.dart'; +import 'constants.dart'; class GraphQlConfiguration { diff --git a/lib/main.dart b/lib/main.dart index a1fd3cc..267bda1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,8 @@ +import 'package:back4appgraphqldemo/mutation_page.dart'; import 'package:flutter/material.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; -import 'consonents.dart'; +import 'constants.dart'; +import 'dart:ui'; void main() { runApp(MyApp()); @@ -9,27 +11,124 @@ void main() { class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { + final HttpLink httpLink = HttpLink( + uri: 'https://parseapi.back4app.com/graphql', + headers: { + 'X-Parse-Application-Id': kParseApplicationId, + 'X-Parse-Client-Key': kParseClientKey, + 'X-Parse-Master-Key': kParseMasterKey, + //'X-Parse-REST-API-Key' : kParseRestApiKey, + }, //getheaders() + ); + + ValueNotifier client = ValueNotifier( + GraphQLClient( + cache: OptimisticCache(dataIdFromObject: typenameDataIdFromObject), + link: httpLink, + ), + ); + return MaterialApp( - home: MyHomePage(), + home: GraphQLProvider( + child: MyHomePage(), + client: client, + ), ); } } + class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { + String name; + String saveFormat; + String objectId; + + String query = ''' + query FindLanguages{ + languages{ + count, + edges{ + node{ + name, + saveFormat + } + } + } +} + '''; @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( appBar: AppBar( - title: Text('Parsing data using GraphQL', + title: Text( + 'Parsing data using GraphQL', + ), + ), + floatingActionButton: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + FloatingActionButton( + heroTag: 'mutation_page', + child: Text('M', + style: TextStyle( + color: Colors.white, + ), + ), + onPressed: (){ + Navigator.pushReplacement(context, MaterialPageRoute( + builder: ((context){ + return MutationPage(); + }) + )); + }, + ), + ], + ), + body: Query( + options: QueryOptions( + documentNode: gql(query), ), + builder: ( + QueryResult result, { + Refetch refetch, + FetchMore fetchMore, + }) { + if (result.data == null) { + return Center( + child: Text( + "Loading...", + style: TextStyle(fontSize: 20.0), + )); + } else if(result.data.isEmpty){ + return Center( + child: Text( + "No data available", + style: TextStyle(fontSize: 20.0), + )); + } + else { + return ListView.builder( + itemBuilder: (BuildContext context, int index) { + return ListTile( + title: Text(result.data["languages"]["edges"][index]["node"] + ['name']), + trailing: Text(result.data["languages"]["edges"][index] + ["node"]['saveFormat']), + + ); + }, + itemCount: result.data["languages"]["edges"].length, + ); + } + }, ), - body: Container(), - ),); + ), + ); } } diff --git a/lib/mutation_options.dart b/lib/mutation_options.dart new file mode 100644 index 0000000..a1a00f1 --- /dev/null +++ b/lib/mutation_options.dart @@ -0,0 +1,102 @@ +import 'package:back4appgraphqldemo/add_geopointer.dart'; +import 'package:back4appgraphqldemo/add_pointer.dart'; +import 'package:back4appgraphqldemo/add_relation.dart'; +import 'package:flutter/material.dart'; + +import 'add_date-time.dart'; + +class ComplexMutationPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + appBar: AppBar( + title: Text('Complex Muatation'), + ), + body: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: EdgeInsets.all(15.0), + child: FlatButton( + color: Colors.green, + onPressed: (){ + Navigator.of(context).push(MaterialPageRoute( + builder: (context)=>AddPointer() + ),); + }, + child: Center( + child: Text( + 'Add Pointers', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ), + ), + Padding( + padding: EdgeInsets.all(15.0), + child: FlatButton( + color: Colors.green, + onPressed: (){ + Navigator.of(context).push(MaterialPageRoute( + builder: (context)=>AddRelation() + ),); + }, + child: Center( + child: Text( + 'Add Relation', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ), + ), + + Padding( + padding: EdgeInsets.all(15.0), + child: FlatButton( + color: Colors.green, + onPressed: (){ + Navigator.of(context).push(MaterialPageRoute( + builder: (context)=>AddGeoPointer() + ),); + }, + child: Center( + child: Text( + 'Add Geopointers', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ), + ), + Padding( + padding: EdgeInsets.all(15.0), + child: FlatButton( + color: Colors.green, + onPressed: (){ + Navigator.of(context).push(MaterialPageRoute( + builder: (context)=>AddDateTime() + ),); + }, + child: Center( + child: Text( + 'Add Date-time', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ), + ), + + ], + ), + ), + ); + } +} diff --git a/lib/mutation_page.dart b/lib/mutation_page.dart new file mode 100644 index 0000000..3bccc1b --- /dev/null +++ b/lib/mutation_page.dart @@ -0,0 +1,52 @@ +import 'package:back4appgraphqldemo/app_ui.dart'; +import 'package:back4appgraphqldemo/database_utils.dart'; +import 'package:flutter/material.dart'; + +class MutationPage extends StatelessWidget { + + String langName,saveFormat,objectId; + DatabaseUtils utils; + + @override + Widget build(BuildContext context) { + return AppUI( + onChangedName: (text){ + langName=text; + }, + onChangedSaveFormat: (text){ + saveFormat=text; + }, + onChangedObjectId: (text){ + objectId=text; + }, + + sendDataButtonPressed: (){ + if(langName.isNotEmpty && saveFormat.isNotEmpty){ + utils = DatabaseUtils( + langName: langName, + saveFormat: saveFormat , + ); + utils.sendData(); + } + }, + deleteDataButtonPressed: (){ + if(objectId.isNotEmpty){ + utils = DatabaseUtils( + objectId: objectId, + ); + utils.deleteData(); + } + }, + updateButtonPressed: (){ + if(langName.isNotEmpty && saveFormat.isNotEmpty && objectId.isNotEmpty){ + utils = DatabaseUtils( + langName: langName, + saveFormat: saveFormat , + objectId: objectId + ); + utils.updateData(); + } + }, + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 03b9212..3083025 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.2" + version: "2.5.0-nullsafety.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.0-nullsafety.3" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.2.0-nullsafety.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.1.0-nullsafety.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.13" + version: "1.15.0-nullsafety.3" connectivity: dependency: transitive description: @@ -98,7 +98,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" file: dependency: transitive description: @@ -169,14 +169,14 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.10-nullsafety.1" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0-nullsafety.3" mime: dependency: transitive description: @@ -190,7 +190,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.1" path_provider: dependency: transitive description: @@ -272,49 +272,49 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.5" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0-nullsafety.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" + version: "0.2.19-nullsafety.2" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0-nullsafety.3" uuid_enhanced: dependency: transitive description: @@ -328,7 +328,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0-nullsafety.3" websocket: dependency: transitive description: @@ -344,5 +344,5 @@ packages: source: hosted version: "0.1.0" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" + dart: ">=2.10.0-110 <2.11.0" flutter: ">=1.12.13+hotfix.5 <2.0.0"