rui_admin 0.0.1 copy "rui_admin: ^0.0.1" to clipboard
rui_admin: ^0.0.1 copied to clipboard

A flutter UI, for crossing platform APP, supporting mobile and windows, macos, web. 主要特点:admin布局,左侧菜单栏可展开收起,在宽度太小时自动切换为drawer。

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:rui_admin/components/menu/rui_menu_item.dart'; 
import 'package:rui_admin/components/panels/head_tools_bar.dart'; 
import 'package:rui_admin/components/panels/user/rui_login_status_panel.dart';
import 'package:rui_admin/components/panels/web_footer.dart';
import 'package:rui_admin/pages/about_page.dart';
import 'package:rui_admin/pages/login_page.dart';
import 'package:rui_admin/rui_route.dart';

import "package:rui_admin/pages/contact_page.dart";

// import 'package:rui_admin/index.dart';

import 'package:rui_admin/rui_app.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  runApp(MyApp());
  // runApp();
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return RuiApp(
      title: "RUI APP", 
      // 定义初始路由
      initialRoute: '/home',
      routes: {
        // 定义路由映射
        '/home': (context) => MyHomePage(
              title: 'Flutter Demo Home Page',
            ),
        '/login': (context) => LoginPage(),
        '/about': (context) => AboutPage(),
        '/contact': (context) => ContactPage(),
      },
      headerMainPanel: _buildHeader(context),
      headerToolsPanel: const RuiHeadToolsBar(),
      headerUserPanel: _buildHeaderUserPanel(context), 
      logo: Icons.apple,
      appName: "RUI", 
      leftFooterWidget: _buildLeftFooterPanel(context), 
      footerPanel: _buildFooter(context),
      rightMenuButtons: _buildRightMenuButtons(context),
      rightPanel: _buildRightPanel(context), 
      onGenLeftMenuButtons: (BuildContext context) {
        return genLeftMenuItems(context);
      }, 
      onLogoPressed: () {
        print("logo pressed");
      },
    );
  }

  Widget _buildHeader(BuildContext context) {
    return Container(
      // color: Colors.blue,
      child: Text("Demo of Rui"),
    );
  }

  Widget _buildHeaderUserPanel(BuildContext context) {
    return Container(
      child: Row(
        children: [
          RuiLoginStatusPanel(
            userName: "张三",
            userPhone: "18000000000",
            userImage:
                "https://th.bing.com/th?id=OSK.f7f4e9af4e9ca9ea2585e5df12ff1c5f&w=80&h=80&c=7&o=6&dpr=2&pid=SANGAM",
            userEmail: "test@qwe.com",
          ),
        ],
      ),
    );
  }

  Widget _buildFooter(BuildContext context) {
    return const WebFooter();
  }

  // Widget _buildLeftMainPanel(BuildContext context) {
  //   // return Text("data");
  //   return RuiLeftNavBar(
  //       isOpen: _isLeftPanelOpen, menuItems: genLeftMenuItems(context));
  // }

  Widget _buildLeftFooterPanel(BuildContext context) {
    return const Icon(Icons.abc);
  }

  void onLeftBarToggle(bool isOpen) {}

  List<RuiMenuItem> genLeftMenuItems(BuildContext context) {
    return [
      RuiMenuItem(
        id: "home",
        icon: Icons.home,
        title: 'Home',
        subItems: [],
      ),
      RuiMenuItem(
        id: "settings",
        icon: Icons.settings,
        title: 'settings',
        subItems: [],
      ),
      RuiMenuItem(
        id: "About",
        icon: Icons.info,
        title: 'About',
        subItems: [
          RuiMenuItem(
            id: "AboutUs",
            icon: Icons.person,
            title: 'About Us',
            subItems: [],
          ),
          RuiMenuItem(
            id: "ContactUs",
            icon: Icons.email,
            title: 'Contact Us',
            subItems: [],
            onPressed: () {},
          ),
        ],
      ),
      RuiMenuItem(
        id: "Logout",
        icon: Icons.logout,
        title: 'Logout',
      ),
    ];
  }

  List<MenuItemButton> _buildRightMenuButtons(BuildContext context) {
    return [
      MenuItemButton(
        child: Text('打开'),
        shortcut: SingleActivator(LogicalKeyboardKey.keyO, control: true),
        onPressed: () {
          print("======打开==========");
        },
      ),
      MenuItemButton(
        child: Text('print'),
        shortcut: SingleActivator(LogicalKeyboardKey.keyE, meta: true),
        onPressed: () {
          print("======print==========");
        },
      ),
      MenuItemButton(
        child: Text('Exit'),
        onPressed: () {
          print("======exit==========");
        },
      ),
    ];
  }

  Widget _buildRightPanel(BuildContext context) {
    return Container(
      // color: Colors.purple,
      child: Text("Right Panel"),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({super.key, required this.title});

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;
  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // appBar: AppBar(
      //   title: Text(widget.title),
      //   leading: Icon(Icons.home),
      //   actions: [
      //     MenuAnchor(
      //         menuChildren: [
      //           MenuItemButton(child: Text("test"), onPressed: () {}),
      //           MenuItemButton(child: Text("test"), onPressed: () {}),
      //           MenuItemButton(child: Text("test"), onPressed: () {})
      //         ],
      //         child: IconButton(
      //           icon: Icon(Icons.menu),
      //           onPressed: () {},
      //         ))
      //   ],
      // ),
      body: Column(
        children: [
          Text(
            '$_counter',
            style: Theme.of(context).textTheme.headlineMedium,
          ),
          ElevatedButton(
            onPressed: () {
              // Navigator.pushNamed(context, "/login");
              Navigator.push(context, CustomPageRoute(child: LoginPage()));
            },
            child: Text("Goto login"),
          ),
        ],
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
1
likes
0
points
67
downloads

Publisher

unverified uploader

Weekly Downloads

A flutter UI, for crossing platform APP, supporting mobile and windows, macos, web. 主要特点:admin布局,左侧菜单栏可展开收起,在宽度太小时自动切换为drawer。

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, loading_animation_widget, provider, shared_preferences

More

Packages that depend on rui_admin