2023-04-02 13:14:58 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
import 'package:outbag_app/backend/room.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
|
|
import 'dart:math';
|
|
|
|
|
|
|
|
class RoomIconPicker extends StatelessWidget {
|
|
|
|
Function(RoomIcon)? onSelect;
|
|
|
|
RoomIconPicker({this.onSelect});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
double width = MediaQuery.of(context).size.width;
|
|
|
|
double height = MediaQuery.of(context).size.height;
|
|
|
|
double smallest = min(min(width, height), 400);
|
|
|
|
|
|
|
|
return AlertDialog(
|
|
|
|
title: Text(AppLocalizations.of(context)!.chooseRoomIcon),
|
|
|
|
actions: const [],
|
|
|
|
content: SizedBox(
|
|
|
|
width: smallest * 0.3 * 3,
|
|
|
|
height: smallest * 0.3 * 3,
|
|
|
|
child: GridView.count(
|
|
|
|
crossAxisCount: 3,
|
|
|
|
children: RoomIcon.list().map((icon) {
|
|
|
|
return GridTile(
|
|
|
|
child: IconButton(
|
|
|
|
icon: SvgPicture.asset(
|
|
|
|
icon.img,
|
|
|
|
width: smallest * 0.3,
|
|
|
|
height: smallest * 0.3,
|
|
|
|
),
|
|
|
|
// do not display tooltip for now
|
|
|
|
// as it is hard to translate
|
|
|
|
// and the tooltip prevented the click event,
|
|
|
|
// when clicked on the tooltip bar
|
|
|
|
// tooltip:icon.text,
|
|
|
|
onPressed: () {
|
|
|
|
if (onSelect != null) {
|
|
|
|
onSelect!(icon);
|
|
|
|
}
|
2023-12-22 20:14:36 +01:00
|
|
|
}));
|
|
|
|
}).toList())));
|
2023-04-02 13:14:58 +02:00
|
|
|
}
|
|
|
|
}
|