Procházet zdrojové kódy

更新商品列表骨架

tags/0.0.1
Weller před 4 roky
rodič
revize
4a35e79690
17 změnil soubory, kde provedl 665 přidání a 101 odebrání
  1. +295
    -1
      .dart_tool/package_config.json
  2. +24
    -0
      example/ios/Podfile.lock
  3. +22
    -0
      example/ios/Runner/AppDelegate.m
  4. +58
    -19
      lib/pages/home_page/home_page.dart
  5. +28
    -0
      lib/pages/home_page/home_page_bloc.dart
  6. +12
    -8
      lib/pages/main_page/main_page.dart
  7. +3
    -3
      lib/register.dart
  8. +5
    -3
      lib/widgets/home_banner/home_banner.dart
  9. +1
    -1
      lib/widgets/home_banner/home_banner_creater.dart
  10. +1
    -0
      lib/widgets/home_banner/home_banner_sk.dart
  11. +22
    -66
      lib/widgets/home_goods/home_goods_creater.dart
  12. +39
    -0
      lib/widgets/home_goods/home_goods_header.dart
  13. +15
    -0
      lib/widgets/home_goods/home_goods_item.dart
  14. +61
    -0
      lib/widgets/home_goods/skeleton/home_goods_header_sk.dart
  15. +57
    -0
      lib/widgets/home_goods/skeleton/home_goods_item_sk.dart
  16. +20
    -0
      lib/widgets/home_goods/skeleton/home_goods_sk.dart
  17. +2
    -0
      pubspec.yaml

+ 295
- 1
.dart_tool/package_config.json Zobrazit soubor

@@ -1,6 +1,18 @@
{
"configVersion": 2,
"packages": [
{
"name": "_fe_analyzer_shared",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/_fe_analyzer_shared-6.0.0",
"packageUri": "lib/",
"languageVersion": "2.2"
},
{
"name": "analyzer",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/analyzer-0.39.14",
"packageUri": "lib/",
"languageVersion": "2.6"
},
{
"name": "archive",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/archive-2.0.11",
@@ -19,12 +31,66 @@
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "bloc",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/bloc-4.0.0",
"packageUri": "lib/",
"languageVersion": "2.6"
},
{
"name": "boolean_selector",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/boolean_selector-1.0.5",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "build",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/build-1.3.0",
"packageUri": "lib/",
"languageVersion": "2.7"
},
{
"name": "build_config",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/build_config-0.4.2",
"packageUri": "lib/",
"languageVersion": "2.6"
},
{
"name": "build_daemon",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/build_daemon-2.1.4",
"packageUri": "lib/",
"languageVersion": "2.6"
},
{
"name": "build_resolvers",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/build_resolvers-1.3.11",
"packageUri": "lib/",
"languageVersion": "2.7"
},
{
"name": "build_runner",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/build_runner-1.10.1",
"packageUri": "lib/",
"languageVersion": "2.6"
},
{
"name": "build_runner_core",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/build_runner_core-6.0.1",
"packageUri": "lib/",
"languageVersion": "2.7"
},
{
"name": "built_collection",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/built_collection-4.3.2",
"packageUri": "lib/",
"languageVersion": "2.6"
},
{
"name": "built_value",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/built_value-7.1.0",
"packageUri": "lib/",
"languageVersion": "2.3"
},
{
"name": "cached_network_image",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/cached_network_image-2.2.0+1",
@@ -37,12 +103,30 @@
"packageUri": "lib/",
"languageVersion": "1.0"
},
{
"name": "checked_yaml",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/checked_yaml-1.0.2",
"packageUri": "lib/",
"languageVersion": "2.3"
},
{
"name": "cli_util",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/cli_util-0.1.4",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "clock",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/clock-1.0.1",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "code_builder",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/code_builder-3.4.1",
"packageUri": "lib/",
"languageVersion": "2.7"
},
{
"name": "collection",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/collection-1.14.11",
@@ -61,6 +145,18 @@
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "csslib",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/csslib-0.16.2",
"packageUri": "lib/",
"languageVersion": "2.2"
},
{
"name": "dart_style",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/dart_style-1.3.6",
"packageUri": "lib/",
"languageVersion": "2.7"
},
{
"name": "device_info",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/device_info-0.4.2+7",
@@ -79,18 +175,36 @@
"packageUri": "lib/",
"languageVersion": "2.4"
},
{
"name": "equatable",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/equatable-1.2.4",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "file",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/file-5.2.1",
"packageUri": "lib/",
"languageVersion": "2.2"
},
{
"name": "fixnum",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/fixnum-0.10.11",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "flutter",
"rootUri": "file:///Users/fnuser/Documents/flutter-sdk/packages/flutter",
"packageUri": "lib/",
"languageVersion": "2.2"
},
{
"name": "flutter_bloc",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/flutter_bloc-4.0.1",
"packageUri": "lib/",
"languageVersion": "2.6"
},
{
"name": "flutter_cache_manager",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/flutter_cache_manager-1.4.1",
@@ -109,6 +223,12 @@
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "flutter_screenutil",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/flutter_screenutil-1.1.0",
"packageUri": "lib/",
"languageVersion": "2.6"
},
{
"name": "flutter_swiper",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/flutter_swiper-1.1.6",
@@ -133,12 +253,36 @@
"packageUri": "lib/",
"languageVersion": "2.7"
},
{
"name": "glob",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/glob-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "graphs",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/graphs-0.2.0",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "html",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/html-0.14.0+3",
"packageUri": "lib/",
"languageVersion": "2.3"
},
{
"name": "http",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/http-0.12.2",
"packageUri": "lib/",
"languageVersion": "2.4"
},
{
"name": "http_multi_server",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/http_multi_server-2.2.0",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "http_parser",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/http_parser-3.1.4",
@@ -157,6 +301,36 @@
"packageUri": "lib/",
"languageVersion": "2.5"
},
{
"name": "io",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/io-0.3.4",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "js",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/js-0.6.2",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "json_annotation",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/json_annotation-3.0.1",
"packageUri": "lib/",
"languageVersion": "2.6"
},
{
"name": "json_serializable",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/json_serializable-3.4.1",
"packageUri": "lib/",
"languageVersion": "2.7"
},
{
"name": "logging",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/logging-0.11.4",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "matcher",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/matcher-0.12.6",
@@ -169,12 +343,36 @@
"packageUri": "lib/",
"languageVersion": "1.12"
},
{
"name": "mime",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/mime-0.9.7",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "nested",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/nested-0.0.4",
"packageUri": "lib/",
"languageVersion": "2.2"
},
{
"name": "node_interop",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/node_interop-1.1.1",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "node_io",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/node_io-1.1.1",
"packageUri": "lib/",
"languageVersion": "2.2"
},
{
"name": "package_config",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/package_config-1.9.3",
"packageUri": "lib/",
"languageVersion": "2.7"
},
{
"name": "package_info",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/package_info-0.4.3",
@@ -235,6 +433,12 @@
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "pool",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/pool-1.4.0",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "process",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/process-3.0.13",
@@ -247,6 +451,18 @@
"packageUri": "lib/",
"languageVersion": "2.2"
},
{
"name": "pub_semver",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/pub_semver-1.4.4",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "pubspec_parse",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/pubspec_parse-0.1.5",
"packageUri": "lib/",
"languageVersion": "2.2"
},
{
"name": "quiver",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/quiver-2.0.5",
@@ -259,6 +475,48 @@
"packageUri": "lib/",
"languageVersion": "2.6"
},
{
"name": "shared_preferences",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.10",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "shared_preferences_linux",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_linux-0.0.2+2",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "shared_preferences_macos",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_macos-0.0.1+10",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "shared_preferences_platform_interface",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_platform_interface-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "shared_preferences_web",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_web-0.1.2+7",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "shelf",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shelf-0.7.9",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "shelf_web_socket",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shelf_web_socket-0.2.3",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "shimmer",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shimmer-1.1.1",
@@ -271,6 +529,12 @@
"packageUri": "lib/",
"languageVersion": "1.11"
},
{
"name": "source_gen",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/source_gen-0.9.6",
"packageUri": "lib/",
"languageVersion": "2.7"
},
{
"name": "source_span",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/source_span-1.5.5",
@@ -301,6 +565,12 @@
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "stream_transform",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/stream_transform-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.6"
},
{
"name": "string_scanner",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/string_scanner-1.0.5",
@@ -325,6 +595,12 @@
"packageUri": "lib/",
"languageVersion": "2.2"
},
{
"name": "timing",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/timing-0.1.1+2",
"packageUri": "lib/",
"languageVersion": "2.2"
},
{
"name": "transformer_page_view",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/transformer_page_view-0.1.6",
@@ -349,6 +625,18 @@
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "watcher",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/watcher-0.9.7+15",
"packageUri": "lib/",
"languageVersion": "2.2"
},
{
"name": "web_socket_channel",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/web_socket_channel-1.1.0",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "xdg_directories",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/xdg_directories-0.1.0",
@@ -361,6 +649,12 @@
"packageUri": "lib/",
"languageVersion": "2.3"
},
{
"name": "yaml",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/yaml-2.2.1",
"packageUri": "lib/",
"languageVersion": "2.4"
},
{
"name": "zhiying_comm",
"rootUri": "../../zhiying_comm",
@@ -374,7 +668,7 @@
"languageVersion": "2.1"
}
],
"generated": "2020-09-03T11:25:12.333713Z",
"generated": "2020-09-04T06:52:20.100476Z",
"generator": "pub",
"generatorVersion": "2.7.2"
}

+ 24
- 0
example/ios/Podfile.lock Zobrazit soubor

@@ -17,6 +17,14 @@ PODS:
- Flutter
- path_provider_macos (0.0.1):
- Flutter
- shared_preferences (0.0.1):
- Flutter
- shared_preferences_linux (0.0.1):
- Flutter
- shared_preferences_macos (0.0.1):
- Flutter
- shared_preferences_web (0.0.1):
- Flutter
- sqflite (0.0.1):
- Flutter
- FMDB (~> 2.7.2)
@@ -34,6 +42,10 @@ DEPENDENCIES:
- path_provider (from `.symlinks/plugins/path_provider/ios`)
- path_provider_linux (from `.symlinks/plugins/path_provider_linux/ios`)
- path_provider_macos (from `.symlinks/plugins/path_provider_macos/ios`)
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
- shared_preferences_linux (from `.symlinks/plugins/shared_preferences_linux/ios`)
- shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`)
- shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
- zhiying_base_widget (from `.symlinks/plugins/zhiying_base_widget/ios`)
- zhiying_comm (from `.symlinks/plugins/zhiying_comm/ios`)
@@ -59,6 +71,14 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/path_provider_linux/ios"
path_provider_macos:
:path: ".symlinks/plugins/path_provider_macos/ios"
shared_preferences:
:path: ".symlinks/plugins/shared_preferences/ios"
shared_preferences_linux:
:path: ".symlinks/plugins/shared_preferences_linux/ios"
shared_preferences_macos:
:path: ".symlinks/plugins/shared_preferences_macos/ios"
shared_preferences_web:
:path: ".symlinks/plugins/shared_preferences_web/ios"
sqflite:
:path: ".symlinks/plugins/sqflite/ios"
zhiying_base_widget:
@@ -76,6 +96,10 @@ SPEC CHECKSUMS:
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
path_provider_linux: 4d630dc393e1f20364f3e3b4a2ff41d9674a84e4
path_provider_macos: f760a3c5b04357c380e2fddb6f9db6f3015897e0
shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d
shared_preferences_linux: afefbfe8d921e207f01ede8b60373d9e3b566b78
shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087
shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9
sqflite: 4001a31ff81d210346b500c55b17f4d6c7589dd0
zhiying_base_widget: 00868c0d2723a3a425c18b27204fbc67e3f7e59d
zhiying_comm: 0daef4a480f4f4dbea3e11b615f3264aafea924b


+ 22
- 0
example/ios/Runner/AppDelegate.m Zobrazit soubor

@@ -1,5 +1,6 @@
#import "AppDelegate.h"
#import "GeneratedPluginRegistrant.h"
#import <zhiying_comm/ZhiyingCommNative.h>

@implementation AppDelegate

@@ -7,7 +8,28 @@
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GeneratedPluginRegistrant registerWithRegistry:self];
// Override point for customization after application launch.
[ZhiyingCommNative regist: self];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

// 公共跳转方法
- (void)openPage: (NSDictionary*)params {
}

- (void)openNativePage: (NSDictionary*)params {
NSString *method = [params valueForKey:@"method"];
if ([method isEqualToString: @""]) {
}
}


// 获取设置
- (NSDictionary*)getSetting {
return @{
// @"domain": @"http://120.76.175.204:8989"
@"domain": @"http://192.168.0.113:5000"
};
}

@end

+ 58
- 19
lib/pages/home_page/home_page.dart Zobrazit soubor

@@ -1,7 +1,9 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:zhiying_base_widget/pages/home_page/home_page_bloc.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:zhiying_comm/util/base_bloc.dart';

class HomePage extends StatefulWidget {
HomePage({Key key}) : super(key: key);
@@ -11,48 +13,85 @@ class HomePage extends StatefulWidget {
}

class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
print('home_page build');
return BlocProvider<HomePageBloc>(
bloc: HomePageBloc(),
child: _HomePageContainer(),
);
}
}

class _HomePageContainer extends StatefulWidget {
_HomePageContainer({Key key}) : super(key: key);

@override
_HomePageContainerState createState() => _HomePageContainerState();
}

class _HomePageContainerState extends State<_HomePageContainer> {
HomePageBloc _tabBloc;

int _currentIndex = 0;
List<String> _tab = List();
List<Widget> _contentWidgets = List();

@override
void initState() {
_tab.add('首页');
_tab.add('个人中心');
_contentWidgets = _tab.map((item) {
return PageFactory.create('mainPage', Map());
}).toList();
_tabBloc = BlocProvider.of<HomePageBloc>(context);
_tabBloc.refresh();
super.initState();
}

@override
Widget build(BuildContext context) {
print('home_page build');
return Scaffold(
body: IndexedStack(
index: _currentIndex,
children: _contentWidgets,
),
//底部导航栏
bottomNavigationBar: createBottomNavigationBar());
return StreamBuilder<List<Map<String, dynamic>>>(
stream: _tabBloc.outData,
builder: (BuildContext context, AsyncSnapshot snapshot) {
List<Map<String, dynamic>> tabs = snapshot.data;
if (tabs == null || tabs.length == 0) {
return Scaffold();
}

List<Widget> contentWidgets = tabs.map((item) {
WidgetModel model = WidgetModel.fromJson(item);
return PageFactory.create(model.modName, item);
}).toList();
if (_currentIndex >= contentWidgets.length) {
_currentIndex = 0;
}

return Scaffold(
body: IndexedStack(
index: _currentIndex,
children: contentWidgets,
),
//底部导航栏
bottomNavigationBar: createBottomNavigationBar(tabs),
);
},
);
}

Widget createBottomNavigationBar() {
Widget createBottomNavigationBar(List<Map<String, dynamic>> tabs) {
List<BottomNavigationBarItem> items = List<BottomNavigationBarItem>();

for (int i = 0; i < _tab.length; i++) {
for (int i = 0; i < tabs.length; i++) {
WidgetModel model = WidgetModel.fromJson(tabs[i]);
items.add(BottomNavigationBarItem(
icon: Container(
width: 24,
height: 24,
margin: EdgeInsets.only(bottom: 4),
child: CachedNetworkImage(
imageUrl:
"http://www.hairuyi.com/Upload/slide/1594279903_1_0.png",
imageUrl: model.icon,
fit: BoxFit.fitWidth,
),
),
title: Text('tab2')));
title: Text(
model.title,
style: TextStyle(fontSize: 11),
)));
}

if (items.length < 2) {


+ 28
- 0
lib/pages/home_page/home_page_bloc.dart Zobrazit soubor

@@ -0,0 +1,28 @@
import 'dart:async';

import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:zhiying_comm/util/base_bloc.dart';

class HomePageBloc extends BlocBase {
List<Map<String, dynamic>> _tabs = List();

StreamController<List<Map<String, dynamic>>> _tabController =
StreamController<List<Map<String, dynamic>>>();
Stream<List<Map<String, dynamic>>> get outData => _tabController.stream;

@override
void dispose() {
_tabController.close();
_tabController = null;
}

void refresh() {
NetUtil.request('/api/v1/config.json', onSuccess: (data) {
List list = data;
_tabs = list.map((item) {
return Map<String, dynamic>.from(item);
}).toList();
_tabController.add(_tabs);
});
}
}

+ 12
- 8
lib/pages/main_page/main_page.dart Zobrazit soubor

@@ -36,6 +36,12 @@ class _MainPageContainerState extends State<MainPageContainer> {
bool _isEnded = false;
ScrollController _controller = ScrollController();

@override
void dispose() {
_controller.dispose();
super.dispose();
}

@override
void initState() {
_reload();
@@ -77,14 +83,12 @@ class _MainPageContainerState extends State<MainPageContainer> {
child: Text('重置'),
),
));
list.addAll(
WidgetFactory.create('home_banner', type: _type, isSliver: true));
list.addAll(
WidgetFactory.create('home_goods', type: _type, isSliver: true));
// list.addAll(
// WidgetFactory.create('home_goods', type: _type, isSliver: true));
// list.addAll(
// WidgetFactory.create('home_goods', type: _type, isSliver: true));
list.addAll(WidgetFactory.create('index_carousel',
type: _type,
isSliver: true,
model: Map<String, dynamic>.from({'aaaaa': 'bbbb'})));
list.addAll(WidgetFactory.create('index_recommend_list',
type: _type, isSliver: true));
return list;
}



+ 3
- 3
lib/register.dart Zobrazit soubor

@@ -14,12 +14,12 @@ class BaseWidgetRegister {
// 注册页面
static void registPage() {
PageFactory.regist('homePage', (model) => HomePage());
PageFactory.regist('mainPage', (model) => MainPage());
PageFactory.regist('index', (model) => MainPage());
}

// 注册控件
static void registWidgets() {
WidgetFactory.regist('home_banner', HomeBannerCreater());
WidgetFactory.regist('home_goods', GoodsListCreater());
WidgetFactory.regist('index_carousel', HomeBannerCreater());
WidgetFactory.regist('index_recommend_list', GoodsListCreater());
}
}

+ 5
- 3
lib/widgets/home_banner/home_banner.dart Zobrazit soubor

@@ -3,6 +3,10 @@ import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

class HomeBanner extends StatelessWidget {
final Map<String, dynamic> model;

const HomeBanner(this.model, {Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
@@ -20,9 +24,7 @@ class HomeBanner extends StatelessWidget {
pagination: new SwiperPagination(),
control: new SwiperControl(),
onTap: (index) {
Map<String, dynamic> model = Map();
model['name'] = '123';
RouterUtil.route(model, context);
print(model.toString());
},
),
);


+ 1
- 1
lib/widgets/home_banner/home_banner_creater.dart Zobrazit soubor

@@ -11,6 +11,6 @@ class HomeBannerCreater extends WidgetCreater {

@override
List<Widget> createWidgets(Map<String, dynamic> model) {
return [HomeBanner()];
return [HomeBanner(model)];
}
}

+ 1
- 0
lib/widgets/home_banner/home_banner_sk.dart Zobrazit soubor

@@ -7,6 +7,7 @@ class HomeBannerSkeleton extends StatelessWidget {
return Container(
width: double.infinity,
height: 200,
color: Colors.white,
child: Shimmer.fromColors(
baseColor: Colors.grey[300],
highlightColor: Colors.grey[100],


+ 22
- 66
lib/widgets/home_goods/home_goods_creater.dart Zobrazit soubor

@@ -1,5 +1,8 @@
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/widgets/home_goods/home_goods.dart';
import 'package:zhiying_base_widget/widgets/home_goods/home_goods_header.dart';
import 'package:zhiying_base_widget/widgets/home_goods/skeleton/home_goods_header_sk.dart';
import 'package:zhiying_base_widget/widgets/home_goods/skeleton/home_goods_sk.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class GoodsListCreater extends WidgetCreater {
@@ -15,89 +18,42 @@ class GoodsListCreater extends WidgetCreater {

@override
List<Widget> createSkeleton(Map<String, dynamic> model) {
return [];
return [
_createHeaderSkeleton(),
_createBodySkeleton(),
];
}

Widget _createHeader(TabController controller) {
return SliverPersistentHeader(
pinned: true,
floating: false,
delegate: GoodsHeaderDelegate(controller),
delegate: HomeGoodsDelegate(controller),
);
}

Widget _createHeaderSkeleton() {
return SliverPersistentHeader(
pinned: true,
floating: false,
delegate: HomeGoodsHeaderSkeletonDelegate(),
);
}

Widget _createBody(TabController controller) {
// return SliverToBoxAdapter(
// child: Container(
// width: double.infinity,
// height: 200,
// // child: Expanded(child: Container()),
// child: TabBarView(
// controller: controller,
// children: <Widget>[
// Icon(Icons.directions_bike, size: 128.0, color: Colors.black12),
// ListView.builder(
// itemCount: 20,
// itemBuilder: (context, index) {
// return Container(
// width: double.infinity,
// height: 70,
// color: Colors.primaries[index % Colors.primaries.length],
// );
// }),
// Icon(Icons.directions_bike, size: 128.0, color: Colors.black12),
// Icon(Icons.local_florist, size: 128.0, color: Colors.black12),
// Icon(Icons.change_history, size: 128.0, color: Colors.black12),
// Icon(Icons.directions_bike, size: 128.0, color: Colors.black12),
// ],
// ),
// ),
// );
return SliverToBoxAdapter(
child: HomeGoods(),
);
}

@override
bool isSliverChild() {
return true;
}
}

class GoodsHeaderDelegate extends SliverPersistentHeaderDelegate {
final TabController controller;

GoodsHeaderDelegate(this.controller);

@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
// print(shrinkOffset.toString());
return Container(
color: Colors.red,
alignment: Alignment.center,
child: TabBar(
controller: controller,
isScrollable: true,
tabs: <Widget>[
Tab(icon: Icon(Icons.local_florist)),
Tab(icon: Icon(Icons.change_history)),
Tab(icon: Icon(Icons.directions_bike)),
Tab(icon: Icon(Icons.local_florist)),
Tab(icon: Icon(Icons.change_history)),
Tab(icon: Icon(Icons.directions_bike)),
],
),
Widget _createBodySkeleton() {
return SliverToBoxAdapter(
child: HomeGoodsSkeleton(),
);
}

@override
double get maxExtent => 60.0;

@override
double get minExtent => 60.0;

@override
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) =>
false; // 如果内容需要更新,设置为true
bool isSliverChild() {
return true;
}
}

+ 39
- 0
lib/widgets/home_goods/home_goods_header.dart Zobrazit soubor

@@ -0,0 +1,39 @@
import 'package:flutter/material.dart';

class HomeGoodsDelegate extends SliverPersistentHeaderDelegate {
final TabController controller;

HomeGoodsDelegate(this.controller);

@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
// print(shrinkOffset.toString());
return Container(
color: Colors.red,
alignment: Alignment.center,
child: TabBar(
controller: controller,
isScrollable: true,
tabs: <Widget>[
Tab(icon: Icon(Icons.local_florist)),
Tab(icon: Icon(Icons.change_history)),
Tab(icon: Icon(Icons.directions_bike)),
Tab(icon: Icon(Icons.local_florist)),
Tab(icon: Icon(Icons.change_history)),
Tab(icon: Icon(Icons.directions_bike)),
],
),
);
}

@override
double get maxExtent => 60.0;

@override
double get minExtent => 60.0;

@override
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) =>
false; // 如果内容需要更新,设置为true
}

+ 15
- 0
lib/widgets/home_goods/home_goods_item.dart Zobrazit soubor

@@ -0,0 +1,15 @@
import 'package:flutter/material.dart';

class HomeGoodsItem extends StatelessWidget {
const HomeGoodsItem({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(7.5))),
);
}
}

+ 61
- 0
lib/widgets/home_goods/skeleton/home_goods_header_sk.dart Zobrazit soubor

@@ -0,0 +1,61 @@
import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';
import 'package:zhiying_base_widget/widgets/home_banner/home_banner_sk.dart';

class HomeGoodsHeaderSkeletonDelegate extends SliverPersistentHeaderDelegate {
HomeGoodsHeaderSkeletonDelegate();

@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return Container(
width: double.infinity,
height: double.infinity,
color: Colors.white,
child: Shimmer.fromColors(
baseColor: Colors.grey[300],
highlightColor: Colors.grey[100],
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: List.generate(5, (index) {
return Expanded(
flex: 1,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
width: double.infinity,
height: 20,
margin: EdgeInsets.only(left: 10, right: 10, bottom: 4),
color: Colors.white,
),
Container(
width: double.infinity,
height: 10,
margin: EdgeInsets.only(left: 20, right: 20),
color: Colors.white,
),
],
),
),
);
}),
),
),
),
);
}

@override
double get maxExtent => 64.0;

@override
double get minExtent => 64.0;

@override
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) =>
false; // 如果内容需要更新,设置为true
}

+ 57
- 0
lib/widgets/home_goods/skeleton/home_goods_item_sk.dart Zobrazit soubor

@@ -0,0 +1,57 @@
import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';

class HomeGoodsItemSkeleton extends StatelessWidget {
const HomeGoodsItemSkeleton({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4),
padding: EdgeInsets.all(7.5),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(7.5))),
child: Shimmer.fromColors(
baseColor: Colors.grey[300],
highlightColor: Colors.grey[100],
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
width: 126,
height: 126,
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(7.5))),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
width: double.infinity,
height: 35,
color: Colors.white,
),
Container(
margin: EdgeInsets.only(top: 6),
width: double.infinity,
height: 12,
color: Colors.white,
),
Container(
margin: EdgeInsets.only(top: 6),
width: 80,
height: 12,
color: Colors.white,
)
],
))
],
),
),
);
}
}

+ 20
- 0
lib/widgets/home_goods/skeleton/home_goods_sk.dart Zobrazit soubor

@@ -0,0 +1,20 @@
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/widgets/home_goods/skeleton/home_goods_item_sk.dart';

class HomeGoodsSkeleton extends StatelessWidget {
const HomeGoodsSkeleton({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
child: ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: 6,
itemBuilder: (context, index) {
return HomeGoodsItemSkeleton();
}),
);
}
}

+ 2
- 0
pubspec.yaml Zobrazit soubor

@@ -14,6 +14,8 @@ dependencies:
shimmer: ^1.1.1
flutter_swiper : ^1.1.6
provider: ^4.0.0
bloc: ^4.0.0
flutter_bloc: ^4.0.1

dev_dependencies:
flutter_test:


Načítá se…
Zrušit
Uložit