From a3b25c3ee116a5e3da6b868e8757ea25b5599f4a Mon Sep 17 00:00:00 2001 From: "Florian RICHER (MrDev023)" Date: Wed, 30 Mar 2022 23:45:27 +0200 Subject: [PATCH] Add link --- lib/widgets/components/link.dart | 5 +++-- lib/widgets/components/tutorials/step3.dart | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/widgets/components/link.dart b/lib/widgets/components/link.dart index af35362..cb0b56d 100644 --- a/lib/widgets/components/link.dart +++ b/lib/widgets/components/link.dart @@ -2,16 +2,17 @@ import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; class Link extends StatelessWidget { - const Link({Key? key, required this.uri}) : super(key: key); + const Link({Key? key, required this.uri, this.label}) : super(key: key); final String uri; + final String? label; @override Widget build(BuildContext context) { return MouseRegion( cursor: SystemMouseCursors.click, child: GestureDetector( - child: Text(uri, + child: Text(label ?? uri, style: const TextStyle(decoration: TextDecoration.underline)), onTap: () { launch(uri); diff --git a/lib/widgets/components/tutorials/step3.dart b/lib/widgets/components/tutorials/step3.dart index 84ec0dd..5f26424 100644 --- a/lib/widgets/components/tutorials/step3.dart +++ b/lib/widgets/components/tutorials/step3.dart @@ -1,21 +1,25 @@ import 'dart:io'; -import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:desktopapp/widgets/components/link.dart' as link; class Step3 extends StatelessWidget { const Step3({Key? key}) : super(key: key); Widget buildContent(BuildContext context, SharedPreferences prefs) { + var clientId = prefs.getString('client_id'); return Column(children: [ const Padding( padding: EdgeInsets.symmetric(vertical: 20), child: Text('Étape 3:Authorisation de l\'application', style: TextStyle(fontSize: 20)), ), - const Text( - 'Pour pouvoir utiliser l\'application, il faut récupérer les clefs associées à l\'application créée juste avant.'), + link.Link( + uri: + 'https://streamlabs.com/api/v1.0/authorize?redirect_uri=http://localhost:1234/&client_id=$clientId&response_type=code&scope=alerts.create', + label: 'Cliquez ici pour vous connecter à Streamlabs', + ) ]); } @@ -36,6 +40,17 @@ class Step3 extends StatelessWidget { ..headers.contentType = ContentType.text ..write('You can close tab now') ..close(); + + // SEND TOKEN ASK TO API + // POST https://streamlabs.com/api/v1.0/token + // { + // "grant_type": "authorization_code", + // "code": "CODE", + // "redirect_uri": "http://localhost:1234/", + // "client_id": "CLIENT_ID", + // "client_secret": "CLIENT_SECRET" + // } + // SAVE RESPONSE TOKEN AS CREDENTIALS IN SHARED PREFERENCES } @override