Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/supabase storage #48

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions teta_widgets/lib/src/core/teta_widget/teta_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class TetaWidget extends StatelessWidget {
@override
Widget build(final BuildContext context) {
return NodeSelectionBuilder(
node: state.node,
forPlay: state.forPlay,
state: state,
child: GestureBuilderBase.get(
context: context,
state: state,
Expand Down
5 changes: 5 additions & 0 deletions teta_widgets/lib/src/core/teta_widget/teta_widget_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class TetaWidgetState {
required this.params,
required this.states,
required this.dataset,
this.isVertical = true,
});

/// The original CNode
Expand All @@ -31,13 +32,16 @@ class TetaWidgetState {
/// The dataset list created by other widgets inside the same page
final List<DatasetObject> dataset;

final bool isVertical;

TetaWidgetState copyWith({
final CNode? node,
final bool? forPlay,
final int? loop,
final List<VariableObject>? params,
final List<VariableObject>? states,
final List<DatasetObject>? dataset,
final bool? isVertical,
}) {
return TetaWidgetState(
node: node ?? this.node,
Expand All @@ -46,6 +50,7 @@ class TetaWidgetState {
params: params ?? this.params,
states: states ?? this.states,
dataset: dataset ?? this.dataset,
isVertical: isVertical ?? this.isVertical,
);
}

Expand Down
2 changes: 1 addition & 1 deletion teta_widgets/lib/src/elements/actions/airtable/delete.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:dart_airtable/dart_airtable.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:teta_core/src/pages/editor_page/cubits/airtable.dart';
import 'package:teta_core/src/cubits/airtable.dart';
import 'package:teta_core/teta_core.dart';
import 'package:teta_widgets/src/elements/features/text_type_input.dart';

Expand Down
3 changes: 2 additions & 1 deletion teta_widgets/lib/src/elements/actions/airtable/insert.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:dart_airtable/dart_airtable.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:teta_core/src/pages/editor_page/cubits/airtable.dart';
import 'package:teta_core/src/cubits/airtable.dart';
import 'package:teta_core/teta_core.dart';
import 'package:teta_widgets/src/elements/features/text_type_input.dart';

Expand Down Expand Up @@ -35,6 +35,7 @@ class FAAirtableInsert {
);

await airtableCubit.insert(recordName: recordName, record: record);
return null;
}

static String toCode(
Expand Down
48 changes: 24 additions & 24 deletions teta_widgets/lib/src/elements/actions/airtable/update.dart
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
import 'package:dart_airtable/dart_airtable.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:teta_core/src/pages/editor_page/cubits/airtable.dart';
import 'package:teta_core/src/cubits/airtable.dart';
import 'package:teta_core/teta_core.dart';
import 'package:teta_widgets/src/elements/features/text_type_input.dart';

class FAAirtableUpdate {
static Future action(
final BuildContext context,
final FTextTypeInput? airtableRecordName,
final List<MapElement> airtableData,
final List<VariableObject> params,
final List<VariableObject> states,
final List<DatasetObject> dataset,
final int? loop,
final BuildContext context,
final FTextTypeInput? airtableRecordName,
final List<MapElement> airtableData,
final List<VariableObject> params,
final List<VariableObject> states,
final List<DatasetObject> dataset,
final int? loop,
) async {
final airtableCubit = BlocProvider.of<AirtableCubit>(context);
final recordName = airtableRecordName?.get(
params,
states,
dataset,
false,
loop,
context,
) ??
params,
states,
dataset,
false,
loop,
context,
) ??
'';

final record = AirtableRecord(
fields: airtableData
.map(
(final e) => AirtableRecordField(fieldName: e.key, value: e.value),
)
)
.toList(),
);

await airtableCubit.update(recordName: recordName, record: record);

}

static String toCode(
final BuildContext context,
final FTextTypeInput? airtableRecordName,
final List<MapElement> airtableData,) {
final BuildContext context,
final FTextTypeInput? airtableRecordName,
final List<MapElement> airtableData,
) {
final record = AirtableRecord(
fields: airtableData
.map(
(final e) => AirtableRecordField(fieldName: e.key, value: e.value),
)
)
.toList(),
);

return '''
context<AirtableCubit>.read().update(recordName: ${airtableRecordName?.toCode(
0,
resultType: ResultTypeEnum.string,
) ?? ''}, record: $record)
0,
resultType: ResultTypeEnum.string,
) ?? ''}, record: $record)
''';
}
}
24 changes: 13 additions & 11 deletions teta_widgets/lib/src/elements/actions/braintree/pay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,22 @@ class FActionBraintreeBuy {
final String? stateName, {
final int loop = 0,
}) {
final prj = (BlocProvider.of<FocusProjectBloc>(context).state as ProjectLoaded).prj;
final isSandbox = prj.config?.braintreeIsSandbox ?? true;
final token =
!isSandbox ? prj.config?.braintreeClientToken : prj.config?.braintreeClientTokenSandbox;
final companyName = prj.config?.companyName ?? '';
final currencyCode = prj.config?.braintreeCurrencyCode ?? '';
final countryCode = prj.config?.countryCode ?? '';
final config =
(BlocProvider.of<ConfigCubit>(context).state as ConfigStateLoaded)
.config;
final isSandbox = config.braintree.isSandbox;
final token = !isSandbox
? config.braintree.productionInfo.clientToken
: config.braintree.sandboxInfo.clientToken;
final companyName = config.braintree.companyName;
final currencyCode = config.braintree.currencyCode;
final countryCode = config.braintree.countryCode;
final amount = valueToChangeWith!.toCode(
loop,
resultType: ResultTypeEnum.double,
defaultValue: '1.00',
);
final appleMerchantId = prj.config?.appleMerchantId;
final appleMerchantId = config.braintree.applePay.merchantId;
String? paypal;
String? googlePay;
String? applePay;
Expand All @@ -60,7 +63,6 @@ class FActionBraintreeBuy {
if (amount.isEmpty) return '';

final page = getPageOnToCode(pageId, context);
if (page == null) return '';
final variable = takeStateFrom(page, stateName);
if (variable == null) return '';

Expand All @@ -72,15 +74,15 @@ class FActionBraintreeBuy {
displayName: '$companyName',
),''';

if (prj.config?.googlePayFlag ?? false) {
if (config.braintree.googlePay.isEnabled) {
googlePay = '''
BraintreeGooglePaymentRequest(
totalPrice: $amount,
currencyCode: '$currencyCode',
billingAddressRequired: false,
),''';
}
if (prj.config?.isApplePayReady ?? false) {
if (config.braintree.applePay.isEnabled) {
applePay = '''
BraintreeApplePayRequest(
displayName: '$companyName',
Expand Down
10 changes: 5 additions & 5 deletions teta_widgets/lib/src/elements/actions/camera/always_flash.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import 'package:teta_widgets/src/elements/actions/snippets/get_page_on_code.dart

class FACameraAlwaysFlash {
static Future action(final BuildContext context) async {
final page = BlocProvider.of<PageCubit>(context).state;
final state =
page.states.firstWhereOrNull((final e) => e.type == VariableType.cameraController);
final page = BlocProvider.of<PageCubit>(context).state as PageLoaded;
final state = page.states
.firstWhereOrNull((final e) => e.type == VariableType.cameraController);
final controller = state?.controller;
if (controller != null) {
await controller.setFlashMode(FlashMode.always);
Expand All @@ -29,8 +29,8 @@ class FACameraAlwaysFlash {
) {
final page = getPageOnToCode(pageId, context);
if (page == null) return '';
final state =
page.states.firstWhereOrNull((final e) => e.type == VariableType.cameraController);
final state = page.states
.firstWhereOrNull((final e) => e.type == VariableType.cameraController);
if (state == null) return '';
final rc = ReCase(state.name);
return '''
Expand Down
11 changes: 5 additions & 6 deletions teta_widgets/lib/src/elements/actions/camera/auto_flash.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class FACameraAutoFlash {
final BuildContext context,
final TetaWidgetState state,
) async {
final page = BlocProvider.of<PageCubit>(context).state;
final state =
page.states.firstWhereOrNull((final e) => e.type == VariableType.cameraController);
final page = BlocProvider.of<PageCubit>(context).state as PageLoaded;
final state = page.states
.firstWhereOrNull((final e) => e.type == VariableType.cameraController);
final controller = state?.controller;
if (controller != null) {
await controller.setFlashMode(FlashMode.off);
Expand All @@ -32,9 +32,8 @@ class FACameraAutoFlash {
final int pageId,
) {
final page = getPageOnToCode(pageId, context);
if (page == null) return '';
final state =
page.states.firstWhereOrNull((final e) => e.type == VariableType.cameraController);
final state = page.states
.firstWhereOrNull((final e) => e.type == VariableType.cameraController);
if (state == null) return '';
final rc = ReCase(state.name);
return '''
Expand Down
10 changes: 5 additions & 5 deletions teta_widgets/lib/src/elements/actions/camera/off_flash.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import 'package:teta_widgets/src/elements/actions/snippets/get_page_on_code.dart

class FACameraOffFlash {
static Future action(final BuildContext context) async {
final page = BlocProvider.of<PageCubit>(context).state;
final state =
page.states.firstWhereOrNull((final e) => e.type == VariableType.cameraController);
final page = BlocProvider.of<PageCubit>(context).state as PageLoaded;
final state = page.states
.firstWhereOrNull((final e) => e.type == VariableType.cameraController);
final controller = state?.controller;
if (controller != null) {
await controller.setFlashMode(FlashMode.auto);
Expand All @@ -29,8 +29,8 @@ class FACameraOffFlash {
) {
final page = getPageOnToCode(pageId, context);
if (page == null) return '';
final state =
page.states.firstWhereOrNull((final e) => e.type == VariableType.cameraController);
final state = page.states
.firstWhereOrNull((final e) => e.type == VariableType.cameraController);
if (state == null) return '';
final rc = ReCase(state.name);
return '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FACameraStopRecording {
final TetaWidgetState state,
final String? stateName,
) async {
final page = BlocProvider.of<PageCubit>(context).state;
final page = BlocProvider.of<PageCubit>(context).state as PageLoaded;
final stateFound = page.states.firstWhereOrNull(
(final e) => e.type == VariableType.cameraController,
);
Expand All @@ -41,8 +41,8 @@ class FACameraStopRecording {
) {
final page = getPageOnToCode(pageId, context);
if (page == null) return '';
final state =
page.states.firstWhereOrNull((final e) => e.type == VariableType.cameraController);
final state = page.states
.firstWhereOrNull((final e) => e.type == VariableType.cameraController);
if (state == null || stateName == null) return '';
final rc = ReCase(state.name);
final fileStateName = ReCase(stateName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FACameraSwitch {
final BuildContext context,
final String? stateName,
) async {
final page = BlocProvider.of<PageCubit>(context).state;
final page = BlocProvider.of<PageCubit>(context).state as PageLoaded;
final state = page.states.firstWhereOrNull(
(final e) => e.type == VariableType.cameraController,
);
Expand Down
9 changes: 5 additions & 4 deletions teta_widgets/lib/src/elements/actions/camera/take_photo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ class FACameraTakePhoto {
final TetaWidgetState state,
final String? stateName,
) async {
final page = BlocProvider.of<PageCubit>(context).state;
final page = BlocProvider.of<PageCubit>(context).state as PageLoaded;
final stateFound = page.states.firstWhereOrNull(
(final e) => e.type == VariableType.cameraController,
);
final controller = stateFound?.controller;
if (controller != null) {
final file = await controller.takePicture();
final index = state.states.indexWhere((final element) => element.name == stateName);
final index =
state.states.indexWhere((final element) => element.name == stateName);
state.states[index].file = file;
}
}
Expand All @@ -37,8 +38,8 @@ class FACameraTakePhoto {
) {
final page = getPageOnToCode(pageId, context);
if (page == null) return '';
final state =
page.states.firstWhereOrNull((final e) => e.type == VariableType.cameraController);
final state = page.states
.firstWhereOrNull((final e) => e.type == VariableType.cameraController);
if (state == null || stateName == null) return '';
final rc = ReCase(state.name);
final fileStateName = ReCase(stateName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FACameraTorchFlash {
final BuildContext context,
final String? stateName,
) async {
final page = BlocProvider.of<PageCubit>(context).state;
final page = BlocProvider.of<PageCubit>(context).state as PageLoaded;
final state = page.states.firstWhereOrNull(
(final e) => e.type == VariableType.cameraController,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ class FAMixpanelSetUserId {
final BuildContext context,
final FTextTypeInput? userIdValue,
) {
final prj =
(BlocProvider.of<FocusProjectBloc>(context).state as ProjectLoaded).prj;
if (prj.config?.isMixpanelReady ?? false) {
final config =
(BlocProvider.of<ConfigCubit>(context).state as ConfigStateLoaded)
.config;
if (config.mixpanel is MixpanelConfigModelInitialized) {
final userId = userIdValue?.toCode(
0,
resultType: ResultTypeEnum.string,
Expand Down
7 changes: 4 additions & 3 deletions teta_widgets/lib/src/elements/actions/mixpanel/track.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ class FAMixpanelTrack {
final FTextTypeInput? eventName,
final List<MapElement>? props,
) {
final prj =
(BlocProvider.of<FocusProjectBloc>(context).state as ProjectLoaded).prj;
if (prj.config?.isMixpanelReady ?? false) {
final config =
(BlocProvider.of<ConfigCubit>(context).state as ConfigStateLoaded)
.config;
if (config.mixpanel is MixpanelConfigModelInitialized) {
//props
final mapBody = <String, dynamic>{};
for (final e in props ?? <MapElement>[]) {
Expand Down
Loading