parent
fb60f29c88
commit
af5d2b53f1
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 28 KiB |
@ -0,0 +1,38 @@
|
||||
|
||||
extension ListExt<T> on List<T> {
|
||||
List<T> sep(T sep) => _sepIterable(sep).toList();
|
||||
|
||||
Iterable<T> _sepIterable(T separate) sync* {
|
||||
final it = iterator;
|
||||
if (!it.moveNext()) return;
|
||||
yield it.current;
|
||||
while (it.moveNext()) {
|
||||
yield separate;
|
||||
yield it.current;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension OddListExt<T> on List<T> {
|
||||
List<T> oddList() {
|
||||
List<T> newList = [];
|
||||
for (var element in this) {
|
||||
if (indexOf(element).isEven) {
|
||||
newList.add(element);
|
||||
}
|
||||
}
|
||||
return newList;
|
||||
}
|
||||
}
|
||||
|
||||
extension EvenListExt<T> on List<T> {
|
||||
List<T> evenList() {
|
||||
List<T> newList = [];
|
||||
forEach((element) {
|
||||
if (indexOf(element).isOdd) {
|
||||
newList.add(element);
|
||||
}
|
||||
});
|
||||
return newList;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
|
||||
extension NumExt on num {
|
||||
Widget get wb => SizedBox(width: w);
|
||||
|
||||
Widget get hb => SizedBox(height: w);
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
/// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
/// *****************************************************
|
||||
/// FlutterGen
|
||||
/// *****************************************************
|
||||
|
||||
// ignore_for_file: directives_ordering,unnecessary_import
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class $AssetsIconsGen {
|
||||
const $AssetsIconsGen();
|
||||
|
||||
/// File path: assets/icons/personal_select.png
|
||||
AssetGenImage get personalSelect =>
|
||||
const AssetGenImage('assets/icons/personal_select.png');
|
||||
|
||||
/// File path: assets/icons/personal_unselect.png
|
||||
AssetGenImage get personalUnselect =>
|
||||
const AssetGenImage('assets/icons/personal_unselect.png');
|
||||
|
||||
/// File path: assets/icons/work_stage_select.png
|
||||
AssetGenImage get workStageSelect =>
|
||||
const AssetGenImage('assets/icons/work_stage_select.png');
|
||||
|
||||
/// File path: assets/icons/work_stage_unselect.png
|
||||
AssetGenImage get workStageUnselect =>
|
||||
const AssetGenImage('assets/icons/work_stage_unselect.png');
|
||||
}
|
||||
|
||||
class $AssetsImagesGen {
|
||||
const $AssetsImagesGen();
|
||||
|
||||
/// File path: assets/images/app_title.png
|
||||
AssetGenImage get appTitle =>
|
||||
const AssetGenImage('assets/images/app_title.png');
|
||||
|
||||
/// File path: assets/images/home_bg.png
|
||||
AssetGenImage get homeBg => const AssetGenImage('assets/images/home_bg.png');
|
||||
}
|
||||
|
||||
class Assets {
|
||||
Assets._();
|
||||
|
||||
static const $AssetsIconsGen icons = $AssetsIconsGen();
|
||||
static const $AssetsImagesGen images = $AssetsImagesGen();
|
||||
}
|
||||
|
||||
class AssetGenImage extends AssetImage {
|
||||
const AssetGenImage(String assetName) : super(assetName);
|
||||
|
||||
Image image({
|
||||
Key? key,
|
||||
ImageFrameBuilder? frameBuilder,
|
||||
ImageLoadingBuilder? loadingBuilder,
|
||||
ImageErrorWidgetBuilder? errorBuilder,
|
||||
String? semanticLabel,
|
||||
bool excludeFromSemantics = false,
|
||||
double? width,
|
||||
double? height,
|
||||
Color? color,
|
||||
BlendMode? colorBlendMode,
|
||||
BoxFit? fit,
|
||||
AlignmentGeometry alignment = Alignment.center,
|
||||
ImageRepeat repeat = ImageRepeat.noRepeat,
|
||||
Rect? centerSlice,
|
||||
bool matchTextDirection = false,
|
||||
bool gaplessPlayback = false,
|
||||
bool isAntiAlias = false,
|
||||
FilterQuality filterQuality = FilterQuality.low,
|
||||
}) {
|
||||
return Image(
|
||||
key: key,
|
||||
image: this,
|
||||
frameBuilder: frameBuilder,
|
||||
loadingBuilder: loadingBuilder,
|
||||
errorBuilder: errorBuilder,
|
||||
semanticLabel: semanticLabel,
|
||||
excludeFromSemantics: excludeFromSemantics,
|
||||
width: width,
|
||||
height: height,
|
||||
color: color,
|
||||
colorBlendMode: colorBlendMode,
|
||||
fit: fit,
|
||||
alignment: alignment,
|
||||
repeat: repeat,
|
||||
centerSlice: centerSlice,
|
||||
matchTextDirection: matchTextDirection,
|
||||
gaplessPlayback: gaplessPlayback,
|
||||
isAntiAlias: isAntiAlias,
|
||||
filterQuality: filterQuality,
|
||||
);
|
||||
}
|
||||
|
||||
String get path => assetName;
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
import 'package:cloud_car_internal/gen/assets.gen.dart';
|
||||
import 'package:cloud_car_internal/utils/user_tool.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({super.key});
|
||||
|
||||
@override
|
||||
_HomePageState createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
title: Row(
|
||||
children: [
|
||||
Text(
|
||||
'HI,张三',
|
||||
style: UserTool.myAppStyle.titleText,
|
||||
)
|
||||
],
|
||||
),
|
||||
centerTitle: false,
|
||||
),
|
||||
extendBody: true,
|
||||
extendBodyBehindAppBar: true,
|
||||
body: Stack(
|
||||
children: [
|
||||
Assets.images.homeBg
|
||||
.image(fit: BoxFit.fill, width: double.infinity, height: 200.w),
|
||||
CustomScrollView(
|
||||
slivers: [
|
||||
SliverGrid.count(
|
||||
crossAxisCount: 4,
|
||||
children: [],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
import 'package:cloud_car_internal/widget/scaffold/cloud_scaffold.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PersonalPage extends StatefulWidget {
|
||||
const PersonalPage({super.key});
|
||||
|
||||
@override
|
||||
_PersonalPageState createState() => _PersonalPageState();
|
||||
}
|
||||
|
||||
class _PersonalPageState extends State<PersonalPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CloudScaffold();
|
||||
}
|
||||
}
|
@ -1,15 +1,112 @@
|
||||
import 'package:bot_toast/bot_toast.dart';
|
||||
import 'package:cloud_car_internal/gen/assets.gen.dart';
|
||||
import 'package:cloud_car_internal/ui/personal/personal_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
|
||||
import '../utils/user_tool.dart';
|
||||
import 'home/home_page.dart';
|
||||
|
||||
class TabNavigator extends StatefulWidget {
|
||||
const TabNavigator({super.key});
|
||||
final int? index;
|
||||
|
||||
const TabNavigator({
|
||||
super.key,
|
||||
this.index,
|
||||
});
|
||||
|
||||
@override
|
||||
_TabNavigatorState createState() => _TabNavigatorState();
|
||||
}
|
||||
|
||||
class _TabNavigatorState extends State<TabNavigator> {
|
||||
class _TabNavigatorState extends State<TabNavigator>
|
||||
with SingleTickerProviderStateMixin {
|
||||
TabController? _tabController;
|
||||
int _currentIndex = 0;
|
||||
DateTime? _lastPressed;
|
||||
|
||||
//页面列表
|
||||
List<Widget> get _pages => [
|
||||
const HomePage(),
|
||||
const PersonalPage(),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_tabController = TabController(
|
||||
length: _pages.length, vsync: this, initialIndex: widget.index ?? 0);
|
||||
}
|
||||
|
||||
_buildBottomBar(
|
||||
String title,
|
||||
String unselected,
|
||||
String selected,
|
||||
) {
|
||||
return BottomNavigationBarItem(
|
||||
icon: Image.asset(
|
||||
unselected,
|
||||
height: 44.w,
|
||||
width: 44.w,
|
||||
//color: Colors.black38,
|
||||
),
|
||||
activeIcon: Image.asset(
|
||||
selected,
|
||||
height: 44.w,
|
||||
width: 44.w,
|
||||
),
|
||||
label: title,
|
||||
);
|
||||
}
|
||||
|
||||
late bool isOpen = UserTool.userProvider.userInfo.level < 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
//底部导航来
|
||||
List<BottomNavigationBarItem> bottomNav = <BottomNavigationBarItem>[
|
||||
_buildBottomBar(
|
||||
'工作台',
|
||||
Assets.icons.workStageUnselect.path,
|
||||
Assets.icons.workStageSelect.path,
|
||||
),
|
||||
_buildBottomBar(
|
||||
'我的',
|
||||
Assets.icons.personalUnselect.path,
|
||||
Assets.icons.personalSelect.path,
|
||||
),
|
||||
];
|
||||
return Scaffold(
|
||||
body: WillPopScope(
|
||||
onWillPop: () async {
|
||||
if (_lastPressed == null ||
|
||||
DateTime.now().difference(_lastPressed!) >
|
||||
const Duration(seconds: 1)) {
|
||||
//两次点击间隔超过1秒重新计算
|
||||
_lastPressed = DateTime.now();
|
||||
BotToast.showText(text: '再点击一次返回退出');
|
||||
return false;
|
||||
}
|
||||
//否则关闭app
|
||||
return true;
|
||||
},
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: _pages,
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
items: bottomNav,
|
||||
backgroundColor: Colors.white,
|
||||
currentIndex: _currentIndex,
|
||||
selectedFontSize: 12.sp,
|
||||
unselectedFontSize: 12.sp,
|
||||
onTap: (index) {
|
||||
_tabController!.animateTo(index, curve: Curves.easeInOutCubic);
|
||||
setState(() => _currentIndex = index);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
import 'package:cloud_car_internal/utils/user_tool.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AccountInputTextField extends StatelessWidget {
|
||||
final String hintText;
|
||||
final Function(String) onChange;
|
||||
|
||||
const AccountInputTextField(
|
||||
{super.key, required this.hintText, required this.onChange});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextField(
|
||||
onChanged: onChange,
|
||||
decoration: InputDecoration(
|
||||
border: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: UserTool.myAppStyle.lightDark!)),
|
||||
hintText: hintText,
|
||||
hintStyle: UserTool.myAppStyle.hintText),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue