From 32a32224caac2445f1c119901cdcf3651a434764 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 2 Nov 2019 18:16:16 +0100 Subject: [PATCH] Can open Term Of Service from Create Account Page. --- lib/main_dev.dart | 12 +++++++----- lib/models/config.dart | 19 +++++++++++-------- lib/ui/routes/create_account_route.dart | 10 ++++++++++ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/lib/main_dev.dart b/lib/main_dev.dart index 5a819cf..944fc48 100644 --- a/lib/main_dev.dart +++ b/lib/main_dev.dart @@ -7,11 +7,13 @@ import 'package:comunic/models/config.dart'; void main() { Config.set(Config( - apiServerName: "devweb.local", - apiServerUri: "/comunic/api/", - apiServerSecure: false, - serviceName: "ComunicFlutter", - serviceToken: "G9sZCBmb3IgVWJ1bnR1CkNvbW1lbnRbbmVdPeCkieCkrOCkq")); + apiServerName: "devweb.local", + apiServerUri: "/comunic/api/", + apiServerSecure: false, + serviceName: "ComunicFlutter", + serviceToken: "G9sZCBmb3IgVWJ1bnR1CkNvbW1lbnRbbmVdPeCkieCkrOCkq", + termOfServicesURL: "http://devweb.local/comunic/current/about.php?cgu", + )); subMain(); } diff --git a/lib/models/config.dart b/lib/models/config.dart index 249468b..fdac4af 100644 --- a/lib/models/config.dart +++ b/lib/models/config.dart @@ -11,18 +11,21 @@ class Config { final bool apiServerSecure; final String serviceName; final String serviceToken; + final String termOfServicesURL; - const Config( - {@required this.apiServerName, - @required this.apiServerUri, - @required this.apiServerSecure, - @required this.serviceName, - @required this.serviceToken}) - : assert(apiServerName != null), + const Config({ + @required this.apiServerName, + @required this.apiServerUri, + @required this.apiServerSecure, + @required this.serviceName, + @required this.serviceToken, + @required this.termOfServicesURL, + }) : assert(apiServerName != null), assert(apiServerUri != null), assert(apiServerSecure != null), assert(serviceName != null), - assert(serviceToken != null); + assert(serviceToken != null), + assert(termOfServicesURL != null); /// Get and set static configuration static Config _config; diff --git a/lib/ui/routes/create_account_route.dart b/lib/ui/routes/create_account_route.dart index aa2dfe0..d9450c3 100644 --- a/lib/ui/routes/create_account_route.dart +++ b/lib/ui/routes/create_account_route.dart @@ -1,6 +1,8 @@ +import 'package:comunic/models/config.dart'; import 'package:comunic/utils/input_utils.dart'; import 'package:comunic/utils/intl_utils.dart'; import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; /// Create account route /// @@ -132,6 +134,10 @@ class __CreateAccountRouteBodyState extends State<_CreateAccountRouteBody> { ) : null, controlAffinity: ListTileControlAffinity.leading, + secondary: IconButton( + icon: Icon(Icons.open_in_new), + onPressed: _openTOS, + ), ), // Submit button @@ -161,6 +167,10 @@ class __CreateAccountRouteBodyState extends State<_CreateAccountRouteBody> { return; } } + + void _openTOS() { + launch(config().termOfServicesURL); + } } class _InputEntry extends StatelessWidget {