Skip to content

Commit

Permalink
feat: login via OTP
Browse files Browse the repository at this point in the history
  • Loading branch information
phanan committed Apr 19, 2024
1 parent 4a18d5c commit 22f2fbd
Show file tree
Hide file tree
Showing 25 changed files with 276 additions and 310 deletions.
2 changes: 1 addition & 1 deletion android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
5 changes: 5 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
<meta-data
android:name="flutterEmbedding"
android:value="2" />

<!-- Support for QR scanner. See https://github.com/roman-yerin/native_qr -->
<meta-data
android:name="com.google.mlkit.vision.DEPENDENCIES"
android:value="barcode_ui" />
</application>

<uses-permission android:name="android.permission.INTERNET" />
Expand Down
2 changes: 1 addition & 1 deletion ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
platform :ios, '11.0'
platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
42 changes: 20 additions & 22 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,35 @@ PODS:
- FMDB/standard (2.7.5)
- just_audio (0.0.1):
- Flutter
- MTBBarcodeScanner (5.0.11)
- native_qr (0.0.1):
- Flutter
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- qr_code_scanner (0.2.0):
- Flutter
- MTBBarcodeScanner
- ReachabilitySwift (5.0.0)
- sqflite (0.0.2):
- Flutter
- FMDB (>= 2.7.5)
- video_player_avfoundation (0.0.1):
- Flutter
- wakelock (0.0.1):
- Flutter
- webview_flutter_wkwebview (0.0.1):
- Flutter

DEPENDENCIES:
- audio_service (from `.symlinks/plugins/audio_service/ios`)
- audio_session (from `.symlinks/plugins/audio_session/ios`)
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
- Flutter (from `Flutter`)
- just_audio (from `.symlinks/plugins/just_audio/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`)
- native_qr (from `.symlinks/plugins/native_qr/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- qr_code_scanner (from `.symlinks/plugins/qr_code_scanner/ios`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
- video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/ios`)
- wakelock (from `.symlinks/plugins/wakelock/ios`)
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`)

SPEC REPOS:
trunk:
- FMDB
- MTBBarcodeScanner
- ReachabilitySwift

EXTERNAL SOURCES:
Expand All @@ -54,31 +54,29 @@ EXTERNAL SOURCES:
:path: Flutter
just_audio:
:path: ".symlinks/plugins/just_audio/ios"
native_qr:
:path: ".symlinks/plugins/native_qr/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/ios"
:path: ".symlinks/plugins/path_provider_foundation/darwin"
qr_code_scanner:
:path: ".symlinks/plugins/qr_code_scanner/ios"
sqflite:
:path: ".symlinks/plugins/sqflite/ios"
video_player_avfoundation:
:path: ".symlinks/plugins/video_player_avfoundation/ios"
wakelock:
:path: ".symlinks/plugins/wakelock/ios"
webview_flutter_wkwebview:
:path: ".symlinks/plugins/webview_flutter_wkwebview/ios"

SPEC CHECKSUMS:
audio_service: f509d65da41b9521a61f1c404dd58651f265a567
audio_session: 4f3e461722055d21515cf3261b64c973c062f345
connectivity_plus: 413a8857dd5d9f1c399a39130850d02fe0feaf7e
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
native_qr: 2a3151f33e6c69d4320fc5c5f24848200c1aa4fa
path_provider_foundation: c68054786f1b4f3343858c1e1d0caaded73f0be9
qr_code_scanner: bb67d64904c3b9658ada8c402e8b4d406d5d796e
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
video_player_avfoundation: 81e49bb3d9fb63dccf9fa0f6d877dc3ddbeac126
wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f
webview_flutter_wkwebview: b7e70ef1ddded7e69c796c7390ee74180182971f

PODFILE CHECKSUM: ca5588cf6dfd563245937ea51517ea6f225e6f5e
PODFILE CHECKSUM: e3f29c7ff5542cfd5274ac2c7e8374a7eab80a0c

COCOAPODS: 1.12.0
18 changes: 11 additions & 7 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -207,6 +207,7 @@
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand Down Expand Up @@ -364,19 +365,20 @@
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_TEAM = PTBU9CDS3L;
ENABLE_BITCODE = NO;
FLUTTER_BUILD_NAME = 2.1.0;
FLUTTER_BUILD_NUMBER = 20;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Koel Player";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)";
MARKETING_VERSION = 2.2.0;
PRODUCT_BUNDLE_IDENTIFIER = dev.koel.koel;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -508,19 +510,20 @@
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_TEAM = PTBU9CDS3L;
ENABLE_BITCODE = NO;
FLUTTER_BUILD_NAME = 2.1.0;
FLUTTER_BUILD_NUMBER = 20;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Koel Player Test";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)";
MARKETING_VERSION = 2.2.0;
PRODUCT_BUNDLE_IDENTIFIER = debug.dev.koel.koel;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -541,19 +544,20 @@
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_TEAM = PTBU9CDS3L;
ENABLE_BITCODE = NO;
FLUTTER_BUILD_NAME = 2.1.0;
FLUTTER_BUILD_NUMBER = 20;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Koel Player";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)";
MARKETING_VERSION = 2.2.0;
PRODUCT_BUNDLE_IDENTIFIER = dev.koel.koel;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
13 changes: 8 additions & 5 deletions ios/Runner/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Flutter View Controller-->
Expand All @@ -14,13 +16,14 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="140" y="-2"/>
</scene>
</scenes>
</document>
2 changes: 2 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSCameraUsageDescription</key>
<string>Require acces to camera to support login via QR code</string>
</dict>
</plist>
15 changes: 15 additions & 0 deletions lib/providers/auth_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ class AuthProvider with StreamSubscriber {
preferences.audioToken = response['audio-token'];
}

Future<void> loginWithOneTimeToken({
required String host,
required String token,
}) async {
preferences.host = host;

final loginData = <String, String>{
'token': token,
};

final response = await post('me/otp', data: loginData);
preferences.apiToken = response['token'];
preferences.audioToken = response['audio-token'];
}

void setAuthUser(User user) => _authUser = user;

Future<User?> tryGetAuthUser() async {
Expand Down
27 changes: 14 additions & 13 deletions lib/ui/screens/info_sheet/info_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class _InfoSheetState extends State<InfoSheet> {
backgroundColor: Colors.transparent,
elevation: 0,
bottom: const TabBar(
indicatorColor: AppColors.highlight,
tabs: [
Tab(text: 'Lyrics'),
Tab(text: 'Artist'),
Expand Down Expand Up @@ -85,18 +84,20 @@ class InfoHtml extends StatelessWidget {

@override
Widget build(BuildContext context) {
return SelectableHtml(
data: '<div>$content</div>',
style: {
'body': Style().copyWith(
padding: EdgeInsets.zero,
margin: EdgeInsets.zero,
),
'div': (style ?? Style()).copyWith(
fontSize: FontSize.large,
lineHeight: LineHeight.number(1.4),
),
},
return SelectionArea(
child: Html(
data: '<div>$content</div>',
style: {
'body': Style().copyWith(
padding: HtmlPaddings.zero,
margin: Margins.zero,
),
'div': (style ?? Style()).copyWith(
fontSize: FontSize.large,
lineHeight: LineHeight.number(1.4),
),
},
),
);
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/screens/info_sheet/lyrics_pane.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class LyricsPane extends StatelessWidget {
: Padding(
padding: EdgeInsets.only(top: 4.0),
child: InfoHtml(
content: song.lyrics.replaceAll('\n', '<br>'),
content:
song.lyrics.replaceAll('\n', '<br>').replaceAll('\r', '<br>'),
style: Style(fontSize: FontSize.larger),
),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/screens/library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class LibraryMenuItem extends StatelessWidget {
contentPadding: EdgeInsets.symmetric(
horizontal: AppDimensions.hPadding,
),
horizontalTitleGap: 0,
horizontalTitleGap: 12,
leading: icon is IconData ? Icon(icon, color: Colors.white54) : icon,
title: Text(label, style: const TextStyle(fontSize: 20)),
trailing: const Icon(
Expand Down
Loading

0 comments on commit 22f2fbd

Please sign in to comment.