Remote Settings: Display the git host

This commit is contained in:
Vishesh Handa
2020-11-09 12:25:24 +01:00
parent aaf96c82d1
commit 7fc6847933
4 changed files with 29 additions and 0 deletions

View File

@ -45,6 +45,7 @@ settings:
cancel: Cancel
title: Git Remote Settings
subtitle: Configure where your notes are synced
host: Git Host
noteMetaData:
title: Note Metadata Settings
subtitle: Configure how the Note Metadata is saved

View File

@ -11,6 +11,7 @@
- text: "Custom SSH keys with passwords can now be used - #227"
- text: "Create new note when clicking on non existing Wiki Link - #240"
- text: "Debug Screen: Add a button to easily copy all the logs"
- text: "Git Remote Settings: Expose the git host"
bugs:
- text: "Fix notes not always showing up - #270"

View File

@ -517,6 +517,11 @@ class Repository with ChangeNotifier {
await repo.checkout(note.filePath);
return note.load();
}
Future<List<GitRemoteConfig>> remoteConfigs() async {
var repo = await GitRepository.load(repoPath);
return repo.config.remotes;
}
}
Future<void> _copyDirectory(String source, String destination) async {

View File

@ -28,13 +28,35 @@ class GitRemoteSettingsScreen extends StatefulWidget {
}
class _GitRemoteSettingsScreenState extends State<GitRemoteSettingsScreen> {
String remoteHost;
@override
Widget build(BuildContext context) {
var textTheme = Theme.of(context).textTheme;
var settings = Provider.of<Settings>(context);
var repo = Provider.of<Repository>(context);
if (remoteHost == null) {
remoteHost = "";
repo.remoteConfigs().then((list) {
setState(() {
if (!mounted) return;
remoteHost = list.first.url;
});
});
}
var body = Column(
children: <Widget>[
if (remoteHost != null && remoteHost.isNotEmpty)
Text(
tr('settings.gitRemote.host'),
style: textTheme.bodyText1,
textAlign: TextAlign.left,
),
if (remoteHost != null && remoteHost.isNotEmpty)
ListTile(title: Text(remoteHost)),
const SizedBox(height: 16.0),
Text(
tr('setup.sshKeyUserProvided.public'),
style: textTheme.bodyText1,