DiscoverModule/lib/test.dart

274 lines
8.5 KiB
Dart
Raw Normal View History

2024-11-22 10:38:43 +00:00
// import 'package:flutter/material.dart';
// void main() {
// runApp(MyApp());
// }
// class MyApp extends StatelessWidget {
// @override
// Widget build(BuildContext context) {
// return MaterialApp(
// home: FilterableSearchList(),
// );
// }
// }
// class Item {
// final String name;
// final String category;
// Item(this.name, this.category);
// }
// class FilterableSearchList extends StatefulWidget {
// @override
// _FilterableSearchListState createState() => _FilterableSearchListState();
// }
// class _FilterableSearchListState extends State<FilterableSearchList> {
// final TextEditingController _searchController = TextEditingController();
// List<Item> items = [
// Item('Apple', 'Fruit'),
// Item('Banana', 'Fruit'),
// Item('Carrot', 'Vegetable'),
// Item('Lettuce', 'Vegetable'),
// Item('Chicken', 'Meat'),
// ];
// List<Item> filteredItems = [];
// Set<String> selectedCategories = {};
// @override
// void initState() {
// super.initState();
// filteredItems = items; // Initially show all items
// _searchController.addListener(_filterItems);
// }
// @override
// void dispose() {
// _searchController.dispose();
// super.dispose();
// }
// void _filterItems() {
// final query = _searchController.text.toLowerCase();
// final searchTerms = query.split(',').map((term) => term.trim()).toList();
// setState(() {
// filteredItems = items.where((item) {
// final matchesCategory = selectedCategories.isEmpty ||
// selectedCategories.contains(item.category);
// // Show all items, but highlight matches
// final matchesSearch =
// searchTerms.any((term) => item.name.toLowerCase() == term);
// return matchesCategory; // Always return true to show all items
// }).toList();
// });
// }
// void _toggleCategory(String category) {
// setState(() {
// if (selectedCategories.contains(category)) {
// selectedCategories.remove(category);
// } else {
// selectedCategories.add(category);
// }
// _filterItems();
// });
// }
// @override
// Widget build(BuildContext context) {
// final categories = ['Fruit', 'Vegetable', 'Meat'];
// return Scaffold(
// appBar: AppBar(title: Text('Filterable & Searchable ListView')),
// body: Column(
// children: [
// // Search Field
// Padding(
// padding: const EdgeInsets.all(8.0),
// child: TextField(
// controller: _searchController,
// decoration: InputDecoration(
// labelText: 'Search (e.g., "Apple, Banana")',
// border: OutlineInputBorder(),
// ),
// ),
// ),
// // Filter options
// Wrap(
// spacing: 8.0,
// children: categories.map((category) {
// return FilterChip(
// label: Text(category),
// selected: selectedCategories.contains(category),
// onSelected: (isSelected) => _toggleCategory(category),
// );
// }).toList(),
// ),
// // ListView
// Expanded(
// child: ListView.builder(
// itemCount: items.length, // Show all items
// itemBuilder: (context, index) {
// final item = items[index];
// final isMatch = _searchController.text.isNotEmpty &&
// (item.name.toLowerCase() ==
// _searchController.text.toLowerCase() ||
// _searchController.text
// .split(',')
// .map((term) => term.trim())
// .contains(item.name.toLowerCase()));
// return ListTile(
// title: Text(item.name,
// style: isMatch
// ? TextStyle(fontWeight: FontWeight.bold)
// : null),
// subtitle: Text(item.category),
// );
// },
// ),
// ),
// ],
// ),
// );
// }
// }
import 'package:discover_module/contacts_module/ui_screen/new_contacts.dart';
import 'package:flutter/material.dart';
import 'package:flutter_offline/flutter_offline.dart';
class DemoPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Builder(builder: (context) {
return OfflineBuilder(
connectivityBuilder: (
BuildContext context,
List<ConnectivityResult> connectivity,
Widget child,
) {
final bool connected =
!connectivity.contains(ConnectivityResult.none);
WidgetsBinding.instance.addPostFrameCallback((_) {
final overlay = Overlay.of(context);
final overlayEntry = OverlayEntry(
builder: (context) => Positioned(
top: 0.0, // Position the status bar at the top
left: 0.0,
right: 0.0,
child: Material(
color: Colors.transparent,
child: Container(
height: 24.0,
color: connected
? Color(0xFF00EE44)
: Color.fromARGB(255, 243, 8, 8),
child: Center(
child: Text(
"${connected ? 'ONLINE' : 'OFFLINE'}",
style: TextStyle(color: Colors.white),
),
),
),
),
),
);
// Insert the overlay entry above the AppBar
overlay.insert(overlayEntry);
// // Optionally remove the overlay after some time (or keep it)
// Future.delayed(Duration(seconds: 30), () {
// overlayEntry.remove();
// });
});
// Returning the rest of the UI
return const Stack(
fit: StackFit.expand,
children: [
Padding(
padding: EdgeInsets.only(
top: 0.0), // Adjust the top padding to prevent overlap
child: Contacts1(),
),
],
);
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(
'There are no buttons to push :)',
),
new Text(
'Just turn off your internet.',
),
],
),
);
}),
);
}
// Scaffold(
// // appBar: new AppBar(
// // title: new Text("Offline Demo"),
// // ),
// body: Builder(builder: (context) {
// return OfflineBuilder(
// connectivityBuilder: (
// BuildContext context,
// List<ConnectivityResult> connectivity,
// Widget child,
// ) {
// final bool connected =
// !connectivity.contains(ConnectivityResult.none);
// return Stack(
// fit: StackFit.expand,
// children: [
// Positioned(
// top: 0,
// //height: 24.0,
// left: 0.0,
// right: 0.0,
// child: Container(
// color: connected
// ? Color(0xFF00EE44)
// : Color.fromARGB(255, 243, 8, 8),
// child: Center(
// child: Text("${connected ? 'ONLINE' : 'OFFLINE'}"),
// ),
// ),
// ),
// Padding(
// padding: const EdgeInsets.only(top: 0.0),
// child: const Contacts1(),
// ),
// ],
// );
// },
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: <Widget>[
// new Text(
// 'There are no bottons to push :)',
// ),
// new Text(
// 'Just turn off your internet.',
// ),
// ],
// ),
// );
// }),
// );
// }
}