Skip to content

Commit

Permalink
Save theme to cache, update logo
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorAguero committed May 8, 2024
1 parent d0adff3 commit 2044942
Show file tree
Hide file tree
Showing 58 changed files with 330 additions and 115 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions android/app/src/main/res/drawable-v21/launch_background.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
<item>
<bitmap android:gravity="fill" android:src="@drawable/background"/>
</item>
<item>
<bitmap android:gravity="bottom" android:src="@drawable/branding"/>
</item>
</layer-list>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions android/app/src/main/res/drawable/launch_background.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
<item>
<bitmap android:gravity="fill" android:src="@drawable/background"/>
</item>
<item>
<bitmap android:gravity="bottom" android:src="@drawable/branding"/>
</item>
</layer-list>
Binary file modified android/app/src/main/res/mipmap-hdpi/ic_launcher_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-mdpi/ic_launcher_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xhdpi/ic_launcher_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/ic_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/ic_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ic_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
23 changes: 23 additions & 0 deletions ios/Runner/Assets.xcassets/BrandingImage.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "BrandingImage.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
4 changes: 4 additions & 0 deletions ios/Runner/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" image="LaunchBackground" translatesAutoresizingMaskIntoConstraints="NO" id="tWc-Dq-wcI"/>
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4"></imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" image="BrandingImage" translatesAutoresizingMaskIntoConstraints="NO" id="Uyq-Kz-ftE"/>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="Uyq-Kz-ftE" secondAttribute="bottom" id="8Yb-q4-8bl"/>
<constraint firstItem="Uyq-Kz-ftE" firstAttribute="centerX" secondItem="YRO-k0-Ey4" secondAttribute="centerX" id="3kg-TC-cPP"/>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="3T2-ad-Qdv"/>
<constraint firstItem="tWc-Dq-wcI" firstAttribute="bottom" secondItem="Ze5-6b-2t3" secondAttribute="bottom" id="RPx-PI-7Xg"/>
<constraint firstItem="tWc-Dq-wcI" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="SdS-ul-q2q"/>
Expand All @@ -40,5 +43,6 @@
<resources>
<image name="LaunchImage" width="168" height="185"/>
<image name="LaunchBackground" width="1" height="1"/>
<image name="BrandingImage" width="1" height="1"/>
</resources>
</document>
2 changes: 1 addition & 1 deletion lib/features/home/home_page_controller.g.dart

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

6 changes: 4 additions & 2 deletions lib/features/home/widgets/settings_theme_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import '../../../common_widgets/app_cupertino_button.dart';
import '../../../constants.dart';
import '../../../core/extensions/app_localization_extension.dart';
import '../../../core/extensions/theme_of_context_extension.dart';
import '../../../theme/app_theme_colors.dart';
import '../../../theme/theme_mode_controller.dart';
import '../../../utils/app_loggers.dart';

Expand Down Expand Up @@ -64,7 +65,8 @@ class SettingsThemeSection extends ConsumerWidget {
Consumer(
builder: (context, ref, child) {
final colors = ref.watch(appSelectedColorsProvider);
final isDefault = colors.name == AppColors.defaultColors().name;
final isDefault =
colors.name == AppThemeColors.defaultColors().name;

return CupertinoListTile(
backgroundColor: context.colorScheme.surface,
Expand All @@ -76,7 +78,7 @@ class SettingsThemeSection extends ConsumerWidget {
? null
: () => ref
.read(appSelectedColorsProvider.notifier)
.setThemeColors(AppColors.defaultColors()),
.setThemeColors(AppThemeColors.defaultColors()),
child: Text(isDefault ? '' : context.loc.resetTheme),
),
subtitle: Text(
Expand Down
4 changes: 1 addition & 3 deletions lib/features/parades/parades_tab_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ class ParadesTabController extends _$ParadesTabController {

@override
FutureOr<ImmutableList<Parade>> build() async {
final parades = await getParades();

return parades;
return getParades();
}

Future<bool?> fetchNextPage({int pageSize = _pageSize}) async {
Expand Down
2 changes: 1 addition & 1 deletion lib/features/parades/parades_tab_controller.g.dart

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

3 changes: 2 additions & 1 deletion lib/features/schools/details/school_details_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import '../../../core/extensions/app_localization_extension.dart';
import '../../../core/extensions/intl_extension.dart';
import '../../../core/extensions/string_extensions.dart';
import '../../../core/extensions/theme_of_context_extension.dart';
import '../../../theme/app_theme_colors.dart';
import '../../../theme/theme_mode_controller.dart';
import '../school.dart';
import '../school_extensions.dart';
Expand Down Expand Up @@ -158,7 +159,7 @@ class _SchoolDetailsTextState extends ConsumerState<SchoolDetailsText> {
void setColors() {
final schoolColors = widget.school.colorsCode;
if (schoolColors.isNotEmpty) {
final colors = AppColors(
final colors = AppThemeColors(
primary: schoolColors.first,
name: widget.school.name,
secondary: schoolColors.elementAtOrNull(1),
Expand Down
4 changes: 2 additions & 2 deletions lib/features/schools/schools_tab_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ part 'schools_tab_controller.g.dart';

@riverpod
class SchoolsTabController extends _$SchoolsTabController {
static const _pageSize = 12;
static const _pageSize = 10;

@override
Future<ImmutableList<School>> build() async {
FutureOr<ImmutableList<School>> build() async {
return getSchools(pageSize: _pageSize);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/features/schools/widgets/school_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class _SchoolCardState extends ConsumerState<SchoolCard> {
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
if (school.colors.isEmpty)
if (school.colorsCode.isEmpty)
for (final _ in Iterable<int>.generate(2))
CupertinoDynamicColor.resolve(
CupertinoColors.systemGrey5,
Expand Down
16 changes: 10 additions & 6 deletions lib/features/schools/widgets/school_flag.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:skeletonizer/skeletonizer.dart';
import '../../../common_widgets/app_fade_in_image.dart';
import '../../../core/extensions/app_localization_extension.dart';
import '../../../core/extensions/theme_of_context_extension.dart';
Expand Down Expand Up @@ -54,12 +55,15 @@ class SchoolFlag extends ConsumerWidget {
},
child: AspectRatio(
aspectRatio: 3 / 2,
child: school.imageUrl.isNotEmpty
? AppFadeInImage(
school.imageUrl,
fit: BoxFit.cover,
)
: EmptyImage(colors: school.colorsCode),
child: Skeleton.replace(
child: AppFadeInImage(
school.imageUrl,
fit: BoxFit.cover,
imageErrorBuilder: (context, error, stackTrace) => EmptyImage(
colors: school.colorsCode,
),
),
),
),
),
),
Expand Down
44 changes: 44 additions & 0 deletions lib/features/schools/widgets/schools_tab_body.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:const_date_time/const_date_time.dart';
import 'package:dynamic_height_grid_view/dynamic_height_grid_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:skeletonizer/skeletonizer.dart';
import 'package:sliver_tools/sliver_tools.dart';

import '../../../common_widgets/app_animation_wrapper.dart';
Expand All @@ -24,6 +26,22 @@ class SchoolsTabBody extends ConsumerWidget {
sliver: AppAsyncSliverWidget(
asyncValue: ref.watch(schoolsTabControllerProvider),
onErrorRetry: () => ref.invalidate(schoolsTabControllerProvider),
loadingSliver: SliverCrossAxisConstrained(
maxCrossAxisExtent: ScreenSize.lg.value,
child: SliverPadding(
padding: EdgeInsets.only(
left: 16,
right: 16 + rightInset(),
),
sliver: SliverSkeletonizer(
child: SliverSchoolsList(
schools: ImmutableList(
[for (var i = 0; i < 10; i++) _schoolSkeleton],
),
),
),
),
),
child: (_) => Consumer(
builder: (_, ref, __) {
final schools = ref.watch(filteredSchoolsProvider);
Expand Down Expand Up @@ -67,6 +85,7 @@ class SliverSchoolsList extends StatelessWidget {
final school = schools[index];

return AppAnimationWrapper(
start: schools.length > 10 ? 0.6 : 1.0,
child: ProviderScope(
overrides: [
currentSchoolProvider.overrideWithValue(school),
Expand All @@ -78,3 +97,28 @@ class SliverSchoolsList extends StatelessWidget {
);
}
}

School get _schoolSkeleton => const School(
id: 1,
name: "name",
translatedName: "translatedName",
imageUrl: "",
foundationDate: ConstDateTime(2024),
godmotherSchool: "godmotherSchool",
colors: IListConst([]),
colorsCode: IListConst([]),
symbols: IListConst([]),
carnivalCategory: SchoolCategory.escolasDeSamba,
currentDivision: SchoolDivision.especial,
divisionNumber: 1,
subdivisionNumber: 1,
firstDivisionChampionships: 1,
country: "country",
leagueLocation: "leagueLocation",
lastPosition: 1,
translatedColors: IListConst([]),
translatedSymbols: IListConst([]),
translatedGodmotherSchool: "translatedGodmotherSchool",
translatedLeagueLocation: "translatedLeagueLocation",
translatedCountry: "translatedCountry",
);
1 change: 0 additions & 1 deletion lib/routing/app_router.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

Expand Down
4 changes: 2 additions & 2 deletions lib/routing/app_router.g.dart

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

6 changes: 3 additions & 3 deletions lib/theme/app_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import 'package:flex_color_scheme/flex_color_scheme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'theme_mode_controller.dart';
import 'app_theme_colors.dart';

const _iOSFontLetterSpacing = -1.5;

class AppTheme {
static ThemeData lightTheme(AppColors colors) => FlexThemeData.light(
static ThemeData lightTheme(AppThemeColors colors) => FlexThemeData.light(
useMaterial3: true,
keyColors: FlexKeyColors(
useSecondary: colors.secondary != null,
Expand Down Expand Up @@ -49,7 +49,7 @@ class AppTheme {
),
);

static ThemeData darkTheme(AppColors colors, {required bool trueBlack}) {
static ThemeData darkTheme(AppThemeColors colors, {required bool trueBlack}) {
return FlexThemeData.dark(
useMaterial3: true,
keyColors: FlexKeyColors(
Expand Down
54 changes: 54 additions & 0 deletions lib/theme/app_theme_colors.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import 'package:dart_mappable/dart_mappable.dart';
import 'package:flutter/material.dart';

import '../constants.dart';

part 'app_theme_colors.mapper.dart';

@MappableClass(includeCustomMappers: [ColorMapper()])
class AppThemeColors with AppThemeColorsMappable {
final Color primary;
final Color? secondary;
final Color? tertiary;
final String name;

static const fromMap = AppThemeColorsMapper.fromMap;
static const fromJson = AppThemeColorsMapper.fromJson;

AppThemeColors({
required this.primary,
required this.name,
this.secondary,
this.tertiary,
});

AppThemeColors.defaultColors()
: primary = const Color(0xffff00a5),
name = Constants.defaultColorName,
secondary = const Color(0xff00a859),
tertiary = null;
}

extension AppColorsExtension on AppThemeColors {
int get usedColors {
return (secondary != null ? 1 : 0) + (tertiary != null ? 1 : 0) + 1;
}
}

class ColorMapper extends SimpleMapper<Color> {
const ColorMapper();

@override
Color decode(dynamic value) {
if (value is int) {
return Color(value);
}

return Color(int.parse(value.toString()));
}

@override
dynamic encode(Color self) {
return self.value;
}
}
Loading

0 comments on commit 2044942

Please sign in to comment.