Browse Source

fix some bug

master
mohsen 1 year ago
parent
commit
2d54088e75
  1. 2
      data/data_core/network/network_core/lib/network/networking/api_endpoint.dart
  2. 2
      data/data_types/data/lib/app_api_data/app_api_repository_impl.dart
  3. 31
      lib/features/posts/widgets/post_item_widget.dart
  4. 34
      lib/features/single_post/screen/single_post_screen.dart
  5. 30
      pubspec.lock

2
data/data_core/network/network_core/lib/network/networking/api_endpoint.dart

@ -17,7 +17,7 @@ enum AppEndpoint {
sendComment('send_comment'), sendComment('send_comment'),
search('search'), search('search'),
contactUs('contact_us'), contactUs('contact_us'),
singlePost('singlepost'),
singlePost('getarticle'),
postList('getarticles'); postList('getarticles');
final String value; final String value;

2
data/data_types/data/lib/app_api_data/app_api_repository_impl.dart

@ -44,7 +44,7 @@ class AppApiRepositoryImpl implements AppApiRepository {
return await _apiService.getDocumentData<SinglePostModel>( return await _apiService.getDocumentData<SinglePostModel>(
endpoint: '${ApiEndpoint.api(AppEndpoint.singlePost)}?post=$postId', endpoint: '${ApiEndpoint.api(AppEndpoint.singlePost)}?post=$postId',
converter: (response) { converter: (response) {
return SinglePostModel.fromJson(response);
return SinglePostModel.fromJson(response['data']);
}, },
); );
} }

31
lib/features/posts/widgets/post_item_widget.dart

@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:repositories/app_api_domain/models/post_model.dart'; import 'package:repositories/app_api_domain/models/post_model.dart';
import 'package:sonnat/core/extensions/context_extension.dart'; import 'package:sonnat/core/extensions/context_extension.dart';
import 'package:sonnat/core/utils/app_constants.dart'; import 'package:sonnat/core/utils/app_constants.dart';
import 'package:sonnat/core/utils/app_utils.dart';
class PostItemWidget extends StatelessWidget { class PostItemWidget extends StatelessWidget {
final PostModel post; final PostModel post;
@ -11,6 +10,7 @@ class PostItemWidget extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final String? thumbnail = post.thumbnail;
return Container( return Container(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
horizontal: context.width * 11 / AppConstants.instance.appWidth, horizontal: context.width * 11 / AppConstants.instance.appWidth,
@ -30,16 +30,33 @@ class PostItemWidget extends StatelessWidget {
children: [ children: [
Container( Container(
height: context.height * 174 / AppConstants.instance.appHeight, height: context.height * 174 / AppConstants.instance.appHeight,
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16), topLeft: Radius.circular(16),
topRight: Radius.circular(16), topRight: Radius.circular(16),
), ),
image: DecorationImage(
image: NetworkImage(post.thumbnail!),
fit: BoxFit.cover,
),
), ),
child: thumbnail == null
? Center(
child: Icon(
Icons.image_search,
color: Colors.grey.withOpacity(0.5),
size: 150,
),
)
: Image.network(
thumbnail,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return Center(
child: Icon(
Icons.image_search,
color: Colors.grey.withOpacity(0.5),
size: 150,
),
);
},
),
), ),
SizedBox(height: context.height * 14 / AppConstants.instance.appHeight), SizedBox(height: context.height * 14 / AppConstants.instance.appHeight),
Text( Text(

34
lib/features/single_post/screen/single_post_screen.dart

@ -6,7 +6,6 @@ import 'package:sonnat/core/extensions/string_extension.dart';
import 'package:sonnat/core/html/html_viewer.dart'; import 'package:sonnat/core/html/html_viewer.dart';
import 'package:sonnat/core/language/translator.dart'; import 'package:sonnat/core/language/translator.dart';
import 'package:sonnat/core/utils/app_constants.dart'; import 'package:sonnat/core/utils/app_constants.dart';
import 'package:sonnat/core/utils/app_utils.dart';
import 'package:sonnat/core/utils/base_cubit_type.dart'; import 'package:sonnat/core/utils/base_cubit_type.dart';
import 'package:sonnat/features/single_post/cubit/single_post_cubit.dart'; import 'package:sonnat/features/single_post/cubit/single_post_cubit.dart';
import 'package:sonnat/features/single_post/widget/add_comment_widget.dart'; import 'package:sonnat/features/single_post/widget/add_comment_widget.dart';
@ -51,9 +50,13 @@ class _SinglePostScreenState extends State<SinglePostScreen> {
_loading = false; _loading = false;
break; break;
} }
if(_loading) {
if (_loading) {
return const Center(child: CircularProgressIndicator()); return const Center(child: CircularProgressIndicator());
} }
if(_cubit.model == null) {
return const Center(child: Text('خطا در دریافت اطلاعات'));
}
String? thumbnail = _cubit.model!.thumbnail;
return SingleChildScrollView( return SingleChildScrollView(
child: Column( child: Column(
children: [ children: [
@ -62,10 +65,27 @@ class _SinglePostScreenState extends State<SinglePostScreen> {
child: Stack( child: Stack(
fit: StackFit.expand, fit: StackFit.expand,
children: [ children: [
Image.network(
_cubit.model!.thumbnail ?? '',
fit: BoxFit.cover,
),
thumbnail == null
? Center(
child: Icon(
Icons.image_search,
color: Colors.grey.withOpacity(0.5),
size: 150,
),
)
: Image.network(
thumbnail,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return Center(
child: Icon(
Icons.image_search,
color: Colors.grey.withOpacity(0.5),
size: 150,
),
);
},
),
PositionedDirectional( PositionedDirectional(
end: 16, end: 16,
top: 16, top: 16,
@ -170,7 +190,7 @@ class _SinglePostScreenState extends State<SinglePostScreen> {
), ),
), ),
Text( Text(
Utils.instance.dateToString(DateTime.parse(_cubit.model!.publishDate).millisecondsSinceEpoch),
_cubit.model!.publishDate,
style: const TextStyle(fontSize: 11), style: const TextStyle(fontSize: 11),
), ),
HTMLViewer( HTMLViewer(

30
pubspec.lock

@ -125,10 +125,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: collection name: collection
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.17.1"
version: "1.17.2"
convert: convert:
dependency: transitive dependency: transitive
description: description:
@ -442,18 +442,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.12.15"
version: "0.12.16"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.2.0"
version: "0.5.0"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -637,10 +637,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.9.1"
version: "1.10.0"
sqflite: sqflite:
dependency: transitive dependency: transitive
description: description:
@ -701,10 +701,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.5.1"
version: "0.6.0"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@ -897,6 +897,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.2.0" version: "0.2.0"
web:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
url: "https://pub.dev"
source: hosted
version: "0.1.4-beta"
win32: win32:
dependency: transitive dependency: transitive
description: description:
@ -930,5 +938,5 @@ packages:
source: hosted source: hosted
version: "3.1.2" version: "3.1.2"
sdks: sdks:
dart: ">=3.0.0-417 <4.0.0"
dart: ">=3.1.0-185.0.dev <4.0.0"
flutter: ">=3.7.0-0" flutter: ">=3.7.0-0"
Loading…
Cancel
Save