forked from eatvio/eatvio_app
refactor: profile model
This commit is contained in:
@@ -1,12 +1,8 @@
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/blog_post_widget.dart';
|
||||
import 'package:eatvio_app/features/profile/models/profile_model.dart';
|
||||
import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart';
|
||||
import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_state.dart';
|
||||
import 'package:eatvio_app/features/profile/presentation/widgets/circumference_chart_widget.dart';
|
||||
import 'package:eatvio_app/features/profile/presentation/widgets/imt_chart_widget.dart';
|
||||
import 'package:eatvio_app/features/profile/presentation/widgets/weight_chart_widget.dart';
|
||||
import 'package:eatvio_app/locator_service.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
@@ -23,8 +19,8 @@ class ProfileScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ProfileScreenState extends State<ProfileScreen> {
|
||||
List<Circumference> chartData = [];
|
||||
List<ChartPointModel> chartPoints = [];
|
||||
// List<Circumference> chartData = [];
|
||||
// List<ChartPointModel> chartPoints = [];
|
||||
final List<String> chipsLabelList = ['Вес', 'Замеры', 'ИМТ'];
|
||||
final List<String> chipsIntervalLabelList = ['1М', '3М', '6М', '1Г', 'ВСЁ ВРЕМЯ'];
|
||||
int _selectedChipIndex = 0;
|
||||
@@ -42,8 +38,8 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
child: BlocBuilder<ProfileCubit, ProfileState>(
|
||||
builder: (BuildContext context, ProfileState state) {
|
||||
if (state is ProfileStateLoaded) {
|
||||
chartData = state.profile.circumferences;
|
||||
chartPoints = state.profile.chartPoints;
|
||||
// chartData = state.profile.circumferences;
|
||||
// chartPoints = state.profile.chartPoints;
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey.shade200,
|
||||
appBar: widget.author == null ? AppBar(toolbarHeight: 0) : AppBar(),
|
||||
@@ -65,17 +61,13 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
state.profile.user.profilePhotoUrl != null
|
||||
? CircleAvatar(
|
||||
radius: 32,
|
||||
backgroundImage: NetworkImage(state.profile.user.profilePhotoUrl!),
|
||||
)
|
||||
: CircleAvatar(
|
||||
radius: 32,
|
||||
),
|
||||
CircleAvatar(
|
||||
radius: 32,
|
||||
backgroundImage: NetworkImage(state.profile.profilePhotoUrl),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
state.profile.user.name,
|
||||
state.profile.name,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500,
|
||||
@@ -123,7 +115,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
GestureDetector(
|
||||
onTap: () => Share.shareUri(
|
||||
Uri.parse(
|
||||
baseUrl + '/ru/profile/' + state.profile.user.slug,
|
||||
baseUrl + '/ru/profile/' + state.profile.slug,
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
@@ -139,12 +131,12 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
],
|
||||
),
|
||||
),
|
||||
if (state.profile.userDetails.additionalInfo.isNotEmpty)
|
||||
if (state.profileDetails.additionalInfo.isNotEmpty)
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
state.profile.userDetails.additionalInfo,
|
||||
state.profileDetails.additionalInfo,
|
||||
style: TextStyle(
|
||||
color: Colors.black.withOpacity(0.4),
|
||||
height: 1,
|
||||
@@ -157,7 +149,9 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
children: [
|
||||
SizedBox(width: 16),
|
||||
GestureDetector(
|
||||
onTap: () => GoRouter.of(context).pushNamed('chatScreen', ),
|
||||
onTap: () => GoRouter.of(context).pushNamed(
|
||||
'chatScreen',
|
||||
),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
padding: EdgeInsets.all(8),
|
||||
@@ -213,25 +207,25 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
],
|
||||
),
|
||||
),
|
||||
Builder(
|
||||
builder: (context) {
|
||||
switch (_selectedChipIndex) {
|
||||
case 0:
|
||||
return WeightChartWidget(
|
||||
chartPoints: chartPoints,
|
||||
profileCubit: context.read<ProfileCubit>(),
|
||||
);
|
||||
case 1:
|
||||
return CircumferenceChartWidget(
|
||||
chartData: chartData,
|
||||
profileCubit: context.read<ProfileCubit>(),
|
||||
);
|
||||
case 2:
|
||||
return ImtChartWidget(chartPoints: chartPoints);
|
||||
}
|
||||
return SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
// Builder(
|
||||
// builder: (context) {
|
||||
// switch (_selectedChipIndex) {
|
||||
// case 0:
|
||||
// return WeightChartWidget(
|
||||
// chartPoints: chartPoints,
|
||||
// profileCubit: context.read<ProfileCubit>(),
|
||||
// );
|
||||
// case 1:
|
||||
// return CircumferenceChartWidget(
|
||||
// chartData: chartData,
|
||||
// profileCubit: context.read<ProfileCubit>(),
|
||||
// );
|
||||
// case 2:
|
||||
// return ImtChartWidget(chartPoints: chartPoints);
|
||||
// }
|
||||
// return SizedBox.shrink();
|
||||
// },
|
||||
// ),
|
||||
SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user