Commit 4847e3dcd640375546d15989369a3ee4a592959c
1 parent
156efec9
feat:添加设备方向处理
Showing
9 changed files
with
39 additions
and
24 deletions
android/app/build.gradle
... | ... | @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' |
26 | 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" |
27 | 27 | |
28 | 28 | android { |
29 | - namespace "com.kouyuxingqiu.wow_english" | |
29 | + namespace "com.kouyuxingqiu.wowenglish" | |
30 | 30 | // compileSdkVersion flutter.compileSdkVersion |
31 | 31 | compileSdkVersion 33 |
32 | 32 | // 展示没有ndk需求 |
... | ... | @@ -46,7 +46,7 @@ android { |
46 | 46 | } |
47 | 47 | |
48 | 48 | defaultConfig { |
49 | - applicationId "com.kouyuxingqiu.wow_english" | |
49 | + applicationId "com.kouyuxingqiu.wowenglish" | |
50 | 50 | //minSdkVersion flutter.minSdkVersion |
51 | 51 | //targetSdkVersion flutter.targetSdkVersion |
52 | 52 | minSdkVersion 23 | ... | ... |
android/app/src/main/kotlin/com/kouyuxingqiu/wow_english/MainActivity.kt
ios/Runner.xcodeproj/project.pbxproj
... | ... | @@ -105,7 +105,6 @@ |
105 | 105 | D8C046A1A9C279FDBB5C174E /* Pods-RunnerTests.release.xcconfig */, |
106 | 106 | 48BCA0827DCB98991774F5AC /* Pods-RunnerTests.profile.xcconfig */, |
107 | 107 | ); |
108 | - name = Pods; | |
109 | 108 | path = Pods; |
110 | 109 | sourceTree = "<group>"; |
111 | 110 | }; |
... | ... | @@ -468,14 +467,14 @@ |
468 | 467 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; |
469 | 468 | CLANG_ENABLE_MODULES = YES; |
470 | 469 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; |
471 | - DEVELOPMENT_TEAM = 6537XPMMG6; | |
470 | + DEVELOPMENT_TEAM = T8P9KW8GWH; | |
472 | 471 | ENABLE_BITCODE = NO; |
473 | 472 | INFOPLIST_FILE = Runner/Info.plist; |
474 | 473 | LD_RUNPATH_SEARCH_PATHS = ( |
475 | 474 | "$(inherited)", |
476 | 475 | "@executable_path/Frameworks", |
477 | 476 | ); |
478 | - PRODUCT_BUNDLE_IDENTIFIER = com.example.wowEnglish; | |
477 | + PRODUCT_BUNDLE_IDENTIFIER = com.kouyuxingqiu.wowenglish; | |
479 | 478 | PRODUCT_NAME = "$(TARGET_NAME)"; |
480 | 479 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; |
481 | 480 | SWIFT_VERSION = 5.0; |
... | ... | @@ -647,14 +646,14 @@ |
647 | 646 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; |
648 | 647 | CLANG_ENABLE_MODULES = YES; |
649 | 648 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; |
650 | - DEVELOPMENT_TEAM = 6537XPMMG6; | |
649 | + DEVELOPMENT_TEAM = T8P9KW8GWH; | |
651 | 650 | ENABLE_BITCODE = NO; |
652 | 651 | INFOPLIST_FILE = Runner/Info.plist; |
653 | 652 | LD_RUNPATH_SEARCH_PATHS = ( |
654 | 653 | "$(inherited)", |
655 | 654 | "@executable_path/Frameworks", |
656 | 655 | ); |
657 | - PRODUCT_BUNDLE_IDENTIFIER = com.example.wowEnglish; | |
656 | + PRODUCT_BUNDLE_IDENTIFIER = com.kouyuxingqiu.wowenglish; | |
658 | 657 | PRODUCT_NAME = "$(TARGET_NAME)"; |
659 | 658 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; |
660 | 659 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; |
... | ... | @@ -670,14 +669,14 @@ |
670 | 669 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; |
671 | 670 | CLANG_ENABLE_MODULES = YES; |
672 | 671 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; |
673 | - DEVELOPMENT_TEAM = 6537XPMMG6; | |
672 | + DEVELOPMENT_TEAM = T8P9KW8GWH; | |
674 | 673 | ENABLE_BITCODE = NO; |
675 | 674 | INFOPLIST_FILE = Runner/Info.plist; |
676 | 675 | LD_RUNPATH_SEARCH_PATHS = ( |
677 | 676 | "$(inherited)", |
678 | 677 | "@executable_path/Frameworks", |
679 | 678 | ); |
680 | - PRODUCT_BUNDLE_IDENTIFIER = com.example.wowEnglish; | |
679 | + PRODUCT_BUNDLE_IDENTIFIER = com.kouyuxingqiu.wowenglish; | |
681 | 680 | PRODUCT_NAME = "$(TARGET_NAME)"; |
682 | 681 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; |
683 | 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 | 4 | <dependencies> |
4 | 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 | 8 | </dependencies> |
7 | 9 | <scenes> |
8 | - <!--Flutter View Controller--> | |
10 | + <!--Main View Controller--> | |
9 | 11 | <scene sceneID="tne-QT-ifu"> |
10 | 12 | <objects> |
11 | - <viewController id="BYZ-38-t0r" customClass="FlutterViewController" sceneMemberID="viewController"> | |
13 | + <viewController id="BYZ-38-t0r" customClass="MainViewController" sceneMemberID="viewController"> | |
12 | 14 | <layoutGuides> |
13 | 15 | <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/> |
14 | 16 | <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/> |
15 | 17 | </layoutGuides> |
16 | 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 | 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 | 22 | </view> |
21 | 23 | </viewController> |
22 | 24 | <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> |
23 | 25 | </objects> |
26 | + <point key="canvasLocation" x="47" y="-2"/> | |
24 | 27 | </scene> |
25 | 28 | </scenes> |
26 | 29 | </document> | ... | ... |
ios/Runner/Info.plist
... | ... | @@ -2,6 +2,8 @@ |
2 | 2 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
3 | 3 | <plist version="1.0"> |
4 | 4 | <dict> |
5 | + <key>CADisableMinimumFrameDurationOnPhone</key> | |
6 | + <true/> | |
5 | 7 | <key>CFBundleDevelopmentRegion</key> |
6 | 8 | <string>$(DEVELOPMENT_LANGUAGE)</string> |
7 | 9 | <key>CFBundleDisplayName</key> |
... | ... | @@ -24,10 +26,14 @@ |
24 | 26 | <string>$(FLUTTER_BUILD_NUMBER)</string> |
25 | 27 | <key>LSRequiresIPhoneOS</key> |
26 | 28 | <true/> |
29 | + <key>UIApplicationSupportsIndirectInputEvents</key> | |
30 | + <true/> | |
27 | 31 | <key>UILaunchStoryboardName</key> |
28 | 32 | <string>LaunchScreen</string> |
29 | 33 | <key>UIMainStoryboardFile</key> |
30 | 34 | <string>Main</string> |
35 | + <key>UIRequiresFullScreen</key> | |
36 | + <true/> | |
31 | 37 | <key>UISupportedInterfaceOrientations</key> |
32 | 38 | <array> |
33 | 39 | <string>UIInterfaceOrientationPortrait</string> |
... | ... | @@ -43,9 +49,5 @@ |
43 | 49 | </array> |
44 | 50 | <key>UIViewControllerBasedStatusBarAppearance</key> |
45 | 51 | <false/> |
46 | - <key>CADisableMinimumFrameDurationOnPhone</key> | |
47 | - <true/> | |
48 | - <key>UIApplicationSupportsIndirectInputEvents</key> | |
49 | - <true/> | |
50 | 52 | </dict> |
51 | 53 | </plist> | ... | ... |
lib/app/app.dart
... | ... | @@ -11,7 +11,7 @@ class App extends StatelessWidget { |
11 | 11 | @override |
12 | 12 | Widget build(BuildContext context) { |
13 | 13 | return ScreenUtilInit( |
14 | - designSize: const Size(375, 812), | |
14 | + designSize: const Size(667, 375), | |
15 | 15 | builder: (_,__) => MultiBlocProvider( |
16 | 16 | providers: [ |
17 | 17 | BlocProvider<TabBloc>(create: (_)=> TabBloc()) | ... | ... |
lib/app/splash_page.dart
lib/main.dart
1 | +import 'dart:io'; | |
1 | 2 | import 'package:flutter/material.dart'; |
3 | +import 'package:flutter/services.dart'; | |
4 | +import 'package:limiting_direction_csx/limiting_direction_csx.dart'; | |
2 | 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 | 15 | runApp(const App()); |
6 | 16 | } | ... | ... |
pubspec.yaml
... | ... | @@ -81,6 +81,8 @@ dependencies: |
81 | 81 | permission_handler: ^10.2.0 |
82 | 82 | # 网络状态监听 https://pub.dev/packages/connectivity_plus |
83 | 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 | 87 | dev_dependencies: |
86 | 88 | build_runner: ^2.4.4 | ... | ... |