8706122590
and moved ChangeRoomIcon-Dialog into seperate file. This was done in an attempt to remove redundancy
50 lines
1.8 KiB
Dart
50 lines
1.8 KiB
Dart
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);
|
|
}
|
|
}
|
|
)
|
|
);
|
|
}).toList()
|
|
)
|
|
)
|
|
);
|
|
}
|
|
}
|