Commit 4847e3dcd640375546d15989369a3ee4a592959c

Authored by liangchengyou
1 parent 156efec9

feat:添加设备方向处理

android/app/build.gradle
@@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
26 apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 26 apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 27
28 android { 28 android {
29 - namespace "com.kouyuxingqiu.wow_english" 29 + namespace "com.kouyuxingqiu.wowenglish"
30 // compileSdkVersion flutter.compileSdkVersion 30 // compileSdkVersion flutter.compileSdkVersion
31 compileSdkVersion 33 31 compileSdkVersion 33
32 // 展示没有ndk需求 32 // 展示没有ndk需求
@@ -46,7 +46,7 @@ android { @@ -46,7 +46,7 @@ android {
46 } 46 }
47 47
48 defaultConfig { 48 defaultConfig {
49 - applicationId "com.kouyuxingqiu.wow_english" 49 + applicationId "com.kouyuxingqiu.wowenglish"
50 //minSdkVersion flutter.minSdkVersion 50 //minSdkVersion flutter.minSdkVersion
51 //targetSdkVersion flutter.targetSdkVersion 51 //targetSdkVersion flutter.targetSdkVersion
52 minSdkVersion 23 52 minSdkVersion 23
android/app/src/main/kotlin/com/kouyuxingqiu/wow_english/MainActivity.kt
1 -package com.kouyuxingqiu.wow_english 1 +package com.kouyuxingqiu.wowenglish
2 2
3 import io.flutter.embedding.android.FlutterActivity 3 import io.flutter.embedding.android.FlutterActivity
4 4
ios/Runner.xcodeproj/project.pbxproj
@@ -105,7 +105,6 @@ @@ -105,7 +105,6 @@
105 D8C046A1A9C279FDBB5C174E /* Pods-RunnerTests.release.xcconfig */, 105 D8C046A1A9C279FDBB5C174E /* Pods-RunnerTests.release.xcconfig */,
106 48BCA0827DCB98991774F5AC /* Pods-RunnerTests.profile.xcconfig */, 106 48BCA0827DCB98991774F5AC /* Pods-RunnerTests.profile.xcconfig */,
107 ); 107 );
108 - name = Pods;  
109 path = Pods; 108 path = Pods;
110 sourceTree = "<group>"; 109 sourceTree = "<group>";
111 }; 110 };
@@ -468,14 +467,14 @@ @@ -468,14 +467,14 @@
468 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 467 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
469 CLANG_ENABLE_MODULES = YES; 468 CLANG_ENABLE_MODULES = YES;
470 CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 469 CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
471 - DEVELOPMENT_TEAM = 6537XPMMG6; 470 + DEVELOPMENT_TEAM = T8P9KW8GWH;
472 ENABLE_BITCODE = NO; 471 ENABLE_BITCODE = NO;
473 INFOPLIST_FILE = Runner/Info.plist; 472 INFOPLIST_FILE = Runner/Info.plist;
474 LD_RUNPATH_SEARCH_PATHS = ( 473 LD_RUNPATH_SEARCH_PATHS = (
475 "$(inherited)", 474 "$(inherited)",
476 "@executable_path/Frameworks", 475 "@executable_path/Frameworks",
477 ); 476 );
478 - PRODUCT_BUNDLE_IDENTIFIER = com.example.wowEnglish; 477 + PRODUCT_BUNDLE_IDENTIFIER = com.kouyuxingqiu.wowenglish;
479 PRODUCT_NAME = "$(TARGET_NAME)"; 478 PRODUCT_NAME = "$(TARGET_NAME)";
480 SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 479 SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
481 SWIFT_VERSION = 5.0; 480 SWIFT_VERSION = 5.0;
@@ -647,14 +646,14 @@ @@ -647,14 +646,14 @@
647 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 646 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
648 CLANG_ENABLE_MODULES = YES; 647 CLANG_ENABLE_MODULES = YES;
649 CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 648 CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
650 - DEVELOPMENT_TEAM = 6537XPMMG6; 649 + DEVELOPMENT_TEAM = T8P9KW8GWH;
651 ENABLE_BITCODE = NO; 650 ENABLE_BITCODE = NO;
652 INFOPLIST_FILE = Runner/Info.plist; 651 INFOPLIST_FILE = Runner/Info.plist;
653 LD_RUNPATH_SEARCH_PATHS = ( 652 LD_RUNPATH_SEARCH_PATHS = (
654 "$(inherited)", 653 "$(inherited)",
655 "@executable_path/Frameworks", 654 "@executable_path/Frameworks",
656 ); 655 );
657 - PRODUCT_BUNDLE_IDENTIFIER = com.example.wowEnglish; 656 + PRODUCT_BUNDLE_IDENTIFIER = com.kouyuxingqiu.wowenglish;
658 PRODUCT_NAME = "$(TARGET_NAME)"; 657 PRODUCT_NAME = "$(TARGET_NAME)";
659 SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 658 SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
660 SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 659 SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -670,14 +669,14 @@ @@ -670,14 +669,14 @@
670 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 669 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
671 CLANG_ENABLE_MODULES = YES; 670 CLANG_ENABLE_MODULES = YES;
672 CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 671 CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
673 - DEVELOPMENT_TEAM = 6537XPMMG6; 672 + DEVELOPMENT_TEAM = T8P9KW8GWH;
674 ENABLE_BITCODE = NO; 673 ENABLE_BITCODE = NO;
675 INFOPLIST_FILE = Runner/Info.plist; 674 INFOPLIST_FILE = Runner/Info.plist;
676 LD_RUNPATH_SEARCH_PATHS = ( 675 LD_RUNPATH_SEARCH_PATHS = (
677 "$(inherited)", 676 "$(inherited)",
678 "@executable_path/Frameworks", 677 "@executable_path/Frameworks",
679 ); 678 );
680 - PRODUCT_BUNDLE_IDENTIFIER = com.example.wowEnglish; 679 + PRODUCT_BUNDLE_IDENTIFIER = com.kouyuxingqiu.wowenglish;
681 PRODUCT_NAME = "$(TARGET_NAME)"; 680 PRODUCT_NAME = "$(TARGET_NAME)";
682 SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 681 SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
683 SWIFT_VERSION = 5.0; 682 SWIFT_VERSION = 5.0;
ios/Runner/Base.lproj/Main.storyboard
1 -<?xml version="1.0" encoding="UTF-8" standalone="no"?>  
2 -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r"> 1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
  3 + <device id="retina6_12" orientation="portrait" appearance="light"/>
3 <dependencies> 4 <dependencies>
4 <deployment identifier="iOS"/> 5 <deployment identifier="iOS"/>
5 - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/> 6 + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
  7 + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
6 </dependencies> 8 </dependencies>
7 <scenes> 9 <scenes>
8 - <!--Flutter View Controller--> 10 + <!--Main View Controller-->
9 <scene sceneID="tne-QT-ifu"> 11 <scene sceneID="tne-QT-ifu">
10 <objects> 12 <objects>
11 - <viewController id="BYZ-38-t0r" customClass="FlutterViewController" sceneMemberID="viewController"> 13 + <viewController id="BYZ-38-t0r" customClass="MainViewController" sceneMemberID="viewController">
12 <layoutGuides> 14 <layoutGuides>
13 <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/> 15 <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
14 <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/> 16 <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
15 </layoutGuides> 17 </layoutGuides>
16 <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> 18 <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
17 - <rect key="frame" x="0.0" y="0.0" width="600" height="600"/> 19 + <rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
18 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> 20 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
19 - <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> 21 + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
20 </view> 22 </view>
21 </viewController> 23 </viewController>
22 <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> 24 <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
23 </objects> 25 </objects>
  26 + <point key="canvasLocation" x="47" y="-2"/>
24 </scene> 27 </scene>
25 </scenes> 28 </scenes>
26 </document> 29 </document>
ios/Runner/Info.plist
@@ -2,6 +2,8 @@ @@ -2,6 +2,8 @@
2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3 <plist version="1.0"> 3 <plist version="1.0">
4 <dict> 4 <dict>
  5 + <key>CADisableMinimumFrameDurationOnPhone</key>
  6 + <true/>
5 <key>CFBundleDevelopmentRegion</key> 7 <key>CFBundleDevelopmentRegion</key>
6 <string>$(DEVELOPMENT_LANGUAGE)</string> 8 <string>$(DEVELOPMENT_LANGUAGE)</string>
7 <key>CFBundleDisplayName</key> 9 <key>CFBundleDisplayName</key>
@@ -24,10 +26,14 @@ @@ -24,10 +26,14 @@
24 <string>$(FLUTTER_BUILD_NUMBER)</string> 26 <string>$(FLUTTER_BUILD_NUMBER)</string>
25 <key>LSRequiresIPhoneOS</key> 27 <key>LSRequiresIPhoneOS</key>
26 <true/> 28 <true/>
  29 + <key>UIApplicationSupportsIndirectInputEvents</key>
  30 + <true/>
27 <key>UILaunchStoryboardName</key> 31 <key>UILaunchStoryboardName</key>
28 <string>LaunchScreen</string> 32 <string>LaunchScreen</string>
29 <key>UIMainStoryboardFile</key> 33 <key>UIMainStoryboardFile</key>
30 <string>Main</string> 34 <string>Main</string>
  35 + <key>UIRequiresFullScreen</key>
  36 + <true/>
31 <key>UISupportedInterfaceOrientations</key> 37 <key>UISupportedInterfaceOrientations</key>
32 <array> 38 <array>
33 <string>UIInterfaceOrientationPortrait</string> 39 <string>UIInterfaceOrientationPortrait</string>
@@ -43,9 +49,5 @@ @@ -43,9 +49,5 @@
43 </array> 49 </array>
44 <key>UIViewControllerBasedStatusBarAppearance</key> 50 <key>UIViewControllerBasedStatusBarAppearance</key>
45 <false/> 51 <false/>
46 - <key>CADisableMinimumFrameDurationOnPhone</key>  
47 - <true/>  
48 - <key>UIApplicationSupportsIndirectInputEvents</key>  
49 - <true/>  
50 </dict> 52 </dict>
51 </plist> 53 </plist>
lib/app/app.dart
@@ -11,7 +11,7 @@ class App extends StatelessWidget { @@ -11,7 +11,7 @@ class App extends StatelessWidget {
11 @override 11 @override
12 Widget build(BuildContext context) { 12 Widget build(BuildContext context) {
13 return ScreenUtilInit( 13 return ScreenUtilInit(
14 - designSize: const Size(375, 812), 14 + designSize: const Size(667, 375),
15 builder: (_,__) => MultiBlocProvider( 15 builder: (_,__) => MultiBlocProvider(
16 providers: [ 16 providers: [
17 BlocProvider<TabBloc>(create: (_)=> TabBloc()) 17 BlocProvider<TabBloc>(create: (_)=> TabBloc())
lib/app/splash_page.dart
1 -import 'package:flutter/foundation.dart';  
2 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
3 import 'package:wow_english/network/basic_configuration.dart'; 2 import 'package:wow_english/network/basic_configuration.dart';
4 import 'package:wow_english/route/route.dart'; 3 import 'package:wow_english/route/route.dart';
lib/main.dart
  1 +import 'dart:io';
1 import 'package:flutter/material.dart'; 2 import 'package:flutter/material.dart';
  3 +import 'package:flutter/services.dart';
  4 +import 'package:limiting_direction_csx/limiting_direction_csx.dart';
2 import 'package:wow_english/app/app.dart'; 5 import 'package:wow_english/app/app.dart';
3 6
4 -void main() { 7 +void main() async{
  8 + ///设置设备默认方向
  9 + WidgetsFlutterBinding.ensureInitialized();
  10 + if (Platform.isIOS) {
  11 + await LimitingDirectionCsx.setScreenDirection(DeviceDirectionMask.Landscape);
  12 + } else {
  13 + SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft,DeviceOrientation.landscapeRight]);
  14 + }
5 runApp(const App()); 15 runApp(const App());
6 } 16 }
pubspec.yaml
@@ -81,6 +81,8 @@ dependencies: @@ -81,6 +81,8 @@ dependencies:
81 permission_handler: ^10.2.0 81 permission_handler: ^10.2.0
82 # 网络状态监听 https://pub.dev/packages/connectivity_plus 82 # 网络状态监听 https://pub.dev/packages/connectivity_plus
83 connectivity_plus: ^4.0.1 83 connectivity_plus: ^4.0.1
  84 + # iOS设备方向控制 https://pub.dev/packages/limiting_direction_csx
  85 + limiting_direction_csx: ^0.2.0
84 86
85 dev_dependencies: 87 dev_dependencies:
86 build_runner: ^2.4.4 88 build_runner: ^2.4.4