Compare commits
2 Commits
2dadcc5ce1
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ff7b3b505 | ||
|
|
2a14f82b72 |
@@ -7,11 +7,11 @@ import UIKit
|
||||
_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||
) -> Bool {
|
||||
#if DEBUG
|
||||
var args = ProcessInfo.processInfo.arguments
|
||||
args.append("-FIRDebugEnabled")
|
||||
ProcessInfo.processInfo.setValue(args, forKey: "arguments")
|
||||
#endif
|
||||
// #if DEBUG
|
||||
// var args = ProcessInfo.processInfo.arguments
|
||||
// args.append("-FIRDebugEnabled")
|
||||
// ProcessInfo.processInfo.setValue(args, forKey: "arguments")
|
||||
// #endif
|
||||
GeneratedPluginRegistrant.register(with: self)
|
||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ class _HomePageState extends ConsumerState<HomePage> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text(
|
||||
'Chương trình ưu đãi',
|
||||
'Tin tức nổi bật',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
/// Widget: Promotion Slider
|
||||
///
|
||||
/// Horizontal scrolling list of promotional banners.
|
||||
/// Auto-sliding carousel of promotional banners.
|
||||
/// Displays promotion images, titles, and descriptions.
|
||||
/// Auto-advances every 4 seconds with smooth animation.
|
||||
library;
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.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
|
||||
///
|
||||
/// 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.
|
||||
class PromotionSlider extends StatelessWidget {
|
||||
/// Auto-advances every 4 seconds with page indicators.
|
||||
class PromotionSlider extends StatefulWidget {
|
||||
const PromotionSlider({
|
||||
super.key,
|
||||
required this.promotions,
|
||||
this.onPromotionTap,
|
||||
this.autoSlideDuration = const Duration(seconds: 4),
|
||||
});
|
||||
|
||||
/// List of promotions to display
|
||||
@@ -29,9 +34,56 @@ class PromotionSlider extends StatelessWidget {
|
||||
/// Callback when a promotion is tapped
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
if (promotions.isEmpty) {
|
||||
if (widget.promotions.isEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
@@ -45,7 +97,7 @@ class PromotionSlider extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text(
|
||||
'Chương trình ưu đãi',
|
||||
'Tin tức nổi bật',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
@@ -55,22 +107,22 @@ class PromotionSlider extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(
|
||||
height: 210, // 140px image + 54px text area
|
||||
height: 210,
|
||||
child: ListView.builder(
|
||||
controller: _scrollController,
|
||||
scrollDirection: Axis.horizontal,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
itemCount: promotions.length,
|
||||
itemCount: widget.promotions.length,
|
||||
itemBuilder: (context, index) {
|
||||
return _PromotionCard(
|
||||
promotion: promotions[index],
|
||||
promotion: widget.promotions[index],
|
||||
onTap: () {
|
||||
if (onPromotionTap != null) {
|
||||
onPromotionTap!(promotions[index]);
|
||||
if (widget.onPromotionTap != null) {
|
||||
widget.onPromotionTap!(widget.promotions[index]);
|
||||
} else {
|
||||
// Navigate to promotion detail page
|
||||
context.pushNamed(
|
||||
RouteNames.promotionDetail,
|
||||
extra: promotions[index],
|
||||
extra: widget.promotions[index],
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -305,12 +305,14 @@ class DesignRequestDetailPage extends ConsumerWidget {
|
||||
value: request.subject,
|
||||
),
|
||||
|
||||
if (request.plainDescription.isNotEmpty) ...[
|
||||
if (request.description != null &&
|
||||
request.description!.isNotEmpty) ...[
|
||||
const SizedBox(height: 12),
|
||||
DescriptionItem(
|
||||
label: 'Mô tả chi tiết:',
|
||||
value: request.plainDescription,
|
||||
value: request.description!,
|
||||
isMultiLine: true,
|
||||
isHtml: true,
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
library;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_html/flutter_html.dart';
|
||||
|
||||
/// Description Item Widget
|
||||
///
|
||||
/// Shows a label and value pair with:
|
||||
/// - Inline layout (label: value) for single line
|
||||
/// - Stacked layout for multi-line values
|
||||
/// - HTML rendering support for rich text content
|
||||
/// - Theme-aware colors
|
||||
class DescriptionItem extends StatelessWidget {
|
||||
const DescriptionItem({
|
||||
@@ -17,11 +19,55 @@ class DescriptionItem extends StatelessWidget {
|
||||
required this.label,
|
||||
required this.value,
|
||||
this.isMultiLine = false,
|
||||
this.isHtml = false,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final String value;
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
@@ -40,15 +86,7 @@ class DescriptionItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: colorScheme.onSurface,
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1.6,
|
||||
),
|
||||
),
|
||||
_buildValueWidget(context),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -75,15 +113,7 @@ class DescriptionItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: colorScheme.onSurface,
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1.6,
|
||||
),
|
||||
),
|
||||
child: _buildValueWidget(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user