elegant_announcement_bar 1.0.0
elegant_announcement_bar: ^1.0.0 copied to clipboard
A highly customizable, animated, and elegant announcement bar for Flutter apps with RTL support and smart pausing.
import 'package:flutter/material.dart';
import 'package:elegant_announcement_bar/elegant_announcement_bar.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner:false,
title: 'شريط الإعلانات الأنيق',
theme: ThemeData(
primarySwatch: Colors.blue,
useMaterial3: true,
),
// Support for RTL testing
home: const Directionality(
textDirection: TextDirection.rtl,
child: MyHomePage(),
),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('شريط الإعلانات الأنيق'),
centerTitle: true,
),
body: Column(
children: [
const SizedBox(height: 20),
// Basic Usage
const Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: Text(
'الأشكال الافتراضية',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
),
ElegantAnnouncementBar(
items: [
AnnouncementItem(
title: 'تنبيه جديد',
message: 'هذا إعلان تجريبي باللغة العربية لاختبار دعم الاتجاهات.',
type: AnnouncementType.info,
),
AnnouncementItem(
title: 'تم بنجاح!',
message: 'تم تحديث البيانات الخاصة بك في النظام بنجاح.',
type: AnnouncementType.success,
),
AnnouncementItem(
title: 'تحذير هام',
message: 'يرجى مراجعة إعدادات الأمان في حسابك.',
type: AnnouncementType.warning,
),
],
onItemTap: (item) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('تم الضغط على: ${item.title}')),
);
},
),
const SizedBox(height: 40),
// Custom Design
const Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: Text(
'تصميم مخصص وعروض',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
),
ElegantAnnouncementBar(
items: [
AnnouncementItem(
title: 'عرض محدود! 🔥',
message: 'احصل على خصم 70% عند استخدام كود الهدية.',
type: AnnouncementType.custom,
accentColor: Colors.deepOrange,
icon: Icons.flash_on_rounded,
gradient: LinearGradient(
colors: [Colors.orange.shade50, Colors.orange.shade100],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
AnnouncementItem(
title: 'مميزات إضافية',
message: 'افتح المزيد من الأدوات والخصائص الاحترافية اليوم.',
type: AnnouncementType.custom,
backgroundColor: Colors.indigo.shade50,
accentColor: Colors.indigo,
icon: Icons.star_rounded,
),
],
scrollDuration: const Duration(seconds: 4),
borderRadius: 12,
iconSize: 24,
showCloseButton: true,
isDismissible: true,
onDismissed: () {
debugPrint('Announcement bar was dismissed');
},
titleStyle: const TextStyle(
fontWeight: FontWeight.w900,
color: Colors.black87,
),
),
const Spacer(),
const Center(
child: Text(
'اضغط مع الاستمرار لإيقاف التدوير',
style: TextStyle(color: Colors.grey, fontStyle: FontStyle.italic),
),
),
const SizedBox(height: 50),
],
),
);
}
}