Skip to content

Commit

Permalink
feat: daily deals, rewards and circuit items now open the codex (#548)
Browse files Browse the repository at this point in the history
ci: bump version direclty

semantic-release-pub just broke out of now where so for the time being new pipline with more control
  • Loading branch information
SlayerOrnstein committed Nov 20, 2024
1 parent c147175 commit 9a531a7
Show file tree
Hide file tree
Showing 29 changed files with 496 additions and 442 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,11 @@ jobs:
path: "build/app/outputs/flutter-apk/app-*-dev-release.apk"

ios:
runs-on: macos-13
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Xcode version
uses: maxim-lobanov/[email protected]
with:
xcode-version: "^15.0.1"

- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.0
Expand Down
41 changes: 38 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,47 @@ jobs:
with:
fetch-tags: true
token: ${{ secrets.GH_TOKEN }}

- name: Semantic Release
id: semantic
uses: cycjimmy/[email protected]
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
with:
extra_plugins: |
@semantic-release/git
semantic-release-pub
semantic_version: 24.2.0

- name: Bump version
if: steps.semantic.outputs.new_release_published == 'true'
env:
NEW_RELEASE: ${{ steps.semantic.outputs.new_release_version }}
run: |
version=$(grep '^version:' pubspec.yaml | awk '{print $2}')
version_code=$(echo $version | sed 's/.*+//')
new_version="${NEW_RELEASE}+$((version_code + 1))"
sed -i "s/^version: .*/version: ${new_version}/" pubspec.yaml
- name: Commit and push changes
if: steps.semantic.outputs.new_release_published == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NOTES: ${{ steps.semantic.outputs.new_release_notes}}
NEW_RELEASE: ${{ steps.semantic.outputs.new_release_version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add pubspec.yaml
git commit -m "chore(release): $NEW_RELEASE [skip ci]" -m "$RELEASE_NOTES" --no-verify
git push
- name: Create Release
if: steps.semantic.outputs.new_release_published == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NOTES: ${{ steps.semantic.outputs.new_release_notes }}
NEW_RELEASE: ${{ steps.semantic.outputs.new_release_version }}
PRERELEASE: ${{ contains(steps.semantic.outputs.new_release_channel, 'beta') }}
run: gh release create v$NEW_RELEASE --notes "$RELEASE_NOTES" --target ${{ github.sha }} $([ "$PRERELEASE" = "true" ] && echo "--prerelease")

10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ jobs:
run: flutter pub get
- name: Unit Test app
run: flutter test --coverage
build_test:
needs: [test]
secrets: inherit
uses: ./.github/workflows/build_test.yml
# build_test:
# needs: [test]
# secrets: inherit
# uses: ./.github/workflows/build_test.yml
release:
if: github.event_name != 'pull_request'
needs: [test, build_test]
needs: [test]
secrets: inherit
uses: ./.github/workflows/release.yml
7 changes: 0 additions & 7 deletions .releaserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ plugins:
release: patch
- - "@semantic-release/release-notes-generator"
- presets: conventionalcommits
- "@semantic-release/github"
- - "semantic-release-pub"
- publishPub: false
updateBuildNumber: true
- - "@semantic-release/git"
- assets: ["pubspec.yaml"]
message: "chore(release): ${nextRelease.version}"
branches:
- name: master
- name: beta
Expand Down
22 changes: 20 additions & 2 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 60;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -203,6 +203,7 @@
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
5AC57969B9426D71894E4F7A /* [CP] Embed Pods Frameworks */,
F565C2D5BD8150893B1356B5 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand All @@ -220,7 +221,7 @@
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C8080294A63A400263BE5 = {
Expand Down Expand Up @@ -367,6 +368,23 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
F565C2D5BD8150893B1356B5 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import Flutter

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
3 changes: 0 additions & 3 deletions lib/app/widgets/bloc_bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class BlocBootstrap extends StatefulWidget {

class _BlocBootstrapState extends State<BlocBootstrap> {
late WorldstateCubit _worldstateCubit;
late DarvodealCubit _darvodealCubit;
late UserSettingsCubit _userSettingsCubit;

@override
Expand All @@ -27,7 +26,6 @@ class _BlocBootstrapState extends State<BlocBootstrap> {
final usersettings = RepositoryProvider.of<UserSettings>(context);

_worldstateCubit = WorldstateCubit(worldstateRepo);
_darvodealCubit = DarvodealCubit(worldstateRepo);
_userSettingsCubit = UserSettingsCubit(usersettings);
}

Expand All @@ -36,7 +34,6 @@ class _BlocBootstrapState extends State<BlocBootstrap> {
return MultiBlocProvider(
providers: [
BlocProvider.value(value: _worldstateCubit),
BlocProvider.value(value: _darvodealCubit),
BlocProvider.value(value: _userSettingsCubit),
],
child: widget.child,
Expand Down
76 changes: 62 additions & 14 deletions lib/codex/cubit/item_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,37 +1,85 @@
import 'package:bloc/bloc.dart';
import 'dart:async';

import 'package:collection/collection.dart';
import 'package:equatable/equatable.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:navis/utils/utils.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:warframestat_client/warframestat_client.dart';
import 'package:warframestat_repository/warframestat_repository.dart';

part 'item_state.dart';

class ItemCubit extends Cubit<ItemState> {
ItemCubit(this.repo) : super(ItemInitial());
class ItemCubit extends HydratedCubit<ItemState> {
ItemCubit(this.name, this.repo) : super(ItemInitial());

final String name;
final WarframestatRepository repo;

Future<void> fetchItem(String uniqueName) async {
try {
Item item;
if (await ConnectionManager.hasInternetConnection) {
item = await repo.fetchItem(uniqueName);
}
Future<void> fetchItem() async {
final item = await _handleItemFetch(() async => repo.fetchItem(name));

item = await ConnectionManager.call(
() async => repo.fetchItem(uniqueName),
);
emit(ItemFetchSuccess(item));
}

Future<void> fetchByName() async {
final items = await _handleItemFetch(() async => repo.searchItems(name));

final item = items
.where((item) => item.imageName != null)
.firstWhereOrNull((item) => name == item.name);

if (item == null) return emit(const NoItemFound());

emit(ItemFetchSuccess(item));
}

Future<void> fetchIncarnonGenesis() async {
final items = await _handleItemFetch(
() async => repo.searchItems('Incarnon'),
);

final item = items.where((item) => item.imageName != null).firstWhereOrNull(
(item) {
return name.replaceAll(' ', '') == item.name.replaceAll(' ', '');
},
);

if (item == null) return emit(const NoItemFound());

emit(ItemFetchSucess(item));
emit(ItemFetchSuccess(item));
}

Future<T> _handleItemFetch<T>(FutureOr<T> Function() compute) async {
try {
return ConnectionManager.call(compute);
} catch (e, s) {
await Sentry.captureException(
e,
stackTrace: s,
hint: Hint.withMap({'uniqueName': uniqueName}),
hint: Hint.withMap({'query': name}),
);

emit(const ItemFetchFailure('Failed to parse item'));

rethrow;
}
}

@override
String get id => name;

@override
ItemState? fromJson(Map<String, dynamic> json) {
final item = MinimalItem.fromJson(json);

return ItemFetchSuccess(item);
}

@override
Map<String, dynamic>? toJson(ItemState state) {
if (state is! ItemFetchSuccess) return null;

return state.item.toJson();
}
}
8 changes: 6 additions & 2 deletions lib/codex/cubit/item_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ sealed class ItemState extends Equatable {

final class ItemInitial extends ItemState {}

final class ItemFetchSucess extends ItemState {
const ItemFetchSucess(this.item);
final class ItemFetchSuccess extends ItemState {
const ItemFetchSuccess(this.item);

final Item item;

Expand All @@ -26,3 +26,7 @@ final class ItemFetchFailure extends ItemState {
@override
List<Object> get props => [message];
}

final class NoItemFound extends ItemState {
const NoItemFound();
}
11 changes: 3 additions & 8 deletions lib/codex/views/codex_search_view.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:animations/animations.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:matomo_tracker/matomo_tracker.dart';
Expand Down Expand Up @@ -69,13 +68,9 @@ class CodexSearchView extends StatelessWidget {
SliverList.builder(
itemCount: state.results.length,
itemBuilder: (BuildContext context, int index) {
return OpenContainer(
closedColor: Theme.of(context).colorScheme.surface,
openColor: Theme.of(context).colorScheme.surface,
openBuilder: (_, __) {
return EntryView(item: state.results[index]);
},
closedBuilder: (_, onTap) {
return EntryViewOpenContainer(
item: state.results[index],
builder: (_, onTap) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: CodexResult(
Expand Down
28 changes: 24 additions & 4 deletions lib/codex/views/entry_view.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:animations/animations.dart';
import 'package:black_hole_flutter/black_hole_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand All @@ -6,19 +7,38 @@ import 'package:navis_ui/navis_ui.dart';
import 'package:warframestat_client/warframestat_client.dart';
import 'package:warframestat_repository/warframestat_repository.dart';

class EntryViewOpenContainer extends StatelessWidget {
const EntryViewOpenContainer({
super.key,
required this.item,
required this.builder,
});

final MinimalItem item;
final Widget Function(BuildContext, void Function()) builder;

@override
Widget build(BuildContext context) {
return OpenContainer(
closedColor: Theme.of(context).colorScheme.surface,
openColor: Theme.of(context).colorScheme.surface,
openBuilder: (_, __) => EntryView(item: item),
closedBuilder: builder,
);
}
}

class EntryView extends StatelessWidget {
const EntryView({super.key, required this.item});

final MinimalItem item;

static const route = '/codexEntry';

@override
Widget build(BuildContext context) {
final repo = RepositoryProvider.of<WarframestatRepository>(context);

return BlocProvider(
create: (context) => ItemCubit(repo)..fetchItem(item.uniqueName),
create: (context) => ItemCubit(item.uniqueName, repo)..fetchItem(),
child: Scaffold(body: SafeArea(child: _Overview(item: item))),
);
}
Expand Down Expand Up @@ -66,7 +86,7 @@ class _Overview extends StatelessWidget {
return Center(child: Text(state.message));
}

if (state is! ItemFetchSucess) {
if (state is! ItemFetchSuccess) {
return const Center(
child: CircularProgressIndicator.adaptive(),
);
Expand Down
Loading

0 comments on commit 9a531a7

Please sign in to comment.