cpd/lib/pages/iconpage.dart

73 lines
1.9 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
class IconPage extends StatelessWidget {
final IconData selectedIcon;
final ValueChanged<IconData> onIconSelected;
const IconPage({
super.key,
required this.selectedIcon,
required this.onIconSelected});
@override
Widget build(BuildContext context) {
final List<IconData> icons = [
Icons.star,
Icons.favorite,
Icons.check,
Icons.home,
Icons.access_alarm,
Icons.import_contacts_rounded,
Icons.code,
Icons.face,
Icons.format_paint,
Icons.book,
Icons.event_busy,
Icons.self_improvement_outlined,
Icons.snowshoeing,
Icons.family_restroom,
Icons.notification_important,
Icons.local_drink,
Icons.music_note,
Icons.edit_note,
Icons.healing,
Icons.tv
];
return Scaffold(
appBar: AppBar(
title: const Text('Choose your icon'),
),
body: Padding(
padding: const EdgeInsets.all(10.0),
child: GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
crossAxisSpacing: 8.0,
mainAxisSpacing: 8.0,
),
itemCount: icons.length,
itemBuilder: (context, index) {
return InkWell(
onTap: () {
onIconSelected(icons[index]);
Navigator.pop(context, icons[index]);
},
child: Container(
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(10.0),
),
child: Icon(
icons[index],
size: 35.0,
color: selectedIcon == icons[index] ? Colors.purple : Colors.black,
),
),
);
},
),
),
);
}
2024-06-19 16:25:05 +02:00
}