Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/77 scoresection #136

Merged
merged 16 commits into from
Oct 1, 2024
3 changes: 3 additions & 0 deletions assets/company/unpublished.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
170 changes: 170 additions & 0 deletions lib/pages/detail/ company_score_widget.dart
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
import 'package:flutter/material.dart';
import 'package:pola_flutter/i18n/strings.g.dart';
import 'package:pola_flutter/theme/assets.gen.dart';
import 'package:pola_flutter/theme/colors.dart';
import 'package:pola_flutter/theme/fonts.gen.dart';
import 'package:pola_flutter/theme/text_size.dart';
import 'polish_capital_graph.dart';

class CompanyScoreData {
final double plCapital;
final bool plWorkers;
final bool plRnD;
final bool plRegistered;
final bool plNotGlobEnt;
final int plScore;

CompanyScoreData(
{required this.plCapital,
required this.plWorkers,
required this.plRnD,
required this.plRegistered,
required this.plNotGlobEnt,
required this.plScore});
}

class CompanyScoreWidget extends StatelessWidget {
final CompanyScoreData data;

const CompanyScoreWidget({super.key, required this.data});

@override
Widget build(BuildContext context) {
final Translations t = Translations.of(context);

return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Align(
alignment: Alignment.centerLeft,
child: Row(
children: [
Assets.company.info.svg(height: 24.0, width: 24.0),
const SizedBox(width: 8.0),
Text(
t.companyScreen.ourRating,
style: TextStyle(
fontSize: TextSize.mediumTitle,
fontWeight: FontWeight.w600,
fontFamily: FontFamily.lato,
color: AppColors.text,
),
),
const SizedBox(width: 8.0),
Text(
t.companyScreen.points(score: data.plScore),
style: TextStyle(
fontSize: TextSize.newsTitle,
fontWeight: FontWeight.w700,
fontFamily: FontFamily.lato,
color: AppColors.text,
),
),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: LinearProgressIndicator(
value: data.plScore / 100.0,
backgroundColor: AppColors.buttonBackground,
valueColor:
const AlwaysStoppedAnimation<Color>(AppColors.defaultRed),
minHeight: 12.0,
),
),
),
const SizedBox(height: 17.0),
Divider(
thickness: 1.0,
color: AppColors.divider,
indent: 0,
endIndent: 0,
),
Padding(
padding: const EdgeInsets.only(top: 22.0),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
t.companyScreen.gradingCriteria,
style: TextStyle(
fontSize: TextSize.mediumTitle,
fontWeight: FontWeight.w600,
fontFamily: FontFamily.lato,
color: AppColors.text,
),
),
),
),
const SizedBox(height: 22.0),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
PolishCapitalGraph(percentage: data.plCapital),
const SizedBox(width: 35.0),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_DetailItem(t.companyScreen.producedInPoland, data.plWorkers),
const SizedBox(height: 14.0),
_DetailItem(t.companyScreen.researchInPoland, data.plRnD),
const SizedBox(height: 14.0),
_DetailItem(
t.companyScreen.registeredInPoland, data.plRegistered),
const SizedBox(height: 14.0),
_DetailItem(
t.companyScreen.notConcernPart, data.plNotGlobEnt),
],
),
),
],
),
const SizedBox(height: 22.0),
Divider(
thickness: 1.0,
color: AppColors.divider,
indent: 0,
endIndent: 0,
),
],
);
}
}

class _DetailItem extends StatelessWidget {
const _DetailItem(this.text, this.state, {Key? key}) : super(key: key);

final String text;
final bool state;

@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(right: 3.0),
child: state
? Assets.company.taskAlt.svg()
: Assets.company.radioButtonUnchecked.svg()),
Expanded(
child: Text(
text,
style: TextStyle(
fontSize: TextSize.description,
fontWeight: FontWeight.w400,
fontFamily: FontFamily.lato,
color: AppColors.text,
),
softWrap: true,
overflow: TextOverflow.visible,
),
),
],
);
}
}
89 changes: 76 additions & 13 deletions lib/pages/detail/detail_content.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'package:flutter/material.dart';
import 'package:flutter/material.dart';
import 'package:pola_flutter/models/company.dart';
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved
import 'package:pola_flutter/models/search_result.dart';
import 'package:pola_flutter/i18n/strings.g.dart';
import 'package:pola_flutter/theme/assets.gen.dart';
import 'package:pola_flutter/theme/assets.gen.dart';
import 'package:pola_flutter/theme/colors.dart';
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved
import 'package:pola_flutter/theme/fonts.gen.dart';
import 'package:pola_flutter/theme/text_size.dart';
import 'logotypes.dart';
import ' company_score_widget.dart';
import 'expandandable_text.dart';
import 'polish_capital_graph.dart';
import 'logotypes.dart';
import 'polish_capital_graph.dart';
import 'friends_bar.dart';
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved

class DetailContent extends StatelessWidget {
Expand All @@ -18,7 +19,7 @@ class DetailContent extends StatelessWidget {

@override
Widget build(BuildContext context) {
if (searchResult.companies == null) {
if (searchResult.companies == null || searchResult.companies!.isEmpty) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Text(searchResult.altText ?? ""),
Expand All @@ -36,14 +37,15 @@ class DetailContent extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if ((company.isFriend ?? false))
FriendsBar(),
if ((company.isFriend ?? false)) FriendsBar(),
const SizedBox(height: 20.0),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 17.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_ScoreSection(company: company),

Align(
alignment: Alignment.centerLeft,
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved
child: Row(
Expand Down Expand Up @@ -78,9 +80,9 @@ class DetailContent extends StatelessWidget {
borderRadius: BorderRadius.circular(10.0),
child: LinearProgressIndicator(
value: score / 100.0,
backgroundColor: AppColors.buttonBackground,
valueColor:
const AlwaysStoppedAnimation<Color>(AppColors.defaultRed),
backgroundColor: AppColors.buttonBackground,
valueColor: const AlwaysStoppedAnimation<Color>(
AppColors.defaultRed),
minHeight: 12.0,
),
),
Expand Down Expand Up @@ -148,7 +150,7 @@ class DetailContent extends StatelessWidget {
if (hasLogo)
Divider(
thickness: 1.0,
color: AppColors.divider,
color: AppColors.divider,
indent: 0,
endIndent: 0,
),
Expand Down Expand Up @@ -187,8 +189,10 @@ class _DetailItem extends StatelessWidget {
children: [
Padding(
padding: const EdgeInsets.only(right: 3.0),
child: state ? Assets.company.taskAlt.svg() : Assets.company.radioButtonUnchecked.svg()
),
child: state
? Assets.company.taskAlt.svg()
: Assets.company.radioButtonUnchecked.svg(),
),
Expanded(
child: Text(
text,
Expand Down Expand Up @@ -239,4 +243,63 @@ extension on Company {
return null;
}
}

CompanyScoreData? scoreData() {
final int? plCapital = this.plCapital;
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved
final int? plWorkers = this.plWorkers;
final int? plRnD = this.plRnD;
final int? plRegistered = this.plRegistered;
final int? plNotGlobEnt = this.plNotGlobEnt;
final int? plScore = this.plScore;

if (plCapital != null &&
plWorkers != null &&
plRnD != null &&
plRegistered != null &&
plNotGlobEnt != null &&
plScore != null) {
return CompanyScoreData(
plCapital: plCapital.toDouble(),
plWorkers: plWorkers != 0,
plRnD: plRnD != 0,
plRegistered: plRegistered != 0,
plNotGlobEnt: plNotGlobEnt != 0,
plScore: plScore);
}
}
}

class _ScoreSection extends StatelessWidget {
final Company company;

const _ScoreSection({super.key, required this.company});

@override
Widget build(BuildContext context) {
final scoreData = company.scoreData();

// Check if scoreData is not null and if the score is zero
if (scoreData != null) {
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved
if (scoreData.plScore == 0) {
return Padding(
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved
padding: const EdgeInsets.all(16.0),
child: Text(
"Niestety, ta firma nie została jeszcze zweryfikowana, więc nie możemy wyświetlić jej oceny. "
"Stale rozszerzamy naszą bazę, aby uwzględnić więcej firm.\n\n"
"Dziękujemy za cierpliwość!",
style: TextStyle(
fontSize: TextSize.description,
fontWeight: FontWeight.w400,
fontFamily: FontFamily.lato,
color: AppColors.text,
),
textAlign: TextAlign.center,
),
);
}
return CompanyScoreWidget(data: scoreData);
} else {
return Container();
}
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved
}
}
51 changes: 51 additions & 0 deletions lib/pages/detail/no_score_message.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import 'package:flutter/material.dart';
import 'package:pola_flutter/theme/assets.gen.dart';
import 'package:pola_flutter/theme/colors.dart';
import 'package:pola_flutter/theme/fonts.gen.dart';
import 'package:pola_flutter/theme/text_size.dart';
import 'package:pola_flutter/i18n/strings.g.dart';

class NoScoreMessage extends StatelessWidget {
const NoScoreMessage({Key? key, required this.t}) : super(key: key);

final Translations t;
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 22.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Assets.company.unpublished.svg(height: 109.42, width: 109.55),
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved
),
const SizedBox(height: 26.0),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 115.0),
),
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved
Text(
t.companyScreen.companyUnverified,
style: TextStyle(
fontSize: TextSize.description,
fontWeight: FontWeight.w400,
fontFamily: FontFamily.lato,
color: AppColors.text,
),
textAlign: TextAlign.left,
),
Text(
t.companyScreen.thankYou,
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved
style: TextStyle(
fontSize: TextSize.description,
fontWeight: FontWeight.w700,
fontFamily: FontFamily.lato,
color: AppColors.text,
),
textAlign: TextAlign.left,
)
],
),
);
}
}
Loading