adding menu with dialog and moving dialog text to l10n
All checks were successful
Build Flutter Web and Docker Image for Local Registry / Build Flutter Web App (push) Successful in 3m12s
All checks were successful
Build Flutter Web and Docker Image for Local Registry / Build Flutter Web App (push) Successful in 3m12s
This commit is contained in:
parent
43467e0a72
commit
4ce7efb5a5
3
l10n.yaml
Normal file
3
l10n.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
arb-dir: lib/l10n
|
||||
template-arb-file: app_en.arb
|
||||
output-localization-file: app_localizations.dart
|
@ -1,6 +1,7 @@
|
||||
// custom_menu_icon.dart
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
class CustomMenu extends StatefulWidget {
|
||||
const CustomMenu({super.key});
|
||||
@ -23,29 +24,26 @@ class CustomMenuState extends State<CustomMenu> {
|
||||
// Detect taps outside the menu
|
||||
GestureDetector(
|
||||
onTap: _removeMenuOverlay,
|
||||
behavior:
|
||||
HitTestBehavior.translucent, // Ensures taps are detected
|
||||
behavior: HitTestBehavior.translucent,
|
||||
child: Container(
|
||||
color: Colors
|
||||
.transparent, // Transparent background for full-screen detection
|
||||
color: Colors.transparent,
|
||||
),
|
||||
),
|
||||
// Positioned menu overlay
|
||||
Positioned(
|
||||
top: position.dy + 60, // Position below the icon
|
||||
top: position.dy + 60,
|
||||
left: position.dx + 10,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white
|
||||
.withOpacity(0.95), // Slightly transparent background
|
||||
color: Colors.white.withOpacity(0.95),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black26,
|
||||
blurRadius: 10,
|
||||
offset: Offset(0, 4), // Shadow under the menu
|
||||
offset: Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -85,7 +83,7 @@ class CustomMenuState extends State<CustomMenu> {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
_removeMenuOverlay();
|
||||
onTap(); // Open the specific dialog for this menu item
|
||||
onTap();
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
@ -114,85 +112,43 @@ class CustomMenuState extends State<CustomMenu> {
|
||||
);
|
||||
}
|
||||
|
||||
// Dialog for "Home" option
|
||||
void _showHomeDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text('Home'),
|
||||
content: Text('This is the Home dialog. Add your home content here.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text('Close'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
_showDialog('Home', AppLocalizations.of(context)!.homeDialogContent);
|
||||
}
|
||||
|
||||
// Dialog for "Profile" option
|
||||
void _showProfileDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text('Profile'),
|
||||
content: Text(
|
||||
'This is the Profile dialog. Add your profile content here.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text('Close'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
_showDialog('Profile', AppLocalizations.of(context)!.profileDialogContent);
|
||||
}
|
||||
|
||||
// Dialog for "Settings" option
|
||||
void _showSettingsDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text('Settings'),
|
||||
content: Text(
|
||||
'This is the Settings dialog. Add your settings content here.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text('Close'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
_showDialog(
|
||||
'Settings', AppLocalizations.of(context)!.settingsDialogContent);
|
||||
}
|
||||
|
||||
// Dialog for "Logout" option
|
||||
void _showLogoutDialog() {
|
||||
_showDialog('Logout', AppLocalizations.of(context)!.logoutDialogContent,
|
||||
isLogout: true);
|
||||
}
|
||||
|
||||
void _showDialog(String title, String content, {bool isLogout = false}) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text('Logout'),
|
||||
content: Text('Are you sure you want to log out?'),
|
||||
title: Text(title),
|
||||
content: Text(content),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
// Add your logout functionality here
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text('Logout', style: TextStyle(color: Colors.red)),
|
||||
child: Text(isLogout ? 'Cancel' : 'Close'),
|
||||
),
|
||||
if (isLogout)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text('Logout', style: TextStyle(color: Colors.red)),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
@ -206,7 +162,7 @@ class CustomMenuState extends State<CustomMenu> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Image.asset(
|
||||
'assets/logo.png', // Your custom icon path
|
||||
'assets/logo.png',
|
||||
height: 40,
|
||||
width: 40,
|
||||
),
|
||||
|
18
lib/l10n/app_en.arb
Normal file
18
lib/l10n/app_en.arb
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"homeDialogContent": "This is the Home dialog. Add your home content here.",
|
||||
"profileDialogContent": "This is the Profile dialog. Add your profile content here.",
|
||||
"settingsDialogContent": "This is the Settings dialog. Add your settings content here.",
|
||||
"logoutDialogContent": "Are you sure you want to log out?",
|
||||
"@homeDialogContent": {
|
||||
"description": "Text for the home dialog content."
|
||||
},
|
||||
"@profileDialogContent": {
|
||||
"description": "Text for the profile dialog content."
|
||||
},
|
||||
"@settingsDialogContent": {
|
||||
"description": "Text for the settings dialog content."
|
||||
},
|
||||
"@logoutDialogContent": {
|
||||
"description": "Text for the logout confirmation dialog content."
|
||||
}
|
||||
}
|
@ -2,11 +2,13 @@ import 'dart:async';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'profile_screen.dart';
|
||||
import 'shared_preferences_provider.dart';
|
||||
import 'status_page.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
@ -26,6 +28,14 @@ class MyApp extends StatelessWidget {
|
||||
title: 'Pogdark',
|
||||
theme: _buildTheme(),
|
||||
home: const HomeScreen(),
|
||||
// Localization configuration
|
||||
localizationsDelegates: [
|
||||
AppLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
);
|
||||
}
|
||||
|
||||
|
10
pubspec.yaml
10
pubspec.yaml
@ -33,12 +33,14 @@ dependencies:
|
||||
english_words: ^4.0.0
|
||||
provider: ^6.1.2
|
||||
web_socket_channel: ^3.0.1
|
||||
shared_preferences: ^2.0.9
|
||||
shared_preferences: ^2.3.3
|
||||
image_picker: ^1.1.2
|
||||
uuid: ^4.4.2
|
||||
fluttertoast: ^8.2.8
|
||||
http: ^1.2.2
|
||||
flutter_dotenv: ^5.0.3
|
||||
intl: ^0.19.0
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
@ -71,10 +73,14 @@ flutter:
|
||||
# the material Icons class.
|
||||
uses-material-design: true
|
||||
|
||||
#localization
|
||||
generate: true
|
||||
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
assets:
|
||||
- assets/default_profile_image.png
|
||||
- assets/pogdark_logo.png
|
||||
- assets/logo.png
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user