Skip to content

Commit

Permalink
save popup
Browse files Browse the repository at this point in the history
  • Loading branch information
BlockchainViper committed Feb 23, 2024
1 parent 70da3e7 commit 20f4a2e
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 27 deletions.
2 changes: 1 addition & 1 deletion lib/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
26 changes: 22 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Color>(
Expand 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<Color>(
Expand All @@ -51,8 +71,6 @@ class Anypay extends StatelessWidget {
Colors.black), //text (and icon)
),
),
accentColor: Color(0xff2196f3),
brightness: Brightness.dark,
fontFamily: 'Ubuntu',
);

Expand Down
1 change: 1 addition & 0 deletions lib/routes/login.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
56 changes: 34 additions & 22 deletions lib/routes/settings.dart
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -88,34 +92,42 @@ class _SettingsPageState extends State<SettingsPage> {
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",
)),
)
],
),
);
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 20f4a2e

Please sign in to comment.