Skip to content

Commit

Permalink
after mint improvements
Browse files Browse the repository at this point in the history
* add ticker on mint info container when mint starts in 1 hour max

* improve and clean home screen a bit
comic details improve code reading

* publishing
  • Loading branch information
d-reader-luka authored Jun 3, 2024
1 parent f0562ae commit da2bf46
Show file tree
Hide file tree
Showing 32 changed files with 891 additions and 902 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ all: build-dev build-prod build-prod-apk

build-dev:
flutter clean && \
flutter build apk --split-per-abi --release --dart-define=apiUrl=$(API_URL_DEV_DEVNET) --dart-define=apiUrlDevnet=$(API_URL_DEV_DEVNET) --dart-define=sentryDsn=${sentryDsn} --flavor dev --target lib/main_dev.dart && \
flutter build apk --split-per-abi --release --dart-define=apiUrl=$(API_URL_DEV_DEVNET) --dart-define=apiUrlDevnet=$(API_URL_DEV_DEVNET) --dart-define=sentryDsn=${sentryDsn} --flavor dev --target lib/main.dart && \
mv ./build/app/outputs/flutter-apk/app-armeabi-v7a-dev-release.apk ./apks/dReader-dev.apk

build-prod:
flutter clean && \
flutter build appbundle --release --dart-define=apiUrl=$(API_URL_PROD) --dart-define=apiUrlDevnet=$(API_URL_PROD) --dart-define=sentryDsn=${sentryDsn} --flavor prod --target lib/main_prod.dart && \
flutter build appbundle --release --dart-define=apiUrl=$(API_URL_PROD) --dart-define=apiUrlDevnet=$(API_URL_PROD) --dart-define=sentryDsn=${sentryDsn} --flavor prod --target lib/main.dart && \
mv ./build/app/outputs/bundle/prodRelease/app-prod-release.aab ./apks/dReader.aab

build-prod-apk:
flutter clean && \
flutter build apk --split-per-abi --release --dart-define=apiUrl=$(API_URL_PROD) --dart-define=apiUrlDevnet=$(API_URL_PROD) --dart-define=sentryDsn=${sentryDsn} --flavor prod --target lib/main_prod.dart && \
flutter build apk --split-per-abi --release --dart-define=apiUrl=$(API_URL_PROD) --dart-define=apiUrlDevnet=$(API_URL_PROD) --dart-define=sentryDsn=${sentryDsn} --flavor prod --target lib/main.dart && \
mv ./build/app/outputs/flutter-apk/app-arm64-v8a-prod-release.apk ./apks/dReader.apk

start-saga-release:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ class SignUpScreen extends ConsumerStatefulWidget {

class _SignUpScreenState extends ConsumerState<SignUpScreen> {
final PageController _pageController = PageController();
@override
void initState() {
super.initState();
}

@override
void dispose() {
_pageController.dispose();
super.dispose();
}

Expand All @@ -45,21 +41,20 @@ class _SignUpScreenState extends ConsumerState<SignUpScreen> {
left: 16,
right: 16,
),
child: const Heading(),
child: const _Heading(),
),
),
body: ref.watch(signUpDataNotifierProvider).googleAccessToken.isNotEmpty
? GoogleSignUpForm(pageController: _pageController)
: RegularSignUpForm(pageController: _pageController),
? _GoogleSignUpForm(pageController: _pageController)
: _RegularSignUpForm(pageController: _pageController),
),
);
}
}

class RegularSignUpForm extends ConsumerWidget {
class _RegularSignUpForm extends ConsumerWidget {
final PageController pageController;
const RegularSignUpForm({
super.key,
const _RegularSignUpForm({
required this.pageController,
});

Expand Down Expand Up @@ -117,10 +112,9 @@ class RegularSignUpForm extends ConsumerWidget {
}
}

class GoogleSignUpForm extends ConsumerWidget {
class _GoogleSignUpForm extends ConsumerWidget {
final PageController pageController;
const GoogleSignUpForm({
super.key,
const _GoogleSignUpForm({
required this.pageController,
});

Expand Down Expand Up @@ -165,15 +159,15 @@ class GoogleSignUpForm extends ConsumerWidget {
}
}

class Heading extends ConsumerWidget {
const Heading({super.key});
class _Heading extends ConsumerWidget {
const _Heading();

@override
Widget build(BuildContext context, WidgetRef ref) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const HeadingItem(
const _HeadingItem(
step: 1,
title: 'Username',
color: Colors.white,
Expand All @@ -191,7 +185,7 @@ class Heading extends ConsumerWidget {
.watch(signUpDataNotifierProvider)
.googleAccessToken
.isEmpty) ...[
HeadingItem(
_HeadingItem(
step: 2,
title: 'Email & pass',
color: ref.watch(signUpPageProvider) > 0
Expand All @@ -208,7 +202,7 @@ class Heading extends ConsumerWidget {
),
),
],
HeadingItem(
_HeadingItem(
step:
ref.watch(signUpDataNotifierProvider).googleAccessToken.isNotEmpty
? 2
Expand All @@ -223,12 +217,11 @@ class Heading extends ConsumerWidget {
}
}

class HeadingItem extends StatelessWidget {
class _HeadingItem extends StatelessWidget {
final int step;
final String title;
final Color color;
const HeadingItem({
super.key,
const _HeadingItem({
required this.step,
required this.title,
required this.color,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import 'package:d_reader_flutter/constants/constants.dart';
import 'package:d_reader_flutter/features/candy_machine/domain/models/candy_machine.dart';
import 'package:d_reader_flutter/features/candy_machine/domain/models/candy_machine_group.dart';
import 'package:d_reader_flutter/features/candy_machine/domain/providers/candy_machine_provider.dart';
import 'package:d_reader_flutter/features/comic_issue/presentation/widgets/tabs/about/mint_info_container.dart';
import 'package:d_reader_flutter/features/settings/domain/models/spl_token.dart';
import 'package:d_reader_flutter/features/settings/presentation/providers/spl_tokens.dart';
import 'package:d_reader_flutter/shared/utils/formatter.dart';
import 'package:d_reader_flutter/shared/utils/utils.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
Expand Down Expand Up @@ -54,3 +56,20 @@ final activeSplToken = StateProvider.autoDispose<SplToken?>(
?.firstWhere((element) => element.priority == splTokenHighestPriority);
},
);

final timeUntilMintStarts = StateProvider.autoDispose<String>(
(ref) {
final candyMachineGroup = ref.read(selectedCandyMachineGroup);
return Formatter.formatDateInRelative(candyMachineGroup?.startDate);
},
);

final mintStatusesProvider = StateProvider.autoDispose<(bool, bool)>(
(ref) {
final candyMachineGroup = ref.read(selectedCandyMachineGroup);

return candyMachineGroup == null
? (false, false)
: getMintStatuses(candyMachineGroup);
},
);
4 changes: 2 additions & 2 deletions lib/features/comic/data/datasource/comic_remote_source.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:d_reader_flutter/shared/exceptions/exceptions.dart';
abstract class ComicDataSource {
Future<Either<AppException, List<ComicModel>>> getComics(
{String? queryString});
Future<Either<AppException, ComicModel?>> getComic(String slug);
Future<Either<AppException, ComicModel>> getComic(String slug);
Future<Either<AppException, List<ComicModel>>> getOwnedComics({
required int userId,
required String query,
Expand Down Expand Up @@ -34,7 +34,7 @@ class ComicRemoteDataSource implements ComicDataSource {
}

@override
Future<Either<AppException, ComicModel?>> getComic(String slug) async {
Future<Either<AppException, ComicModel>> getComic(String slug) async {
try {
final response = await networkService.get('/comic/get/$slug');
return response.fold((exception) => Left(exception), (result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ComicRepositoryImpl implements ComicRepository {
}

@override
Future<Either<AppException, ComicModel?>> getComic(String slug) {
Future<Either<AppException, ComicModel>> getComic(String slug) {
return dataSource.getComic(slug);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:d_reader_flutter/shared/exceptions/exceptions.dart';
abstract class ComicRepository {
Future<Either<AppException, List<ComicModel>>> getComics(
{String? queryString});
Future<Either<AppException, ComicModel?>> getComic(String slug);
Future<Either<AppException, ComicModel>> getComic(String slug);
Future<Either<AppException, List<ComicModel>>> getOwnedComics({
required int userId,
required String query,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final paginatedComicsProvider = StateNotifierProvider.family<
});

final comicSlugProvider =
FutureProvider.autoDispose.family<ComicModel?, String>((ref, slug) async {
FutureProvider.autoDispose.family<ComicModel, String>((ref, slug) async {
return ref.read(comicRepositoryProvider).getComic(slug).then(
(result) => result.fold((exception) => throw exception, (data) => data));
});
Expand Down
22 changes: 12 additions & 10 deletions lib/features/comic/presentation/screens/comic_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:d_reader_flutter/features/comic_issue/presentation/widgets/tabs/
import 'package:d_reader_flutter/features/comic/presentation/widgets/details/scaffold.dart';
import 'package:d_reader_flutter/features/discover/root/presentation/widgets/common/on_going_bottom.dart';
import 'package:d_reader_flutter/features/discover/root/presentation/widgets/tabs/issues/issues_gallery_builder.dart';
import 'package:d_reader_flutter/shared/widgets/unsorted/carrot_error_widget.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

Expand All @@ -22,18 +23,16 @@ class ComicDetails extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final AsyncValue<ComicModel?> provider = ref.watch(comicSlugProvider(slug));
final AsyncValue<ComicModel> provider = ref.watch(comicSlugProvider(slug));
final issuesProvider = ref.watch(
paginatedIssuesProvider(
'comicSlug=$slug&sortTag=latest&sortOrder=${getSortDirection(ref.watch(comicSortDirectionProvider))}',
),
);

final bool isDetailedViewMode =
ref.watch(comicViewModeProvider) == ViewMode.detailed;
return provider.when(
data: (comic) {
if (comic == null) {
return const SizedBox();
}
return ComicDetailsScaffold(
comic: comic,
loadMore: ref
Expand All @@ -53,25 +52,28 @@ class ComicDetails extends ConsumerWidget {
(context, index) {
return issuesProvider.when(
data: (List<ComicIssueModel> issues) {
return ref.watch(comicViewModeProvider) ==
ViewMode.detailed
return isDetailedViewMode
? _IssuesList(issues: issues)
: IssuesGalleryBuilder(
issues: issues,
);
},
error: (Object? e, StackTrace? stk) {
return const Text('Failed to fetch data.');
return const CarrotErrorWidget();
},
loading: () {
return const SizedBox();
},
onGoingError: (List<ComicIssueModel> items, Object? e,
StackTrace? stk) {
return _IssuesList(issues: items);
return isDetailedViewMode
? _IssuesList(issues: items)
: IssuesGalleryBuilder(issues: items);
},
onGoingLoading: (List<ComicIssueModel> items) {
return _IssuesList(issues: items);
return isDetailedViewMode
? _IssuesList(issues: items)
: IssuesGalleryBuilder(issues: items);
},
);
},
Expand Down
Loading

0 comments on commit da2bf46

Please sign in to comment.