ente/lib/ui/viewer/search/result/go_to_map_widget.dart

64 lines
1.8 KiB
Dart
Raw Normal View History

import "package:flutter/material.dart";
2023-11-16 06:11:44 +00:00
import "package:photos/generated/l10n.dart";
import "package:photos/services/search_service.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/map/enable_map.dart";
import "package:photos/ui/map/map_screen.dart";
class GoToMapWidget extends StatelessWidget {
const GoToMapWidget({super.key});
@override
Widget build(BuildContext context) {
final textScaleFactor = MediaQuery.textScaleFactorOf(context);
late final double width;
if (textScaleFactor <= 1.0) {
width = 85.0;
} else {
width = 85.0 + ((textScaleFactor - 1.0) * 64);
}
return GestureDetector(
onTap: () async {
final bool result = await requestForMapEnable(context);
if (result) {
2023-12-16 21:04:26 +00:00
// ignore: unawaited_futures
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => MapScreen(
filesFutureFn: SearchService.instance.getAllFiles,
),
),
);
}
},
child: SizedBox(
width: width,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 10),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
2023-11-16 18:29:35 +00:00
Image.asset(
"assets/map.png",
width: 64,
height: 64,
),
const SizedBox(
height: 10,
),
Text(
2023-11-16 06:11:44 +00:00
S.of(context).yourMap,
maxLines: 2,
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: getEnteTextTheme(context).mini,
),
],
),
),
),
);
}
}