Certainly! Let's update your Flutter dashboard application based on the detailed specifications you've provided. We'll address each requirement step-by-step, ensuring the sidebar and main content match your design expectations.
Overview of Changes:
-
Sidebar Adjustments:
- Color: Match the sidebar color to the main content (
#09090A).
- Layout:
- Center the "netpc.space" text with the Neue Machina font in white.
- Create a user card containing:
- Static user icon.
- Username with a logout icon button.
- Balance represented by an icon only.
- Navigation:
- Text "Основное" in purple.
- Navigation buttons below "Основное" with appropriate styling.
-
Main Content Adjustments:
- Welcome Section:
- Positioned image with specified dimensions and styling.
- Positioned welcome texts using the Unbounded font.
- Server List:
- Fixed-size server cards with specific positioning elements like flags, server details, and management buttons.
-
Fonts:
- Integrate Neue Machina and Unbounded fonts.
-
Static Sizing:
- Apply fixed widths and heights as per the specifications.
-
Assets:
- Ensure images are correctly placed in the
assets directory and referenced in pubspec.yaml.
Step-by-Step Implementation:
1. Update pubspec.yaml for Custom Fonts and Assets
First, ensure that you have the Neue Machina and Unbounded fonts added to your project. Download the font files and place them in an assets/fonts/ directory. Similarly, place your images in an assets/images/ directory.
# pubspec.yaml
flutter:
fonts:
- family: NeueMachina
fonts:
- asset: assets/fonts/NeueMachina-Regular.ttf
- family: Unbounded
fonts:
- asset: assets/fonts/Unbounded-Regular.ttf
assets:
- assets/images/welcome_background.png
Note: Replace the font file paths with the actual paths where you've placed the font files.
Run flutter pub get to update the asset references.
2. Updated Dart Code
Below is the revised Flutter code incorporating all the specified changes:
import 'package:flutter/material.dart';
void main() {
runApp(NetpcSpaceApp());
}
class NetpcSpaceApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Netpc.Space Dashboard',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primaryColor: Color(0xFF532E41),
scaffoldBackgroundColor: Color(0xFF09090A),
fontFamily: 'Roboto', // Default font
textTheme: TextTheme(
bodyLarge: TextStyle(color: Colors.white),
bodyMedium: TextStyle(color: Colors.white),
),
),
home: DashboardScreen(),
);
}
}
class DashboardScreen extends StatefulWidget {
@override
State<DashboardScreen> createState() => _DashboardScreenState();
}
class _DashboardScreenState extends State<DashboardScreen> {
String selectedTab = 'Главное';
@override
Widget build(BuildContext context) {
return Scaffold(
body: Row(
children: [
Sidebar(
selectedTab: selectedTab,
onTabSelected: (tab) {
setState(() {
selectedTab = tab;
});
},
),
Expanded(
child: MainContent(
selectedTab: selectedTab,
),
),
],
),
);
}
}
class Sidebar extends StatelessWidget {
final String selectedTab;
final Function(String) onTabSelected;
Sidebar({required this.selectedTab, required this.onTabSelected});
@override
Widget build(BuildContext context) {
return Container(
width: 400, // Fixed width
height: MediaQuery.of(context).size.height,
color: Color(0xFF09090A), // Same as main content
padding: EdgeInsets.only(left: 128, top: 63), // Positioned as per specification
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// "netpc.space" Text
Center(
child: Text(
'netpc.space',
style: TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold,
fontFamily: 'NeueMachina', // Neue Machina font
),
),
),
SizedBox(height: 40), // Spacing
// User Card with Icon, Username, Logout Button, and Balance Icon
Container(
width: double.infinity,
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.1),
border: Border.all(color: Colors.white30),
borderRadius: BorderRadius.circular(12),
),
child: Column(
children: [
Row(
children: [
// Static User Icon
Icon(
Icons.person,
color: Colors.white,
size: 40,
),
SizedBox(width: 16),
// Username and Logout Button
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'username',
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontFamily: 'Roboto',
),
),
IconButton(
onPressed: () {
// Handle logout
},
icon: Icon(
Icons.logout,
color: Colors.white,
size: 20,
),
tooltip: 'Logout',
),
],
),
),
// Balance Icon without Text
Icon(
Icons.account_balance_wallet,
color: Colors.white,
size: 24,
),
],
),
],
),
),
SizedBox(height: 40), // Spacing
// "Основное" Text
Text(
'Основное',
style: TextStyle(
color: Color(0xFF532E41), // Purple color
fontSize: 20,
fontWeight: FontWeight.bold,
fontFamily: 'Roboto',
),
),
SizedBox(height: 16),
// Navigation Buttons
NavButton(
icon: Icons.dashboard,
label: 'Главное',
isSelected: selectedTab == 'Главное',
onTap: () => onTabSelected('Главное'),
),
NavButton(
icon: Icons.settings,
label: 'Настройки',
isSelected: selectedTab == 'Настройки',
onTap: () => onTabSelected('Настройки'),
),
// Add more navigation buttons here as needed
],
),
);
}
}
class NavButton extends StatelessWidget {
final IconData icon;
final String label;
final bool isSelected;
final VoidCallback onTap;
NavButton({
required this.icon,
required this.label,
this.isSelected = false,
required this.onTap,
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Container(
width: 368, // Fixed width within sidebar
height: 48, // Fixed height for uniformity
margin: EdgeInsets.only(bottom: 16),
padding: EdgeInsets.symmetric(vertical: 12, horizontal: 16),
decoration: BoxDecoration(
color: isSelected ? Colors.black.withOpacity(0.7) : Colors.transparent,
borderRadius: BorderRadius.circular(8),
),
child: Row(
children: [
Icon(
icon,
color: Colors.white,
),
SizedBox(width: 16),
Text(
label,
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontFamily: 'Roboto',
),
),
],
),
),
);
}
}
class MainContent extends StatelessWidget {
final String selectedTab;
MainContent({required this.selectedTab});
@override
Widget build(BuildContext context) {
return Stack(
children: [
// Welcome Image and Text
Positioned(
left: 523,
top: 74,
child: Container(
width: 1176,
height: 184,
decoration: BoxDecoration(
color: Colors.grey[800],
borderRadius: BorderRadius.circular(12),
image: DecorationImage(
image: AssetImage('assets/images/welcome_background.png'),
fit: BoxFit.cover,
colorFilter: ColorFilter.mode(
Colors.black.withOpacity(0.3), BlendMode.darken),
),
),
),
),
// Welcome Texts
Positioned(
left: 578,
top: 132,
child: Container(
width: 800,
height: 50,
child: Text(
'Добро пожаловать, username',
style: TextStyle(
color: Colors.white,
fontSize: 28,
fontFamily: 'Unbounded', // Unbounded font
),
),
),
),
Positioned(
left: 577,
top: 191,
child: Container(
width: 1084,
height: 40,
child: Text(
'Приветствуем в панели хостинга netpc.space, тут вы можете управлять вашими услугами',
style: TextStyle(
color: Colors.grey[300],
fontSize: 16,
fontFamily: 'Roboto',
),
),
),
),
// Server List Section
Positioned(
left: 523,
top: 314,
child: Text(
'My Servers',
style: TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold,
fontFamily: 'Roboto',
),
),
),
Positioned(
left: 523,
top: 380,
child: ServerList(),
),
],
);
}
}
class ServerList extends StatelessWidget {
// Mock server data
final List<Map<String, String>> servers = [
{
'name': 'Server One',
'address': '192.168.1.1',
'cpu': '4 cores',
'ram': '16GB',
'disk': '512GB SSD',
'flag': '🇩🇪', // Germany flag as emoji
},
{
'name': 'Server Two',
'address': '192.168.1.2',
'cpu': '8 cores',
'ram': '32GB',
'disk': '1TB SSD',
'flag': '🇺🇸', // USA flag as emoji
},
// Add more servers as needed
];
@override
Widget build(BuildContext context) {
return Column(
children: servers
.map((server) => Positioned(
child: ServerCard(server: server),
))
.toList(),
);
}
}
class ServerCard extends StatelessWidget {
final Map<String, String> server;
ServerCard({required this.server});
@override
Widget build(BuildContext context) {
return Container(
width: 1176, // Fixed width
height: 139, // Fixed height
margin: EdgeInsets.only(bottom: 16),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.05),
border: Border.all(color: Colors.white30),
borderRadius: BorderRadius.circular(12),
),
child: Padding(
padding: EdgeInsets.fromLTRB(54, 16, 0, 16), // Adjusted padding based on x positions
child: Row(
children: [
// Flag
Text(
server['flag'] ?? '',
style: TextStyle(fontSize: 34),
),
SizedBox(width: 48), // 625 - 577 = 48
// Server Name and Address
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 334,
height: 28,
child: Text(
server['name'] ?? 'Unnamed Server',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontFamily: 'Unbounded', // Unbounded font
),
),
),
SizedBox(height: 16),
Container(
width: 221,
height: 24,
child: Text(
'Address: ${server['address'] ?? 'N/A'}',
style: TextStyle(
color: Colors.grey,
fontSize: 16,
fontFamily: 'Roboto',
),
),
),
SizedBox(height: 8),
// Server Info Buttons
Row(
children: [
InfoButton(label: 'CPU: ${server['cpu'] ?? 'N/A'}'),
SizedBox(width: 8),
InfoButton(label: 'RAM: ${server['ram'] ?? 'N/A'}'),
SizedBox(width: 8),
InfoButton(label: 'Disk: ${server['disk'] ?? 'N/A'}'),
],
),
],
),
Spacer(),
// Manage Button
ElevatedButton.icon(
onPressed: () {
// Handle management action
},
icon: Icon(
Icons.settings,
color: Color(0xFF532E41),
size: 20,
),
label: Text(
'Управление',
style: TextStyle(color: Colors.white, fontFamily: 'Unbounded'),
),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.grey, // Grey background
padding: EdgeInsets.symmetric(vertical: 12, horizontal: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
],
),
),
);
}
}
class InfoButton extends StatelessWidget {
final String label;
InfoButton({required this.label});
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () {
// OnClick info is zero as per specification
},
child: Text(
label,
style: TextStyle(
fontSize: 14,
fontFamily: 'Roboto',
),
),
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: Colors.grey.withOpacity(0.5), // Grey with transparency
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
elevation: 0,
),
);
}
}
class SettingsTab extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Placeholder for Settings
return Center(
child: Text(
'Настройки',
style: TextStyle(
fontSize: 24,
color: Colors.white,
fontFamily: 'Roboto',
),
),
);
}
}
class MainTab extends StatelessWidget {
@override
Widget build(BuildContext context) {
// This widget is no longer used as positions are handled in MainContent
return Container();
}
}
3. Explanation of Changes
-
Sidebar (Sidebar Widget):
- Color: Changed the
color property to Color(0xFF09090A) to match the main content.
- Width: Set to
400 as specified.
- "netpc.space" Text: Positioned at the top center with
NeueMachina font and white color.
- User Card:
- Contains a static user icon, username, a small logout button, and a balance icon without text.
- "Основное" Text: Colored purple (
#532E41) using the specified color code.
- Navigation Buttons: Updated to have a fixed width and height with a background color change when selected.
-
Navigation Button (NavButton Widget):
- Added fixed
width and height to match the static sizing requirement.
- Changed the selected state's background to a semi-transparent black for better visibility.
-
Main Content (MainContent Widget):
- Used a
Stack to position elements absolutely based on the provided x and y coordinates.
- Welcome Image: Positioned with fixed
left and top values, set size, border radius, and integrated a dark overlay using colorFilter.
- Welcome Texts: Positioned texts using the Unbounded font and specified sizes.
- Server List:
- Positioned below the welcome section.
- Each
ServerCard has fixed dimensions and uses absolute positioning within its container to place flags, names, addresses, and info buttons correctly.
- The "Управление" button is styled as per the specification.
-
Server Card (ServerCard Widget):
- Designed with fixed
width and height.
- Contains flag emoji, server details, and management buttons with fixed positions and sizes.
- Info buttons are styled as per the requirements with grey transparency and border radii.
-
Fonts:
4. Important Considerations
-
Responsive Design: While the specifications require static sizing and positioning, Flutter is inherently responsive. Ensure that your application runs on the target devices with the expected screen resolutions to maintain the design integrity.
-
Assets Management: Make sure all asset paths are correct, especially for images and fonts. Incorrect paths can lead to runtime errors.
-
API Integration: Currently, the balance is hardcoded as 10000. When integrating APIs, replace the hardcoded values with dynamic data fetched from your backend.
-
Internationalization: Since the application uses Russian texts, consider setting up internationalization (intl package) if you plan to support multiple languages in the future.
-
Accessibility: Ensure that interactive elements like buttons have appropriate semantic labels for better accessibility support.
5. Final Touches
After implementing the changes, thoroughly test the application on different devices to ensure that all elements are positioned correctly and that the UI matches the desired design. Adjust padding, margins, and sizes as necessary to perfect the layout.
Feel free to further customize the styles, animations, and functionalities to enhance the user experience of your dashboard!