git-touch-android-ios-app/lib/screens/gh_issue_form.dart

77 lines
2.2 KiB
Dart
Raw Normal View History

2019-10-03 06:16:44 +02:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
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:github/github.dart';
2019-10-03 06:16:44 +02:00
import 'package:provider/provider.dart';
2020-02-07 07:17:05 +01:00
class GhIssueFormScreen extends StatefulWidget {
2019-10-03 06:16:44 +02:00
final String owner;
final String name;
2020-02-07 07:17:05 +01:00
GhIssueFormScreen(this.owner, this.name);
2019-10-03 06:16:44 +02:00
@override
2020-02-07 07:17:05 +01:00
_GhIssueFormScreenState createState() => _GhIssueFormScreenState();
2019-10-03 06:16:44 +02:00
}
2020-02-07 07:17:05 +01:00
class _GhIssueFormScreenState extends State<GhIssueFormScreen> {
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 {
final slug = RepositorySlug(widget.owner, widget.name);
2020-10-04 14:37:23 +02:00
final res = await context
.read<AuthModel>()
2021-06-14 08:56:42 +02:00
.ghClient
2020-10-04 14:37:23 +02:00
.issues
.create(slug, IssueRequest(title: _title, body: _body));
2020-01-07 11:33:41 +01:00
await theme.push(
context,
'/github/${widget.owner}/${widget.name}/issues/${res.number}',
2020-01-07 11:33:41 +01:00
replace: true,
);
2019-10-03 06:16:44 +02:00
},
),
],
),
);
}
}