lot of work on rfplus

This commit is contained in:
Kima
2024-02-28 22:37:21 +01:00
parent 55a9a41722
commit 25464eff79
8 changed files with 214 additions and 30 deletions

View File

@@ -50,6 +50,10 @@ class FilcAPI {
static const allGradeColors = "$gradeColorsGet/all";
static const gradeColorsByID = "$gradeColorsGet/";
// Payment API
static const payment = "$baseUrl/v3/payment";
static const stripeSheet = "$payment/stripe-sheet";
static Future<bool> checkConnectivity() async =>
(await Connectivity().checkConnectivity()) != ConnectivityResult.none;
@@ -340,6 +344,35 @@ class FilcAPI {
}
return null;
}
// payment
static Future<Map?> createPaymentSheet(String product) async {
try {
Map body = {
"product": product,
};
var client = http.Client();
http.Response res = await client.post(
Uri.parse(stripeSheet),
body: body,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
);
if (res.statusCode != 200) {
throw "HTTP ${res.statusCode}: ${res.body}";
}
return jsonDecode(res.body);
} on Exception catch (error, stacktrace) {
log("ERROR: FilcAPI.sendReport: $error $stacktrace");
}
return null;
}
}
class ErrorReport {

View File

@@ -35,7 +35,7 @@ void main() async {
// initialize stripe key
stripe.Stripe.publishableKey =
'pk_live_51OWSV2HW2TAy5tA6EELuXtpG6ombCCrOFbvz2fDwZlqLT42Ql64CfxptWem8NjN1dhnE6jaI77TRsVZbF8gfd29Q00OGMQRGqm';
'pk_test_51Oo7iUBS0FxsTGxKjGZSQqzDKWHY5ZFYM9XeI0qSdIh2w8jWy6GhHlYpT7GLTzgpl1xhE5YP4BXpA4gMZqPmgMId00cGFYFzbh';
// Run App
runApp(App(

View File

@@ -91,6 +91,7 @@ class SettingsProvider extends ChangeNotifier {
// more
bool _showBreaks;
String _fontFamily;
String _plusSessionId;
SettingsProvider({
DatabaseProvider? database,
@@ -148,6 +149,7 @@ class SettingsProvider extends ChangeNotifier {
required String pinSetNotify,
required String pinSetExtras,
required String fontFamily,
required String plusSessionId,
}) : _database = database,
_language = language,
_startPage = startPage,
@@ -202,7 +204,8 @@ class SettingsProvider extends ChangeNotifier {
_pinSetPersonalize = pinSetPersonalize,
_pinSetNotify = pinSetNotify,
_pinSetExtras = pinSetExtras,
_fontFamily = fontFamily;
_fontFamily = fontFamily,
_plusSessionId = plusSessionId;
factory SettingsProvider.fromMap(Map map,
{required DatabaseProvider database}) {
@@ -277,6 +280,7 @@ class SettingsProvider extends ChangeNotifier {
pinSetNotify: map['notify_s_pin'],
pinSetExtras: map['extras_s_pin'],
fontFamily: map['font_family'],
plusSessionId: map['plus_session_id'],
);
}
@@ -339,6 +343,7 @@ class SettingsProvider extends ChangeNotifier {
"notify_s_pin": _pinSetNotify,
"extras_s_pin": _pinSetExtras,
"font_family": _fontFamily,
"plus_session_id": _plusSessionId,
};
}
@@ -405,6 +410,7 @@ class SettingsProvider extends ChangeNotifier {
pinSetNotify: '',
pinSetExtras: '',
fontFamily: '',
plusSessionId: '',
);
}
@@ -462,6 +468,7 @@ class SettingsProvider extends ChangeNotifier {
String get currentThemeCreator => _currentThemeCreator;
bool get showBreaks => _showBreaks;
String get fontFamily => _fontFamily;
String get plusSessionId => _plusSessionId;
Future<void> update({
bool store = true,
@@ -515,6 +522,7 @@ class SettingsProvider extends ChangeNotifier {
String? currentThemeCreator,
bool? showBreaks,
String? fontFamily,
String? plusSessionId,
}) async {
if (language != null && language != _language) _language = language;
if (startPage != null && startPage != _startPage) _startPage = startPage;
@@ -662,6 +670,9 @@ class SettingsProvider extends ChangeNotifier {
if (fontFamily != null && fontFamily != _fontFamily) {
_fontFamily = fontFamily;
}
if (plusSessionId != null && plusSessionId != _plusSessionId) {
_plusSessionId = plusSessionId;
}
// store or not
if (store) await _database?.store.storeSettings(this);
notifyListeners();

View File

@@ -11,8 +11,10 @@ import 'package:googleapis/calendar/v3.dart';
import 'package:google_sign_in/google_sign_in.dart';
class ThirdPartyProvider with ChangeNotifier {
late List<Event>? _googleEvents;
late List<LinkedAccount> _linkedAccounts;
// google specific
late List<Event>? _googleEvents;
late List<Calendar>? _googleCalendars;
late BuildContext _context;
@@ -21,9 +23,12 @@ class ThirdPartyProvider with ChangeNotifier {
CalendarApi.calendarEventsScope,
]);
List<Event> get googleEvents => _googleEvents ?? [];
// public
List<LinkedAccount> get linkedAccounts => _linkedAccounts;
List<Event> get googleEvents => _googleEvents ?? [];
List<Calendar> get googleCalendars => _googleCalendars ?? [];
ThirdPartyProvider({
required BuildContext context,
List<LinkedAccount>? initialLinkedAccounts,
@@ -64,6 +69,11 @@ class ThirdPartyProvider with ChangeNotifier {
return null;
}
Future<void> signOutAll() async {
await _googleSignIn.signOut();
_linkedAccounts.clear();
}
// Future<void> fetchGoogle() async {
// try {
// var httpClient = (await _googleSignIn.authenticatedClient())!;