diff --git a/lib/client.dart b/lib/client.dart index a8283b83..a402fdf1 100644 --- a/lib/client.dart +++ b/lib/client.dart @@ -8,7 +8,7 @@ import 'dart:io'; class Client { static String protocol = 'https'; - static String domain = 'api.anypayx.com'; + static String domain = 'anypay.pshenmic.dev'; static String host = "$protocol://$domain"; static String humanize(String str) { diff --git a/lib/main.dart b/lib/main.dart index f893a5fa..779d5813 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -26,6 +26,15 @@ class Anypay extends StatelessWidget { var lightTheme = ThemeData( primaryColorDark: Color(0xFF707070), primaryColorLight: Color(0xFF404040), + inputDecorationTheme: const InputDecorationTheme( + labelStyle: TextStyle(color: Color(0xFF404040)), + enabledBorder: + UnderlineInputBorder(borderSide: BorderSide(color: Colors.black)), + ), + colorScheme: ColorScheme.fromSwatch().copyWith( + background: AppController.white, + secondary: AppController.blue, + brightness: Brightness.light), elevatedButtonTheme: ElevatedButtonThemeData( style: ButtonStyle( backgroundColor: MaterialStateProperty.all( @@ -35,13 +44,24 @@ class Anypay extends StatelessWidget { Colors.white), //text (and icon) ), ), - brightness: Brightness.light, - accentColor: AppController.blue, fontFamily: 'Ubuntu', ); var darkTheme = ThemeData( primaryColorDark: Color(0xffCCCCCC), primaryColorLight: Color(0xFFFFFFFF), + textTheme: TextTheme( + bodyMedium: TextStyle(color: Color(0xFFFFFFFF)), + bodyLarge: TextStyle(color: Color(0xFFFFFFFF)), + ), + inputDecorationTheme: const InputDecorationTheme( + labelStyle: TextStyle(color: Color(0xFFFFFFFF)), + enabledBorder: + UnderlineInputBorder(borderSide: BorderSide(color: Colors.white)), + ), + colorScheme: ColorScheme.fromSwatch().copyWith( + background: Color(0xff222222), + secondary: Color(0xff2196f3), + brightness: Brightness.dark), elevatedButtonTheme: ElevatedButtonThemeData( style: ButtonStyle( backgroundColor: MaterialStateProperty.all( @@ -51,8 +71,6 @@ class Anypay extends StatelessWidget { Colors.black), //text (and icon) ), ), - accentColor: Color(0xff2196f3), - brightness: Brightness.dark, fontFamily: 'Ubuntu', ); diff --git a/lib/routes/login.dart b/lib/routes/login.dart index 59953463..bb73d412 100644 --- a/lib/routes/login.dart +++ b/lib/routes/login.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:email_validator/email_validator.dart'; +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:app/app_controller.dart'; import 'package:flutter/material.dart'; diff --git a/lib/routes/settings.dart b/lib/routes/settings.dart index 07c4fbad..ecc9afa2 100644 --- a/lib/routes/settings.dart +++ b/lib/routes/settings.dart @@ -1,8 +1,12 @@ import 'package:app/authentication.dart'; +import 'package:confirm_dialog/confirm_dialog.dart'; import 'package:flutter/material.dart'; import 'package:app/back_button.dart'; import 'package:app/app_controller.dart'; import 'package:app/currencies.dart'; +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; + +import '../client.dart'; class Settings extends StatelessWidget { @override @@ -88,34 +92,42 @@ class _SettingsPageState extends State { labelText: 'Update Backend Url', hintText: "http:// or https://"), validator: (value) { - if (Uri.parse(value).isAbsolute) { - return null; + if (value != null) { + if (Uri.parse(value).isAbsolute) { + return null; + } else { + return "Please provide valid url"; + } } else { return "Please provide valid url"; } }), ), - ElevatedButton( - onPressed: () async { - if (_formKey.currentState.validate()) { - if (await confirm(context, - title: Text("Confirmation"), - content: Text( - "You will be logged out because you changed the API backend url"))) { - final uri = Uri.parse(urlController.text); - await FlutterSecureStorage( - aOptions: AndroidOptions( - encryptedSharedPreferences: true, - )).write(key: "backend_url", value: urlController.text); - Client.protocol = uri.scheme; - Client.domain = uri.host; - Authentication.logout(); + Padding( + padding: const EdgeInsets.only(left: 12), + child: ElevatedButton( + onPressed: () async { + if (_formKey.currentState!.validate()) { + bool confirmed = await confirm(context, + title: Text("Confirmation"), + content: Text( + "You will be logged out because you changed the API backend url")); + if (confirmed) { + final uri = Uri.parse(urlController.text); + await FlutterSecureStorage( + aOptions: AndroidOptions( + encryptedSharedPreferences: true, + )).write(key: "backend_url", value: urlController.text); + Client.protocol = uri.scheme; + Client.domain = uri.host; + Authentication.logout(); + } } - } - }, - child: Text( - "Save", - )) + }, + child: Text( + "Save", + )), + ) ], ), ); diff --git a/pubspec.yaml b/pubspec.yaml index ca233789..2a37da46 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,6 +39,7 @@ dependencies: fluro: ^2.0.4 http: ^1.2.0 intl: ^0.19.0 + confirm_dialog: ^1.0.1 flutter: sdk: flutter