Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
55946fa
:art: added new core classes
sarbagyastha Dec 30, 2022
2b0c27a
:truck: reorganize classes
sarbagyastha Dec 30, 2022
94832ec
:truck: reorganize ui classes
sarbagyastha Dec 30, 2022
5b0d693
:truck: move example outside of the package
sarbagyastha Dec 30, 2022
0b289c8
:sparkles: added new example app
sarbagyastha Dec 30, 2022
4340712
:white_check_mark: added gateway test
sarbagyastha Jan 2, 2023
41bbf5b
:white_check_mark: added use case tests
sarbagyastha Jan 2, 2023
5033bca
:white_check_mark: added use case transformer tests
sarbagyastha Jan 2, 2023
2247aae
:white_check_mark: refined transformer tests
sarbagyastha Jan 2, 2023
5bba046
:rotating_light: made analyzer happy
sarbagyastha Jan 2, 2023
8765f80
Merge pull request #96 from MattHamburger/pv2-tests
sarbagya-acme Jan 2, 2023
3a488a6
:sparkles: everything is place for example
sarbagyastha Jan 3, 2023
2cf04e3
:bug: fixed issue while using old classes
sarbagyastha Jan 4, 2023
3b82918
:lipstick: added palette card
sarbagyastha Jan 4, 2023
b472d6a
:lipstick: design improvements
sarbagyastha Jan 4, 2023
50fab77
:lipstick: show pokemon name in caps
sarbagyastha Jan 4, 2023
f443dc0
:lipstick: design refinement
sarbagyastha Jan 4, 2023
b92e2b5
:bug: minor fix
sarbagyastha Jan 4, 2023
e8643f2
:sparkles: added pokemon search
sarbagyastha Jan 4, 2023
06394cd
:art: added pokemon search field widget
sarbagyastha Jan 4, 2023
63dc8fa
:art: added pokemon card widget
sarbagyastha Jan 4, 2023
d0ccfcc
:sparkles: added refresh indicator
sarbagyastha Jan 4, 2023
f61c0a8
:sparkles: added loading failed ui
sarbagyastha Jan 4, 2023
700e5d4
:sparkles: implemented router
sarbagyastha Jan 4, 2023
8fa64f0
:sparkles: added profile page
sarbagyastha Jan 4, 2023
c890420
:sparkles: added cached image
sarbagyastha Jan 4, 2023
43171bc
:sparkles: added spotlight image
sarbagyastha Jan 5, 2023
deb247a
:lipstick: improved transition
sarbagyastha Jan 5, 2023
5df94e9
:lipstick: setup spotlight
sarbagyastha Jan 5, 2023
8c70f46
:sparkles: added pokemon profile gateway
sarbagyastha Jan 5, 2023
dd1d739
:bug: minor fix
sarbagyastha Jan 5, 2023
b674d88
:sparkles: added pokemon type
sarbagyastha Jan 5, 2023
f13d95c
:sparkles: added pokemon description
sarbagyastha Jan 5, 2023
34a7a3e
:sparkles: added height weight
sarbagyastha Jan 5, 2023
f6d739a
:lipstick: fixed gradient
sarbagyastha Jan 5, 2023
339f24a
:lipstick: minor fix
sarbagyastha Jan 5, 2023
76b37e4
:truck: moved models to separate dir
sarbagyastha Jan 5, 2023
0a575db
:bug: minor fix
sarbagyastha Jan 5, 2023
27ef795
:art:
sarbagyastha Jan 5, 2023
55ee486
:sparkles: added stats
sarbagyastha Jan 5, 2023
be2df0e
:white_check_mark:
sarbagyastha Jan 5, 2023
ed6cd45
:white_check_mark: fixed failing test
sarbagyastha Jan 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
✨ added stats
  • Loading branch information
sarbagyastha committed Jan 5, 2023
commit 55ee486a38d4622fe7f88372b71c8913103f52f8
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class HomeUI extends UI<HomeViewModel> {
final pokemon = viewModel.pokemons[index];

return PokemonCard(
key: ValueKey(pokemon.name),
imageUrl: pokemon.imageUrl,
name: pokemon.name,
heroTag: pokemon.name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
import 'package:clean_framework/clean_framework_core.dart';
import 'package:clean_framework_example/features/profile/models/pokemon_profile_model.dart';

class ProfileEntity extends Entity {
ProfileEntity({
this.types = const [],
this.description = '',
this.height = 0,
this.weight = 0,
this.stats = const [],
});

final List<String> types;
final String description;
final int height;
final int weight;
final List<PokemonStatModel> stats;

@override
List<Object?> get props => [types, description, height, weight];
List<Object?> get props => [types, description, height, weight, stats];

@override
ProfileEntity copyWith({
List<String>? types,
String? description,
int? height,
int? weight,
List<PokemonStatModel>? stats,
}) {
return ProfileEntity(
types: types ?? this.types,
description: description ?? this.description,
height: height ?? this.height,
weight: weight ?? this.weight,
stats: stats ?? this.stats,
);
}
}

class PokemonStat {
PokemonStat({required this.name, required this.point});

final String name;
final int point;
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import 'package:clean_framework/clean_framework_core.dart';
import 'package:clean_framework_example/features/profile/domain/profile_entity.dart';

class ProfileUIOutput extends Output {
ProfileUIOutput({
required this.types,
required this.description,
required this.height,
required this.weight,
required this.stats,
});

final List<String> types;
final String description;
final double height;
final double weight;
final List<PokemonStat> stats;

@override
List<Object?> get props => [types, description, height, weight];
List<Object?> get props => [types, description, height, weight, stats];
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ProfileUseCase extends UseCase<ProfileEntity> {
types: profile.types,
height: profile.height,
weight: profile.weight,
stats: profile.stats,
);
},
onFailure: (failure) => entity,
Expand All @@ -54,9 +55,25 @@ class ProfileUIOutputTransformer
ProfileUIOutput transform(ProfileEntity entity) {
return ProfileUIOutput(
types: entity.types,
description: entity.description,
description: entity.description.replaceAll(RegExp(r'[\n\f]'), ' '),
height: entity.height / 10,
weight: entity.weight / 10,
stats: entity.stats.map(
(s) {
return PokemonStat(
name: _kebabToTitleCase(s.name),
point: s.baseStat,
);
},
).toList(growable: false),
);
}

String _kebabToTitleCase(String input) {
return input
.replaceAll('special', 'sp.')
.split('-')
.map((s) => s[0].toUpperCase() + s.substring(1))
.join(' ');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ class ProfilePresenter
) {
return ProfileViewModel(
pokemonTypes: output.types.map(PokemonType.new).toList(growable: false),
description: output.description.replaceAll(RegExp(r'[\n\f]'), ' '),
description: output.description,
height: '📏 ${output.height} m',
weight: '⚖️ ${output.weight} kg',
stats: output.stats,
);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:clean_framework/clean_framework_core.dart';
import 'package:clean_framework_example/features/profile/domain/profile_entity.dart';
import 'package:clean_framework_example/features/profile/presentation/profile_presenter.dart';
import 'package:clean_framework_example/features/profile/presentation/profile_view_model.dart';
import 'package:clean_framework_example/widgets/spotlight.dart';
Expand Down Expand Up @@ -38,25 +39,29 @@ class ProfileUI extends UI<ProfileViewModel> {
borderRadius: BorderRadius.circular(48),
),
child: Padding(
padding: const EdgeInsets.fromLTRB(24, 88, 24, 16),
child: Column(
children: [
Wrap(
runSpacing: 8,
spacing: 8,
children: pokeTypes.map(_PokeTypeChip.new).toList(),
),
const SizedBox(height: 16),
Text(
viewModel.description,
style: Theme.of(context).textTheme.bodySmall,
),
const SizedBox(height: 16),
_BodyMeasurement(
height: viewModel.height,
weight: viewModel.weight,
),
],
padding: const EdgeInsets.fromLTRB(24, 96, 24, 16),
child: SingleChildScrollView(
child: Column(
children: [
Wrap(
runSpacing: 8,
spacing: 8,
children: pokeTypes.map(_PokeTypeChip.new).toList(),
),
const SizedBox(height: 24),
Text(
viewModel.description,
style: Theme.of(context).textTheme.bodySmall,
),
const SizedBox(height: 24),
_BodyMeasurement(
height: viewModel.height,
weight: viewModel.weight,
),
const SizedBox(height: 32),
_ProfileStats(stats: viewModel.stats),
],
),
),
),
);
Expand All @@ -66,6 +71,74 @@ class ProfileUI extends UI<ProfileViewModel> {
}
}

class _ProfileStats extends StatelessWidget {
const _ProfileStats({required this.stats});

final List<PokemonStat> stats;

@override
Widget build(BuildContext context) {
return Column(
children: [
for (final stat in stats)
Padding(
padding: const EdgeInsets.all(6),
child: _StatRow(stat: stat),
),
],
);
}
}

class _StatRow extends StatelessWidget {
const _StatRow({required this.stat});

final PokemonStat stat;

@override
Widget build(BuildContext context) {
final themeData = Theme.of(context);
final primaryColor = themeData.colorScheme.primary;
final pointFraction = stat.point / 255;

return Row(
children: [
Expanded(
flex: 2,
child: Row(
children: [
Expanded(
child: Text(
stat.name,
style: themeData.textTheme.bodySmall,
),
),
const SizedBox(width: 16),
Text(
stat.point.toString(),
style: themeData.textTheme.titleSmall,
),
],
),
),
const SizedBox(width: 32),
Expanded(
flex: 3,
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: LinearProgressIndicator(
color: primaryColor.withAlpha(stat.point),
value: pointFraction,
minHeight: 8,
backgroundColor: themeData.colorScheme.surfaceVariant,
),
),
),
],
);
}
}

class _BodyMeasurement extends StatelessWidget {
const _BodyMeasurement({
required this.height,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:clean_framework/clean_framework_core.dart';
import 'package:clean_framework_example/features/profile/domain/profile_entity.dart';
import 'package:flutter/material.dart';

class ProfileViewModel extends ViewModel {
Expand All @@ -7,15 +8,17 @@ class ProfileViewModel extends ViewModel {
required this.description,
required this.height,
required this.weight,
required this.stats,
});

final List<PokemonType> pokemonTypes;
final String description;
final String height;
final String weight;
final List<PokemonStat> stats;

@override
List<Object?> get props => [pokemonTypes, description, height, weight];
List<Object?> get props => [pokemonTypes, description, height, weight, stats];
}

class PokemonType {
Expand Down