Jelajahi Sumber

接单页长按拨打电话

daxu0403 7 tahun lalu
induk
melakukan
1028889489

+ 1 - 0
.flutter-plugins

@@ -1,3 +1,4 @@
 city_pickers=/Users/daxu/app/flutter/.pub-cache/hosted/pub.dartlang.org/city_pickers-0.0.4/
 flutter_picker=/Users/daxu/app/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_picker-1.0.8/
 shared_preferences=/Users/daxu/app/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.1+1/
+url_launcher=/Users/daxu/app/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.0.1/

+ 2 - 1
.packages

@@ -1,4 +1,4 @@
-# Generated by pub on 2019-03-06 16:52:52.878346.
+# Generated by pub on 2019-03-09 14:17:22.566811.
 async:file:///Users/daxu/app/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.0.8/lib/
 boolean_selector:file:///Users/daxu/app/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.4/lib/
 charcode:file:///Users/daxu/app/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib/
@@ -25,5 +25,6 @@ string_scanner:file:///Users/daxu/app/flutter/.pub-cache/hosted/pub.dartlang.org
 term_glyph:file:///Users/daxu/app/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.0.1/lib/
 test_api:file:///Users/daxu/app/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.1/lib/
 typed_data:file:///Users/daxu/app/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib/
+url_launcher:file:///Users/daxu/app/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.0.1/lib/
 vector_math:file:///Users/daxu/app/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/
 logistics_client:lib/

TEMPAT SAMPAH
android/.gradle/4.10.2/fileHashes/fileHashes.bin


TEMPAT SAMPAH
android/.gradle/4.10.2/fileHashes/fileHashes.lock


TEMPAT SAMPAH
android/.gradle/4.10.2/fileHashes/resourceHashesCache.bin


TEMPAT SAMPAH
android/.gradle/4.10.2/javaCompile/classAnalysis.bin


TEMPAT SAMPAH
android/.gradle/4.10.2/javaCompile/jarAnalysis.bin


TEMPAT SAMPAH
android/.gradle/4.10.2/javaCompile/javaCompile.lock


TEMPAT SAMPAH
android/.gradle/4.10.2/javaCompile/taskHistory.bin


TEMPAT SAMPAH
android/.gradle/4.10.2/taskHistory/taskHistory.bin


TEMPAT SAMPAH
android/.gradle/4.10.2/taskHistory/taskHistory.lock


TEMPAT SAMPAH
android/.gradle/buildOutputCleanup/buildOutputCleanup.lock


TEMPAT SAMPAH
android/.gradle/buildOutputCleanup/outputFiles.bin


+ 2 - 0
android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java

@@ -4,6 +4,7 @@ import io.flutter.plugin.common.PluginRegistry;
 import com.example.citypickers.CityPickersPlugin;
 import com.yangyxd.flutterpicker.FlutterPickerPlugin;
 import io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin;
+import io.flutter.plugins.urllauncher.UrlLauncherPlugin;
 
 /**
  * Generated file. Do not edit.
@@ -16,6 +17,7 @@ public final class GeneratedPluginRegistrant {
     CityPickersPlugin.registerWith(registry.registrarFor("com.example.citypickers.CityPickersPlugin"));
     FlutterPickerPlugin.registerWith(registry.registrarFor("com.yangyxd.flutterpicker.FlutterPickerPlugin"));
     SharedPreferencesPlugin.registerWith(registry.registrarFor("io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin"));
+    UrlLauncherPlugin.registerWith(registry.registrarFor("io.flutter.plugins.urllauncher.UrlLauncherPlugin"));
   }
 
   private static boolean alreadyRegisteredWith(PluginRegistry registry) {

+ 2 - 0
ios/Runner/GeneratedPluginRegistrant.m

@@ -6,6 +6,7 @@
 #import <city_pickers/CityPickersPlugin.h>
 #import <flutter_picker/FlutterPickerPlugin.h>
 #import <shared_preferences/SharedPreferencesPlugin.h>
+#import <url_launcher/UrlLauncherPlugin.h>
 
 @implementation GeneratedPluginRegistrant
 
@@ -13,6 +14,7 @@
   [CityPickersPlugin registerWithRegistrar:[registry registrarForPlugin:@"CityPickersPlugin"]];
   [FlutterPickerPlugin registerWithRegistrar:[registry registrarForPlugin:@"FlutterPickerPlugin"]];
   [FLTSharedPreferencesPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTSharedPreferencesPlugin"]];
+  [FLTUrlLauncherPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTUrlLauncherPlugin"]];
 }
 
 @end

+ 32 - 20
lib/pages/order_taking_page.dart

@@ -1,5 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
+import 'package:url_launcher/url_launcher.dart';
 import '../util/api.dart';
 import '../util/models.dart';
 import '../showDialog.dart';
@@ -99,7 +100,7 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
               itemCount: listObj.length + 1,
               itemBuilder: (BuildContext context, int index) { //itemBuilder实际上就是一个map的循环
                 if (index < listObj.length) {
-                  return OrderCardContainer(order:listObj[index],index:index,callback:(val)=>deleteOrder(val));
+                  return OrderCardContainer(order: listObj[index], index: index, callback: (val) => deleteOrder(val));
                 }
                 return _getMoreWidget();
               },
@@ -125,10 +126,9 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
             Container(
               width: ScreenUtil.getInstance().setWidth(50),
               height: ScreenUtil.getInstance().setHeight(50),
-              child:CircularProgressIndicator(
+              child: CircularProgressIndicator()
             )
-            )
-            
+
           ],
         ),
       ),
@@ -143,16 +143,16 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
     });
   }
 
-  void deleteOrder(val){
+  void deleteOrder(val) {
     setState(() {
       listObj.removeAt(val);
-      if(listObj.length<4){
+      if (listObj.length < 4) {
         getOrderList().then((resp) {
           setState(() {
             listObj.addAll(resp.orderList);
           });
         });
-      } 
+      }
     });
   }
 
@@ -210,8 +210,8 @@ class _OrderCardContainerState extends State < OrderCardContainer > with SingleT
         padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), 0),
         child: Column(
           children: < Widget > [
-            orderNoRow(widget.order.orderNo,widget.order.createTime),
-            orderAddress(widget.order.startAddress,widget.order.endAddress),
+            orderNoRow(widget.order.orderNo, widget.order.createTime),
+            orderAddress(widget.order.startAddress, widget.order.endAddress),
             orderItem('货物名称', widget.order.itemName, 15),
             orderItem('货物件数', '${widget.order.itemNo}件', 30),
             orderCutLine(),
@@ -271,10 +271,10 @@ class _OrderCardContainerState extends State < OrderCardContainer > with SingleT
                 barrierDismissible: false,
                 builder: (BuildContext context) {
                   return new LoadingDialog( //调用对话框
-                    text:'是否确认接单',childCallback: (val){
-                      if(val){
-                         widget.callback(widget.index);
-                      }else{
+                    text: '是否确认接单', childCallback: (val) {
+                      if (val) {
+                        widget.callback(widget.index);
+                      } else {
                         return;
                       }
                     },
@@ -362,11 +362,23 @@ Widget orderItem(String key, String value, int marginBottom) { //货物名称,
 }
 
 Widget orderPhone(String key, String value, int marginBottom) {
-  return Container(
-    margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(marginBottom)),
-    child: Row(children: < Widget > [
-      Text('${key}:', style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
-      Text('${value}', style: TextStyle(color: Color.fromRGBO(64, 98, 254, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
-    ], )
+  return InkWell(
+    child: Container(
+      margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(marginBottom)),
+      child: Row(children: < Widget > [
+        Text('${key}:', style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
+        Text('${value}', style: TextStyle(color: Color.fromRGBO(64, 98, 254, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
+      ], )
+    ),
+    onLongPress: () async {
+      String  phone = 'tel:${value}';
+      print(phone);
+      if(await canLaunch(phone)){
+        await (launch(phone));
+      }else{
+        throw 'Could not launch $value';
+      }
+    },
   );
-}
+}
+

+ 8 - 1
pubspec.lock

@@ -177,6 +177,13 @@ packages:
       url: "https://pub.dartlang.org"
     source: hosted
     version: "1.1.6"
+  url_launcher:
+    dependency: "direct main"
+    description:
+      name: url_launcher
+      url: "https://pub.dartlang.org"
+    source: hosted
+    version: "5.0.1"
   vector_math:
     dependency: transitive
     description:
@@ -186,4 +193,4 @@ packages:
     version: "2.0.8"
 sdks:
   dart: ">=2.0.0 <3.0.0"
-  flutter: ">=0.1.4 <2.0.0"
+  flutter: ">=0.5.6 <2.0.0"

+ 2 - 0
pubspec.yaml

@@ -29,6 +29,8 @@ dependencies:
   city_pickers: ^0.0.1
   #picker
   flutter_picker: ^1.0.8
+  #拨打电话及调整web页面插件
+  url_launcher: ^5.0.1
 
 dev_dependencies:
   flutter_test: