Skip to content

Commit

Permalink
Merge pull request #2421 from gram-incolo/feat/implementEvently
Browse files Browse the repository at this point in the history
fix the event length issue
  • Loading branch information
MikeSofaer authored Jun 11, 2024
2 parents 22ce109 + 57c0783 commit bdf0e47
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 21 deletions.
39 changes: 29 additions & 10 deletions evently/lib/evently_provider.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:convert';

import 'package:dartz/dartz.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:evently/generated/locale_keys.g.dart';
Expand All @@ -21,6 +22,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:injectable/injectable.dart';
import 'package:pylons_sdk/low_level.dart';

import 'services/third_party_services/quick_node.dart';

@LazySingleton()
Expand Down Expand Up @@ -66,7 +68,8 @@ class EventlyProvider extends ChangeNotifier {
}

checkIsOverEnable() {
setOverviewEnable = thumbnail!.isNotEmpty && eventName.length > 8 && hostName.isNotEmpty;
setOverviewEnable =
thumbnail!.isNotEmpty && eventName.length > 4 && hostName.isNotEmpty;
}

///* detail screen
Expand Down Expand Up @@ -190,9 +193,11 @@ class EventlyProvider extends ChangeNotifier {
notifyListeners();
}

final StreamController<UploadProgress> _uploadProgressController = StreamController.broadcast();
final StreamController<UploadProgress> _uploadProgressController =
StreamController.broadcast();

Stream<UploadProgress> get uploadProgressStream => _uploadProgressController.stream;
Stream<UploadProgress> get uploadProgressStream =>
_uploadProgressController.stream;

void pickThumbnail() async {
final pickedFile = await repository.pickFile();
Expand All @@ -207,11 +212,15 @@ class EventlyProvider extends ChangeNotifier {

if (result.path.isEmpty) return;

final loading = LoadingProgress()..showLoadingWithProgress(message: LocaleKeys.uploading.tr());
final loading = LoadingProgress()
..showLoadingWithProgress(message: LocaleKeys.uploading.tr());

Either<Failure, StorageResponseModel> response;
response = await repository.uploadFileUsingQuickNode(
uploadIPFSInput: UploadIPFSInput(fileName: result.fileName, filePath: result.path, contentType: QuickNode.getContentType(result.extension)),
uploadIPFSInput: UploadIPFSInput(
fileName: result.fileName,
filePath: result.path,
contentType: QuickNode.getContentType(result.extension)),
onUploadProgressCallback: (value) {
_uploadProgressController.sink.add(value);
},
Expand All @@ -223,7 +232,8 @@ class EventlyProvider extends ChangeNotifier {
return;
}

final fileUploadResponse = response.getOrElse(() => StorageResponseModel.initial());
final fileUploadResponse =
response.getOrElse(() => StorageResponseModel.initial());
loading.dismiss();

setThumbnail = "$ipfsDomain/${fileUploadResponse.value?.cid}";
Expand All @@ -234,7 +244,10 @@ class EventlyProvider extends ChangeNotifier {
String? _cookbookId;
String? get cookbookId => _cookbookId;

bool showStripeDialog() => !stripeAccountExists && _selectedDenom.symbol == kUsdSymbol && isFreeDrop == FreeDrop.no;
bool showStripeDialog() =>
!stripeAccountExists &&
_selectedDenom.symbol == kUsdSymbol &&
isFreeDrop == FreeDrop.no;

///* this method is used to get the profile
Future<SDKIPCResponse<Profile>> getProfile() async {
Expand All @@ -243,7 +256,10 @@ class EventlyProvider extends ChangeNotifier {
if (sdkResponse.success) {
stripeAccountExists = sdkResponse.data!.stripeExists;

supportedDenomList = Denom.availableDenoms.where((Denom e) => sdkResponse.data!.supportedCoins.contains(e.symbol)).toList();
supportedDenomList = Denom.availableDenoms
.where(
(Denom e) => sdkResponse.data!.supportedCoins.contains(e.symbol))
.toList();

if (supportedDenomList.isNotEmpty && selectedDenom.symbol.isEmpty) {
_selectedDenom = supportedDenomList.first;
Expand Down Expand Up @@ -292,7 +308,9 @@ class EventlyProvider extends ChangeNotifier {
step: '',
);

final String prices = isFreeDrop == FreeDrop.yes ? "0" : _selectedDenom.formatAmount(price: price.toString());
final String prices = isFreeDrop == FreeDrop.yes
? "0"
: _selectedDenom.formatAmount(price: price.toString());

final recipe = event.createRecipe(
cookbookId: _cookbookId!,
Expand All @@ -302,7 +320,8 @@ class EventlyProvider extends ChangeNotifier {
price: prices,
);

final response = await PylonsWallet.instance.txCreateRecipe(recipe, requestResponse: false);
final response = await PylonsWallet.instance
.txCreateRecipe(recipe, requestResponse: false);

if (!response.success) {
scaffoldMessengerState?.show(message: "$kErrRecipe ${response.error}");
Expand Down
7 changes: 5 additions & 2 deletions evently/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:ui';

import 'package:easy_localization/easy_localization.dart';
import 'package:evently/evently_provider.dart';
import 'package:evently/screens/buyer_status_screen.dart';
Expand Down Expand Up @@ -65,7 +66,8 @@ class MyApp extends StatelessWidget {
builder: (context, widget) {
ScreenUtil.init(context);
return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaler: TextScaler.noScaling),
data: MediaQuery.of(context)
.copyWith(textScaler: TextScaler.noScaling),
child: widget!,
);
},
Expand All @@ -89,6 +91,7 @@ class MyApp extends StatelessWidget {
}

bool _getIsCurrentDeviceTablet() {
final MediaQueryData mediaQuery = MediaQueryData.fromView(PlatformDispatcher.instance.implicitView!);
final MediaQueryData mediaQuery =
MediaQueryData.fromView(PlatformDispatcher.instance.implicitView!);
return mediaQuery.size.shortestSide >= tabletMinWidth;
}
41 changes: 32 additions & 9 deletions evently/lib/models/events.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:equatable/equatable.dart';
import 'package:evently/utils/enums.dart';
import 'package:fixnum/fixnum.dart';
import 'package:floor/floor.dart';
import 'package:pylons_sdk/low_level.dart';
import 'package:fixnum/fixnum.dart';

@entity
class Events extends Equatable {
Expand Down Expand Up @@ -60,7 +60,8 @@ class Events extends Equatable {
});

factory Events.fromRecipe(Recipe recipe) {
Map<String, String> map = _extractAttributeValues(recipe.entries.itemOutputs[0].strings);
Map<String, String> map =
_extractAttributeValues(recipe.entries.itemOutputs[0].strings);
return Events(
eventName: map[kEventName]!,
hostName: map[kEventHostName]!,
Expand All @@ -80,7 +81,8 @@ class Events extends Equatable {
);
}

static Map<String, String> _extractAttributeValues(List<StringParam> attributes) {
static Map<String, String> _extractAttributeValues(
List<StringParam> attributes) {
final Map<String, String> attributeValues = {};
for (final attribute in attributes) {
switch (attribute.key) {
Expand Down Expand Up @@ -110,8 +112,24 @@ class Events extends Equatable {
}

@override
List<Object?> get props =>
[eventName, hostName, thumbnail, startDate, endDate, startTime, endTime, location, description, numberOfTickets, price, listOfPerks, isFreeDrops, cookbookID, recipeID, step];
List<Object?> get props => [
eventName,
hostName,
thumbnail,
startDate,
endDate,
startTime,
endTime,
location,
description,
numberOfTickets,
price,
listOfPerks,
isFreeDrops,
cookbookID,
recipeID,
step
];

@override
String toString() {
Expand All @@ -131,7 +149,7 @@ extension CreateRecipe on Events {
cookbookId: cookbookId,
id: recipeId,
nodeVersion: Int64(1),
name: eventName.trim(),
name: eventName.trim() + hostName.trim(),
description: description.trim(),
version: kVersion,
coinInputs: [
Expand Down Expand Up @@ -216,17 +234,22 @@ class PerksModel {
final String name;
final String description;

factory PerksModel.updateName({required String name, required PerksModel perksModel}) => PerksModel(
factory PerksModel.updateName(
{required String name, required PerksModel perksModel}) =>
PerksModel(
name: name,
description: perksModel.description,
);

factory PerksModel.updateDescription({required String description, required PerksModel perksModel}) => PerksModel(
factory PerksModel.updateDescription(
{required String description, required PerksModel perksModel,}) =>
PerksModel(
name: perksModel.name,
description: description,
);

factory PerksModel.fromJson(Map<String, dynamic> map) => PerksModel(name: map['name'] ?? '', description: map['description'] ?? '');
factory PerksModel.fromJson(Map<String, dynamic> map) => PerksModel(
name: map['name'] ?? '', description: map['description'] ?? '',);

Map<String, String> toJson() {
Map<String, String> map = {};
Expand Down

0 comments on commit bdf0e47

Please sign in to comment.