2022-09-24 20:46:37 +02:00
|
|
|
import 'package:antd_mobile/antd_mobile.dart';
|
2021-01-10 07:20:03 +01:00
|
|
|
import 'package:flutter/cupertino.dart';
|
2022-09-22 19:50:45 +02:00
|
|
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
2021-01-10 07:20:03 +01:00
|
|
|
import 'package:git_touch/models/auth.dart';
|
|
|
|
import 'package:git_touch/models/gitea.dart';
|
|
|
|
import 'package:git_touch/scaffolds/common.dart';
|
|
|
|
import 'package:git_touch/utils/utils.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
class GtIssueFormScreen extends StatefulWidget {
|
2022-09-21 18:28:21 +02:00
|
|
|
const GtIssueFormScreen(this.owner, this.name);
|
2021-01-10 07:20:03 +01:00
|
|
|
final String owner;
|
|
|
|
final String name;
|
|
|
|
|
|
|
|
@override
|
2022-10-03 19:05:29 +02:00
|
|
|
State<GtIssueFormScreen> createState() => _GtIssueFormScreenState();
|
2021-01-10 07:20:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
class _GtIssueFormScreenState extends State<GtIssueFormScreen> {
|
|
|
|
var _title = '';
|
|
|
|
var _body = '';
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final auth = Provider.of<AuthModel>(context);
|
|
|
|
return CommonScaffold(
|
2021-06-17 05:02:41 +02:00
|
|
|
title: Text(AppLocalizations.of(context)!.submitAnIssue),
|
2021-01-10 07:20:03 +01:00
|
|
|
body: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Padding(
|
|
|
|
padding: CommonStyle.padding,
|
|
|
|
child: CupertinoTextField(
|
2022-09-24 20:46:37 +02:00
|
|
|
style: TextStyle(color: AntTheme.of(context).colorText),
|
2021-06-17 05:02:41 +02:00
|
|
|
placeholder: AppLocalizations.of(context)!.title,
|
2021-01-10 07:20:03 +01:00
|
|
|
onChanged: (v) {
|
|
|
|
setState(() {
|
|
|
|
_title = v;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: CommonStyle.padding,
|
|
|
|
child: CupertinoTextField(
|
2022-09-24 20:46:37 +02:00
|
|
|
style: TextStyle(color: AntTheme.of(context).colorText),
|
2021-06-17 05:02:41 +02:00
|
|
|
placeholder: AppLocalizations.of(context)!.body,
|
2021-01-10 07:20:03 +01:00
|
|
|
onChanged: (v) {
|
|
|
|
setState(() {
|
|
|
|
_body = v;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
maxLines: 10,
|
|
|
|
),
|
|
|
|
),
|
2022-10-04 19:51:53 +02:00
|
|
|
AntButton(
|
|
|
|
color: AntTheme.of(context).colorPrimary,
|
2021-06-17 05:02:41 +02:00
|
|
|
child: Text(AppLocalizations.of(context)!.submit),
|
2022-10-04 19:51:53 +02:00
|
|
|
onClick: () async {
|
2021-01-30 08:42:02 +01:00
|
|
|
await auth.fetchGitea(
|
2021-01-10 07:20:03 +01:00
|
|
|
'/repos/${widget.owner}/${widget.name}/issues',
|
|
|
|
requestType: 'POST',
|
|
|
|
body: {'body': _body, 'title': _title},
|
|
|
|
).then((v) {
|
|
|
|
return GiteaIssue.fromJson(v);
|
|
|
|
});
|
|
|
|
Navigator.pop(context);
|
2022-09-22 19:50:45 +02:00
|
|
|
await context.pushUrl(
|
2021-01-10 07:20:03 +01:00
|
|
|
'/gitea/${widget.owner}/${widget.name}/issues',
|
|
|
|
replace: true,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|