1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-18 19:22:54 +01:00
git-touch-android-ios-app/lib/screens/issue_form.dart

83 lines
2.6 KiB
Dart
Raw Normal View History

2019-10-03 06:16:44 +02:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
2020-01-07 11:33:41 +01:00
import 'package:git_touch/graphql/gh.dart';
2019-10-03 06:16:44 +02:00
import 'package:git_touch/models/auth.dart';
import 'package:git_touch/models/theme.dart';
import 'package:git_touch/scaffolds/common.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:provider/provider.dart';
class IssueFormScreen extends StatefulWidget {
final String owner;
final String name;
IssueFormScreen(this.owner, this.name);
@override
_IssueFormScreenState createState() => _IssueFormScreenState();
}
class _IssueFormScreenState extends State<IssueFormScreen> {
2020-01-07 11:33:41 +01:00
var _title = '';
var _body = '';
2019-10-03 06:16:44 +02:00
@override
Widget build(BuildContext context) {
2020-02-01 10:18:21 +01:00
final theme = Provider.of<ThemeModel>(context);
2019-10-03 06:16:44 +02:00
return CommonScaffold(
title: Text('Submit an issue'),
body: Column(
children: <Widget>[
Padding(
padding: CommonStyle.padding,
child: CupertinoTextField(
2020-02-01 10:18:21 +01:00
style: TextStyle(color: theme.palette.text),
2019-10-03 06:16:44 +02:00
placeholder: 'Title',
onChanged: (v) {
setState(() {
_title = v;
});
},
),
),
Padding(
padding: CommonStyle.padding,
child: CupertinoTextField(
2020-02-01 10:18:21 +01:00
style: TextStyle(color: theme.palette.text),
2019-10-03 06:16:44 +02:00
placeholder: 'Body',
onChanged: (v) {
setState(() {
_body = v;
});
},
2019-10-03 06:57:21 +02:00
maxLines: 10,
2019-10-03 06:16:44 +02:00
),
),
2019-10-03 06:57:21 +02:00
CupertinoButton.filled(
2019-10-03 06:16:44 +02:00
child: Text('Submit'),
onPressed: () async {
2020-01-07 11:33:41 +01:00
final auth = Provider.of<AuthModel>(context);
final theme = Provider.of<ThemeModel>(context);
final r0 = await auth.gqlClient.execute(
GhRepoIdQuery(
variables:
GhRepoIdArguments(owner: widget.owner, name: widget.name),
),
);
final res = await auth.gqlClient.execute(GhCreateIssueQuery(
variables: GhCreateIssueArguments(
repoId: r0.data.repository.id, title: _title, body: _body),
));
final issue = res.data.createIssue.issue;
await theme.push(
context,
'/${issue.repository.owner.login}/${issue.repository.name}/issues/${issue.number}',
replace: true,
);
2019-10-03 06:16:44 +02:00
},
),
],
),
);
}
}