Compare commits

...

2 Commits

Author SHA1 Message Date
Phuoc Nguyen
8ff7b3b505 update text + slider 2025-12-03 17:20:22 +07:00
Phuoc Nguyen
2a14f82b72 fix design request 2025-12-03 17:12:21 +07:00
5 changed files with 122 additions and 38 deletions

View File

@@ -7,11 +7,11 @@ import UIKit
_ application: UIApplication, _ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool { ) -> Bool {
#if DEBUG // #if DEBUG
var args = ProcessInfo.processInfo.arguments // var args = ProcessInfo.processInfo.arguments
args.append("-FIRDebugEnabled") // args.append("-FIRDebugEnabled")
ProcessInfo.processInfo.setValue(args, forKey: "arguments") // ProcessInfo.processInfo.setValue(args, forKey: "arguments")
#endif // #endif
GeneratedPluginRegistrant.register(with: self) GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions) return super.application(application, didFinishLaunchingWithOptions: launchOptions)
} }

View File

@@ -252,7 +252,7 @@ class _HomePageState extends ConsumerState<HomePage> {
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 16), padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text( child: Text(
'Chương trình ưu đãi', 'Tin tức nổi bật',
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,

View File

@@ -1,9 +1,12 @@
/// Widget: Promotion Slider /// Widget: Promotion Slider
/// ///
/// Horizontal scrolling list of promotional banners. /// Auto-sliding carousel of promotional banners.
/// Displays promotion images, titles, and descriptions. /// Displays promotion images, titles, and descriptions.
/// Auto-advances every 4 seconds with smooth animation.
library; library;
import 'dart:async';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
@@ -14,13 +17,15 @@ import 'package:worker/features/home/domain/entities/promotion.dart';
/// Promotion Slider Widget /// Promotion Slider Widget
/// ///
/// Displays a horizontal scrollable list of promotion cards. /// Displays an auto-sliding carousel of promotion cards.
/// Each card shows an image, title, and brief description. /// Each card shows an image, title, and brief description.
class PromotionSlider extends StatelessWidget { /// Auto-advances every 4 seconds with page indicators.
class PromotionSlider extends StatefulWidget {
const PromotionSlider({ const PromotionSlider({
super.key, super.key,
required this.promotions, required this.promotions,
this.onPromotionTap, this.onPromotionTap,
this.autoSlideDuration = const Duration(seconds: 4),
}); });
/// List of promotions to display /// List of promotions to display
@@ -29,9 +34,56 @@ class PromotionSlider extends StatelessWidget {
/// Callback when a promotion is tapped /// Callback when a promotion is tapped
final void Function(Promotion promotion)? onPromotionTap; final void Function(Promotion promotion)? onPromotionTap;
/// Duration between auto-slides
final Duration autoSlideDuration;
@override
State<PromotionSlider> createState() => _PromotionSliderState();
}
class _PromotionSliderState extends State<PromotionSlider> {
late final ScrollController _scrollController;
Timer? _autoSlideTimer;
int _currentIndex = 0;
static const double _cardWidth = 280;
static const double _cardMargin = 12;
static const double _scrollOffset = _cardWidth + _cardMargin;
@override
void initState() {
super.initState();
_scrollController = ScrollController();
_startAutoSlide();
}
@override
void dispose() {
_autoSlideTimer?.cancel();
_scrollController.dispose();
super.dispose();
}
void _startAutoSlide() {
if (widget.promotions.length <= 1) return;
_autoSlideTimer = Timer.periodic(widget.autoSlideDuration, (_) {
if (!mounted) return;
_currentIndex = (_currentIndex + 1) % widget.promotions.length;
final targetOffset = _currentIndex * _scrollOffset;
_scrollController.animateTo(
targetOffset,
duration: const Duration(milliseconds: 400),
curve: Curves.easeInOut,
);
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (promotions.isEmpty) { if (widget.promotions.isEmpty) {
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
@@ -45,7 +97,7 @@ class PromotionSlider extends StatelessWidget {
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 16), padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text( child: Text(
'Chương trình ưu đãi', 'Tin tức nổi bật',
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
@@ -55,22 +107,22 @@ class PromotionSlider extends StatelessWidget {
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
SizedBox( SizedBox(
height: 210, // 140px image + 54px text area height: 210,
child: ListView.builder( child: ListView.builder(
controller: _scrollController,
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(horizontal: 16), padding: const EdgeInsets.symmetric(horizontal: 16),
itemCount: promotions.length, itemCount: widget.promotions.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
return _PromotionCard( return _PromotionCard(
promotion: promotions[index], promotion: widget.promotions[index],
onTap: () { onTap: () {
if (onPromotionTap != null) { if (widget.onPromotionTap != null) {
onPromotionTap!(promotions[index]); widget.onPromotionTap!(widget.promotions[index]);
} else { } else {
// Navigate to promotion detail page
context.pushNamed( context.pushNamed(
RouteNames.promotionDetail, RouteNames.promotionDetail,
extra: promotions[index], extra: widget.promotions[index],
); );
} }
}, },

View File

@@ -305,12 +305,14 @@ class DesignRequestDetailPage extends ConsumerWidget {
value: request.subject, value: request.subject,
), ),
if (request.plainDescription.isNotEmpty) ...[ if (request.description != null &&
request.description!.isNotEmpty) ...[
const SizedBox(height: 12), const SizedBox(height: 12),
DescriptionItem( DescriptionItem(
label: 'Mô tả chi tiết:', label: 'Mô tả chi tiết:',
value: request.plainDescription, value: request.description!,
isMultiLine: true, isMultiLine: true,
isHtml: true,
), ),
], ],
], ],

View File

@@ -4,12 +4,14 @@
library; library;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
/// Description Item Widget /// Description Item Widget
/// ///
/// Shows a label and value pair with: /// Shows a label and value pair with:
/// - Inline layout (label: value) for single line /// - Inline layout (label: value) for single line
/// - Stacked layout for multi-line values /// - Stacked layout for multi-line values
/// - HTML rendering support for rich text content
/// - Theme-aware colors /// - Theme-aware colors
class DescriptionItem extends StatelessWidget { class DescriptionItem extends StatelessWidget {
const DescriptionItem({ const DescriptionItem({
@@ -17,11 +19,55 @@ class DescriptionItem extends StatelessWidget {
required this.label, required this.label,
required this.value, required this.value,
this.isMultiLine = false, this.isMultiLine = false,
this.isHtml = false,
}); });
final String label; final String label;
final String value; final String value;
final bool isMultiLine; final bool isMultiLine;
final bool isHtml;
Widget _buildValueWidget(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
if (isHtml) {
return Html(
data: value,
style: {
'body': Style(
fontSize: FontSize(15),
color: colorScheme.onSurface,
fontWeight: FontWeight.w500,
lineHeight: const LineHeight(1.6),
margin: Margins.zero,
padding: HtmlPaddings.zero,
),
'p': Style(
margin: Margins.only(bottom: 8),
),
'ul': Style(
margin: Margins.only(left: 16, bottom: 8),
),
'ol': Style(
margin: Margins.only(left: 16, bottom: 8),
),
'li': Style(
margin: Margins.only(bottom: 4),
),
},
);
}
return Text(
value,
style: TextStyle(
fontSize: 15,
color: colorScheme.onSurface,
fontWeight: FontWeight.w500,
height: 1.6,
),
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -40,15 +86,7 @@ class DescriptionItem extends StatelessWidget {
), ),
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
Text( _buildValueWidget(context),
value,
style: TextStyle(
fontSize: 15,
color: colorScheme.onSurface,
fontWeight: FontWeight.w500,
height: 1.6,
),
),
], ],
); );
} }
@@ -75,15 +113,7 @@ class DescriptionItem extends StatelessWidget {
), ),
), ),
Expanded( Expanded(
child: Text( child: _buildValueWidget(context),
value,
style: TextStyle(
fontSize: 15,
color: colorScheme.onSurface,
fontWeight: FontWeight.w500,
height: 1.6,
),
),
), ),
], ],
), ),