mirror of
https://github.com/git-touch/git-touch
synced 2025-02-22 14:27:46 +01:00
feat: gitlab login by token
This commit is contained in:
parent
9c0b0f64c4
commit
2b6d45c457
@ -132,11 +132,50 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
),
|
||||||
|
_buildAddItem(
|
||||||
|
text: 'GitLab Account by Token',
|
||||||
|
onTap: () async {
|
||||||
|
var result =
|
||||||
|
await Provider.of<ThemeModel>(context).showConfirm(
|
||||||
|
context,
|
||||||
|
Column(
|
||||||
|
children: <Widget>[
|
||||||
|
CupertinoTextField(
|
||||||
|
placeholder: 'Access token',
|
||||||
|
onChanged: (v) {
|
||||||
|
setState(() {
|
||||||
|
_token = v;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'GitTouch needs these permissions',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14, fontWeight: FontWeight.w400),
|
||||||
|
),
|
||||||
|
SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'api, read_user, read_repository',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16, color: PrimerColors.blue500),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (result == true) {
|
||||||
|
try {
|
||||||
|
await auth.loginToGitlab(
|
||||||
|
'https://gitlab.com', _token);
|
||||||
|
// TODO: Custom domain
|
||||||
|
} catch (err) {
|
||||||
|
Provider.of<ThemeModel>(context).showConfirm(
|
||||||
|
context, Text('Token invalid: $err'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
)
|
)
|
||||||
// _buildAddItem(
|
|
||||||
// text: 'GitLab Account',
|
|
||||||
// screenBuilder: (_) => LoginGitlabScreen(),
|
|
||||||
// )
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:git_touch/models/auth.dart';
|
|
||||||
import 'package:git_touch/scaffolds/single.dart';
|
|
||||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
class LoginGitlabScreen extends StatefulWidget {
|
|
||||||
@override
|
|
||||||
_LoginGitlabScreenState createState() => _LoginGitlabScreenState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _LoginGitlabScreenState extends State<LoginGitlabScreen> {
|
|
||||||
String _token;
|
|
||||||
String _domain;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SingleScaffold(
|
|
||||||
title: AppBarTitle('Login to GitLab'),
|
|
||||||
body: Column(
|
|
||||||
children: <Widget>[
|
|
||||||
TextField(
|
|
||||||
// decoration: InputDecoration(icon: Icon(Icons.more_vert)),
|
|
||||||
onChanged: (value) {
|
|
||||||
_domain = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TextField(
|
|
||||||
onChanged: (value) {
|
|
||||||
_token = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
MaterialButton(
|
|
||||||
child: Text('Login'),
|
|
||||||
onPressed: () {
|
|
||||||
Provider.of<AuthModel>(context).loginToGitlab(_domain, _token);
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user