Allow loading ssh keys from a file

Fixes #74
This commit is contained in:
Vishesh Handa
2020-10-02 17:18:42 +02:00
parent b3ea9c9565
commit d2b1ad7e46
5 changed files with 54 additions and 10 deletions

View File

@ -311,6 +311,7 @@ setup:
keyEditors:
public: Invalid Public Key - Doesn't start with ssh-rsa
private: Invalid Private Key
load: Load from File
sshKey:
generate: Generating SSH Key
title: In order to access this repository, this public key must be copied as a deploy key

View File

@ -1,5 +1,8 @@
- version: "1.71"
draft: true
improvements:
- text: "Allow SSH Keys to be loaded from the FS - #74"
image: ssh_key_file.jpeg
bugs:
- text: "Dark Theme: Render checkboxes in a lighter color"
- text: "Fix Relative Parent links not working - #256"

View File

@ -1,6 +1,11 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:file_picker/file_picker.dart';
import 'package:gitjournal/utils/logger.dart';
class PublicKeyEditor extends StatelessWidget {
final Key formKey;
@ -74,18 +79,45 @@ class KeyEditor extends StatelessWidget {
autovalidateMode: AutovalidateMode.onUserInteraction,
);
return SizedBox(
width: double.infinity,
height: 80.0,
child: Container(
color: Theme.of(context).buttonColor,
child: SingleChildScrollView(
child: Container(
padding: const EdgeInsets.all(8.0),
child: form,
var screenSize = MediaQuery.of(context).size;
return Column(
children: [
Container(
constraints: BoxConstraints(
maxHeight: screenSize.height / 4,
),
color: Theme.of(context).buttonColor,
child: SingleChildScrollView(
child: Container(
padding: const EdgeInsets.all(8.0),
child: form,
),
),
),
),
OutlineButton(
child: Text(tr("setup.keyEditors.load")),
onPressed: _pickAndLoadFile,
),
],
);
}
void _pickAndLoadFile() async {
var result = await FilePicker.platform.pickFiles();
if (result != null) {
var file = File(result.files.single.path);
try {
var data = await file.readAsString();
textEditingController.text = data.trim();
} catch (e, stackTrace) {
Log.e(
"Open File for importing SSH Key",
ex: e,
stacktrace: stackTrace,
);
}
}
}
}

View File

@ -241,6 +241,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.0-nullsafety.2"
file_picker:
dependency: "direct main"
description:
name: file_picker
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.6"
fimber:
dependency: "direct main"
description:

View File

@ -58,6 +58,7 @@ dependencies:
timeago: ^2.0.27
multicast_dns: ^0.2.2
bonsoir: ^0.1.2+2
file_picker: ^2.0.6
dev_dependencies:
flutter_launcher_icons: "^0.7.2"