# Conflicts:
#	lib/buttons/as_button.dart
null_safety
张萌 4 years ago
commit 367b9edeba

@ -1,3 +1,9 @@
# ansu_ui 安速物流移动组件
## Getting Started
## 贡献
### 组件命名
* 命名规则 `as_***`,例如 `as_button`

@ -0,0 +1,18 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/material.dart';
class ExampleScaffold extends StatefulWidget {
ExampleScaffold({Key key}) : super(key: key);
@override
_ExampleScaffoldState createState() => _ExampleScaffoldState();
}
class _ExampleScaffoldState extends State<ExampleScaffold> {
@override
Widget build(BuildContext context) {
return ASScaffold(
title: '标题',
);
}
}

@ -1,6 +1,9 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:ansu_ui/buttons/as_button.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'example_scaffold.dart';
void main() {
runApp(MyApp());
@ -9,44 +12,24 @@ void main() {
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
ScreenUtil.init(context,
designSize: Size(750, 1334), allowFontScaling: false);
return MaterialApp(
return GetMaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
// This makes the visual density adapt to the platform that you run
// the app on. For desktop platforms, the controls will be smaller and
// closer together (more dense) than on mobile platforms.
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
home: _ScreenAdapter(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
// 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".
class _ScreenAdapter extends StatelessWidget {
@override
Widget build(BuildContext context) {
ScreenUtil.init(context,
designSize: Size(375, 812), allowFontScaling: false);
return MyHomePage();
}
}
final String title;
class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
@ -57,12 +40,17 @@ class _MyHomePageState extends State<MyHomePage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
title: Text('title'),
),
body: ListView(
children: [
ASButton.gray('删除订单', (){}),
SizedBox(height: 12.w),
TextButton(
onPressed: () {
Get.to(ExampleScaffold());
},
child: Text('SCAFFOLD')),
],
),
);

@ -81,6 +81,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
get:
dependency: "direct main"
description:
name: get
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.17.1"
matcher:
dependency: transitive
description:
@ -164,5 +171,5 @@ packages:
source: hosted
version: "2.1.0-nullsafety.3"
sdks:
dart: ">=2.10.0-110 <2.11.0"
dart: ">=2.10.0 <2.11.0"
flutter: ">=1.17.0"

@ -30,6 +30,7 @@ dependencies:
cupertino_icons: ^1.0.0
ansu_ui:
path: ../
get:
dev_dependencies:
flutter_test:

@ -1,4 +1,8 @@
library ansu_ui;
export 'buttons/as_button.dart';
export 'scaffold/as_scaffold.dart';
export 'styles/as_colors.dart';
//`BOTTOM` is external lib
export 'package:flutter_screenutil/flutter_screenutil.dart';

@ -0,0 +1,26 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class ASBackButton extends StatelessWidget {
final Color color;
const ASBackButton({Key key, this.color = kDarkColor}) : super(key: key);
const ASBackButton.white({Key key})
: color = kForegroundColor,
super(key: key);
@override
Widget build(BuildContext context) {
return Navigator.canPop(context)
? IconButton(
icon: Icon(
CupertinoIcons.chevron_back,
size: 24,
color: color,
),
onPressed: () => Navigator.pop(context),
)
: SizedBox();
}
}

@ -0,0 +1,55 @@
import 'package:ansu_ui/buttons/as_back_button.dart';
import 'package:ansu_ui/styles/as_colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
///ASScaffold
///
///made with Scaffold from `Material`
///
///`title`,`body`
///
///`leading`
class ASScaffold extends StatefulWidget {
///`String``Text`
final dynamic title;
/// `Scaffold` body
final Widget body;
/// `Scaffold` leading
final Widget leading;
ASScaffold({
Key key,
@required this.title,
this.leading,
this.body,
}) : super(key: key);
@override
_ASScaffoldState createState() => _ASScaffoldState();
}
class _ASScaffoldState extends State<ASScaffold> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: kBackgroundColor,
appBar: AppBar(
backgroundColor: kForegroundColor,
elevation: 0,
leading: ASBackButton(),
centerTitle: true,
title: DefaultTextStyle(
style: TextStyle(
color: kTextColor,
fontSize: 18.sp,
fontWeight: FontWeight.bold,
),
child: widget.title is String ? Text(widget.title) : widget.title,
),
),
body: widget.body,
);
}
}

@ -0,0 +1,16 @@
import 'package:flutter/material.dart';
///
const Color kDarkColor = Color(0xFF333333);
///
const Color kTextColor = kDarkColor;
///
const Color kPrimaryColor = Color(0xFFF6B72D);
///
const Color kForegroundColor = Color(0xFFFFFFFF);
///
const Color kBackgroundColor = Color(0xFFF6F6F6);
Loading…
Cancel
Save