Skip to content

Commit

Permalink
Merge pull request #47 from andannn/avtivity_function
Browse files Browse the repository at this point in the history
Avtivity function
  • Loading branch information
andannn authored Nov 5, 2023
2 parents 1e46b29 + 56c6957 commit b3a8915
Show file tree
Hide file tree
Showing 93 changed files with 4,256 additions and 376 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Generated file.
//
// If you wish to remove Flutter's multidex support, delete this entire file.
//
// Modifications to this file should be done in a copy under a different name
// as this file may be regenerated.

package io.flutter.app;

import android.app.Application;
import android.content.Context;
import androidx.annotation.CallSuper;
import androidx.multidex.MultiDex;

/**
* Extension of {@link android.app.Application}, adding multidex support.
*/
public class FlutterMultiDexApplication extends Application {
@Override
@CallSuper
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
12 changes: 6 additions & 6 deletions lib/app/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:aniflow/core/common/model/media_type.dart';
import 'package:aniflow/core/data/auth_repository.dart';
import 'package:aniflow/core/data/media_information_repository.dart';
import 'package:aniflow/core/data/media_list_repository.dart';
import 'package:aniflow/core/data/user_data_repository.dart';
import 'package:aniflow/core/data/settings_repository.dart';
import 'package:aniflow/core/design_system/theme/colors.dart';
import 'package:aniflow/core/design_system/widget/vertical_animated_scale_switcher.dart';
import 'package:aniflow/feature/discover/bloc/discover_bloc.dart';
Expand Down Expand Up @@ -108,7 +108,7 @@ class _AnimeTrackerAppScaffoldState extends State<AnimeTrackerAppScaffold> {
var currentNavigation = TopLevelNavigation.discover;
var needHideNavigationBar = false;
var showFloatingButton = true;
late UserDataRepository userDataRepository = UserDataRepositoryImpl();
late SettingsRepository userDataRepository = SettingsRepositoryImpl();
late StreamSubscription _mediaTypeSub;
MediaType _mediaType = MediaType.anime;

Expand Down Expand Up @@ -150,16 +150,16 @@ class _AnimeTrackerAppScaffoldState extends State<AnimeTrackerAppScaffold> {
BlocProvider(
create: (context) =>
DiscoverBloc(
userDataRepository: context.read<UserDataRepository>(),
aniListRepository: context.read<MediaInformationRepository>(),
settingsRepository: context.read<SettingsRepository>(),
mediaRepository: context.read<MediaInformationRepository>(),
authRepository: context.read<AuthRepository>(),
animeTrackListRepository: context.read<MediaListRepository>(),
),
),
BlocProvider(
create: (context) =>
TrackBloc(
userDataRepository: context.read<UserDataRepository>(),
settingsRepository: context.read<SettingsRepository>(),
mediaListRepository: context.read<MediaListRepository>(),
authRepository: context.read<AuthRepository>(),
),
Expand Down Expand Up @@ -206,7 +206,7 @@ class _AnimeTrackerAppScaffoldState extends State<AnimeTrackerAppScaffold> {
Widget _buildTopFloatingActionButton() {
return FloatingActionButton.extended(
onPressed: () {
final repository = context.read<UserDataRepository>();
final repository = context.read<SettingsRepository>();
if (_mediaType == MediaType.manga) {
repository.setMediaType(MediaType.anime);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:aniflow/app/local/ani_flow_localizations.dart';
import 'package:aniflow/core/common/model/activity_filter_type.dart';
import 'package:aniflow/core/common/model/anime_season.dart';
import 'package:aniflow/core/common/model/anime_source.dart';
import 'package:aniflow/core/common/model/character_role.dart';
Expand Down Expand Up @@ -102,3 +103,11 @@ extension AnimeModelEx on MediaModel {
return airingTimeString;
}
}

extension ActivityFilterTypeEx on ActivityFilterType {
String label(BuildContext context) => switch(this) {
ActivityFilterType.all => 'All',
ActivityFilterType.text => 'Text',
ActivityFilterType.list => 'List',
};
}
18 changes: 13 additions & 5 deletions lib/app/navigation/ani_flow_route_path.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import 'package:aniflow/feature/anime_search/media_search.dart';
import 'package:aniflow/feature/character_page/character_page.dart';
import 'package:aniflow/feature/detail_media/detail_media.dart';
import 'package:aniflow/feature/discover/discover.dart';
import 'package:aniflow/feature/forum/profile.dart';
import 'package:aniflow/feature/media_page/media_page.dart';
import 'package:aniflow/feature/media_track/media_track.dart';
import 'package:aniflow/feature/profile/profile.dart';
import 'package:aniflow/feature/social/social.dart';
import 'package:aniflow/feature/staff_page/staff_page.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -39,8 +39,8 @@ class TrackRoutePath extends TopLevelRoutePath {
const TrackRoutePath() : super(TopLevelNavigation.track);
}

class ForumRoutePath extends TopLevelRoutePath {
const ForumRoutePath() : super(TopLevelNavigation.forum);
class SocialRoutePath extends TopLevelRoutePath {
const SocialRoutePath() : super(TopLevelNavigation.social);
}

class ProfileRoutePath extends TopLevelRoutePath {
Expand All @@ -51,6 +51,12 @@ class SearchRoutePath extends AniFlowRoutePath {
const SearchRoutePath() : super(isFullScreen: true);
}

class UserProfileRoutePath extends AniFlowRoutePath {
const UserProfileRoutePath(this.userId);

final String userId;
}

class AnimeListRoutePath extends AniFlowRoutePath {
const AnimeListRoutePath(this.category) : super(isFullScreen: true);

Expand Down Expand Up @@ -118,10 +124,12 @@ extension AniFlowRoutePathEx on AniFlowRoutePath {
);
case TrackRoutePath(topLevel: final _):
return const AnimeTrackPage(key: ValueKey('AnimeTrackPage'));
case ForumRoutePath(topLevel: final _):
return const ForumPage(key: ValueKey('ForumPage'));
case SocialRoutePath(topLevel: final _):
return const SocialPage(key: ValueKey('SocialPage'));
case ProfileRoutePath(topLevel: final _):
return const ProfilePage(key: ValueKey('ProfilePage'));
case UserProfileRoutePath(userId: final id):
return ProfilePage(key: ValueKey('ProfilePage_$id'), userId: id);
case AiringScheduleRoutePath():
return const AiringSchedule(key: ValueKey('AiringSchedule'));
case SearchRoutePath():
Expand Down
4 changes: 4 additions & 0 deletions lib/app/navigation/ani_flow_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ class AFRouterDelegate extends RouterDelegate<AniFlowRoutePath>
_pushAsSingleton(const SearchRoutePath());
}

void navigateToUserProfile(String userId) {
_pushAsSingleton(UserProfileRoutePath(userId));
}

void _pushAsSingleton(AniFlowRoutePath path) {
if (_backStack.contains(path)) {
_backStack.remove(path);
Expand Down
8 changes: 4 additions & 4 deletions lib/app/navigation/top_level_navigation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ enum TopLevelNavigation {
unSelectedIcon: Icons.collections_bookmark_outlined,
iconTextId: 'Track',
),
forum(
social(
selectedIcon: Icons.forum,
unSelectedIcon: Icons.forum_outlined,
iconTextId: 'Forum',
iconTextId: 'Social',
),
profile(
selectedIcon: Icons.person,
Expand Down Expand Up @@ -49,8 +49,8 @@ extension TopLevelNavigationEx on TopLevelNavigation {
return const DiscoverRoutePath();
case TopLevelNavigation.track:
return const TrackRoutePath();
case TopLevelNavigation.forum:
return const ForumRoutePath();
case TopLevelNavigation.social:
return const SocialRoutePath();
case TopLevelNavigation.profile:
return const ProfileRoutePath();
}
Expand Down
24 changes: 24 additions & 0 deletions lib/core/common/model/activity_filter_type.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:freezed_annotation/freezed_annotation.dart';

part 'activity_filter_type.g.dart';

@JsonEnum(alwaysCreate: true)
enum ActivityFilterType {
/// no filter.
@JsonValue('ALL')
all,

/// only test activity.
@JsonValue('TEXT')
text,

/// only list activity
@JsonValue('LIST')
list;

String toJson() => _$ActivityFilterTypeEnumMap[this]!;

factory ActivityFilterType.fromJson(String json) =>
_$ActivityFilterTypeEnumMap
.map((key, value) => MapEntry(value, key))[json]!;
}
13 changes: 13 additions & 0 deletions lib/core/common/model/activity_filter_type.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions lib/core/common/model/activity_scope_category.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:freezed_annotation/freezed_annotation.dart';

part 'activity_scope_category.g.dart';

@JsonEnum(alwaysCreate: true)
enum ActivityScopeCategory {
/// show activities of all users..
@JsonValue('GLOBAL')
global,

/// show activities of following users.
@JsonValue('FOLLOWING')
following;

String toJson() => _$ActivityScopeCategoryEnumMap[this]!;

factory ActivityScopeCategory.fromJson(String json) =>
_$ActivityScopeCategoryEnumMap
.map((key, value) => MapEntry(value, key))[json]!;
}

12 changes: 12 additions & 0 deletions lib/core/common/model/activity_scope_category.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions lib/core/common/model/activity_type.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:freezed_annotation/freezed_annotation.dart';

part 'activity_type.g.dart';

/// Bangumi releasing season.
@JsonEnum(alwaysCreate: true)
enum ActivityType {
/// A text activity
@JsonValue('TEXT')
text,

/// A anime list update activity
@JsonValue('ANIME_LIST')
animeList,

/// A manga list update activity
@JsonValue('MANGA_LIST')
mangaList,

/// A text message activity sent to another user
@JsonValue('MESSAGE')
message,

/// Anime & Manga list update, only used in query arguments
@JsonValue('MEDIA_LIST')
mediaList;

String toJson() => _$ActivityTypeEnumMap[this]!;

factory ActivityType.fromJson(String json) =>
_$ActivityTypeEnumMap.map((key, value) => MapEntry(value, key))[json]!;
}
15 changes: 15 additions & 0 deletions lib/core/common/model/activity_type.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions lib/core/common/model/extension/activity_type_extension.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import 'package:aniflow/core/common/model/activity_filter_type.dart';
import 'package:aniflow/core/common/model/activity_scope_category.dart';

extension ActivityTypeEx on (ActivityFilterType, ActivityScopeCategory) {
String get combineJsonKey => '${this.$1.toJson()}_${this.$2.toJson()}';
}
8 changes: 8 additions & 0 deletions lib/core/common/util/change_notifier_util.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

import 'package:flutter/cupertino.dart';

extension IntValueNotifierEx on ValueNotifier<int> {
void notifyChanged() {
value = value++;
}
}
6 changes: 5 additions & 1 deletion lib/core/common/util/global_static_constants.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

// ignore_for_file: lines_longer_than_80_chars

mixin Config {
static const defaultAnimationDuration = Duration(milliseconds: 300);
static const defaultCatchExtend = 300.0;
Expand All @@ -7,7 +9,9 @@ mixin Config {
static const int defaultPerPageCount = 18;

static const int profilePageDefaultPerPageCount = 6;
static const int activityPageDefaultPerPageCount = 50;
}

/// Only for test
var isUnitTest = false;

String testToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImNlNjM4MGQ2MTY0YjFmYjdhZmUzZjA0NTM0ZTVlNDJlZmM2MDQwNjNhYjAyYjdjOWRmYWUwODVmNTQ4Yjk0YWEzNDZmZDE5MTEyNDU3Njc4In0.eyJhdWQiOiIxNDQwOSIsImp0aSI6ImNlNjM4MGQ2MTY0YjFmYjdhZmUzZjA0NTM0ZTVlNDJlZmM2MDQwNjNhYjAyYjdjOWRmYWUwODVmNTQ4Yjk0YWEzNDZmZDE5MTEyNDU3Njc4IiwiaWF0IjoxNjk4ODI5MDgyLCJuYmYiOjE2OTg4MjkwODIsImV4cCI6MTczMDQ1MTQ4Miwic3ViIjoiNjM3ODM5MyIsInNjb3BlcyI6W119.sVv96g4xST4QnJucV5O3vNOy2hseu8EZGTsOpx8SOC0Zgp1LTAQj585U32QY900IF8VXlikoFvTPWM0cU0QASx7mCnTeG75vMNxUpzTOoZ6cQbVUFKF0NzOVPkWldVt4m7Wn79wrwGa91Oal6Hj5r8TiICzg_vOZb-dTpkWFiAeZ2CEcuw7099_FaBKLNMspMGPwhRh7xdfiLTvMTRLUdPtwz6TQf7lLtsKVx1Qz0LLIuZluEVb5gBu43N5GHPRbj2JwDJQxsZ6nL95QwrA2LOBIasYltr90mShC78gj0eDOM7Hf84Gioekz26-VJTivWxXSS3mklGPq4WAtHVzfEBdkduhRl-GySsGQoQZamDZdyc4ikii_AOlKH6-aPRPVj5KI1ecC4Wiw5pZHGntGoP2m8fJlprGufawpwbjqo-_Ki0qPyJSSYqJgDWekFC2Wm8-IkyZzDsCca8NXo_EkAow-j54rqLldEZrCT1pzxI9YIHUmsheVMkQfA5-5VCS-zL_qW5o0DYM1P8QVyKJGtgCrL83UOABANLSC__SKhXIH4eiD6LI-lCeiVgaiIv6lwzn2PATFvOJeTv0uUJGkhSLELIJlDhDZ88TwwHUzbxNVjXj5OnywAGHYO09SdZNs1YI3ATccTzMq96SWXN9rzY1If7h8XKts-NzX1esINjM';
Loading

0 comments on commit b3a8915

Please sign in to comment.