Skip to content

Commit 4a4193e

Browse files
Merge pull request #1 from IgorKhramtsov/IK_reddit_api
Reddit api, authorization
2 parents d8e8184 + ca13acf commit 4a4193e

36 files changed

+2519
-39
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ app.*.map.json
4444
/android/app/debug
4545
/android/app/profile
4646
/android/app/release
47+
48+
# Secure files
49+
.env

ios/Flutter/Debug.xcconfig

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
12
#include "Generated.xcconfig"

ios/Flutter/Release.xcconfig

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
12
#include "Generated.xcconfig"

ios/Podfile

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Uncomment this line to define a global platform for your project
2+
# platform :ios, '9.0'
3+
4+
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5+
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6+
7+
project 'Runner', {
8+
'Debug' => :debug,
9+
'Profile' => :release,
10+
'Release' => :release,
11+
}
12+
13+
def flutter_root
14+
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15+
unless File.exist?(generated_xcode_build_settings_path)
16+
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
17+
end
18+
19+
File.foreach(generated_xcode_build_settings_path) do |line|
20+
matches = line.match(/FLUTTER_ROOT\=(.*)/)
21+
return matches[1].strip if matches
22+
end
23+
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
24+
end
25+
26+
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
27+
28+
flutter_ios_podfile_setup
29+
30+
target 'Runner' do
31+
use_frameworks!
32+
use_modular_headers!
33+
34+
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
35+
end
36+
37+
post_install do |installer|
38+
installer.pods_project.targets.each do |target|
39+
flutter_additional_ios_build_settings(target)
40+
end
41+
end

ios/Podfile.lock

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
PODS:
2+
- Flutter (1.0.0)
3+
- path_provider (0.0.1):
4+
- Flutter
5+
- url_launcher (0.0.1):
6+
- Flutter
7+
8+
DEPENDENCIES:
9+
- Flutter (from `Flutter`)
10+
- path_provider (from `.symlinks/plugins/path_provider/ios`)
11+
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)
12+
13+
EXTERNAL SOURCES:
14+
Flutter:
15+
:path: Flutter
16+
path_provider:
17+
:path: ".symlinks/plugins/path_provider/ios"
18+
url_launcher:
19+
:path: ".symlinks/plugins/url_launcher/ios"
20+
21+
SPEC CHECKSUMS:
22+
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
23+
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
24+
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef
25+
26+
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
27+
28+
COCOAPODS: 1.10.2

ios/Runner.xcodeproj/project.pbxproj

+86-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 46;
6+
objectVersion = 50;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -13,6 +13,7 @@
1313
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
1414
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
1515
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
16+
CC3710756EB93DB359F177AE /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A17807CFEDDD55D1F200B500 /* Pods_Runner.framework */; };
1617
/* End PBXBuildFile section */
1718

1819
/* Begin PBXCopyFilesBuildPhase section */
@@ -31,30 +32,43 @@
3132
/* Begin PBXFileReference section */
3233
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
3334
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
35+
19B8936E9568C90A4BB0F7ED /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
3436
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3537
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
3638
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
3739
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
40+
8496F45FD128A345A9B47C31 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
3841
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
3942
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
4043
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
4144
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
4245
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4346
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
4447
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
48+
A17807CFEDDD55D1F200B500 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
49+
ACC6E5DC50CB3DDCB322EC02 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
4550
/* End PBXFileReference section */
4651

4752
/* Begin PBXFrameworksBuildPhase section */
4853
97C146EB1CF9000F007C117D /* Frameworks */ = {
4954
isa = PBXFrameworksBuildPhase;
5055
buildActionMask = 2147483647;
5156
files = (
57+
CC3710756EB93DB359F177AE /* Pods_Runner.framework in Frameworks */,
5258
);
5359
runOnlyForDeploymentPostprocessing = 0;
5460
};
5561
/* End PBXFrameworksBuildPhase section */
5662

5763
/* Begin PBXGroup section */
64+
7D0B65E1611B995D6860883D /* Frameworks */ = {
65+
isa = PBXGroup;
66+
children = (
67+
A17807CFEDDD55D1F200B500 /* Pods_Runner.framework */,
68+
);
69+
name = Frameworks;
70+
sourceTree = "<group>";
71+
};
5872
9740EEB11CF90186004384FC /* Flutter */ = {
5973
isa = PBXGroup;
6074
children = (
@@ -72,6 +86,8 @@
7286
9740EEB11CF90186004384FC /* Flutter */,
7387
97C146F01CF9000F007C117D /* Runner */,
7488
97C146EF1CF9000F007C117D /* Products */,
89+
FC10BCD361E1260FACFC8EB6 /* Pods */,
90+
7D0B65E1611B995D6860883D /* Frameworks */,
7591
);
7692
sourceTree = "<group>";
7793
};
@@ -98,19 +114,32 @@
98114
path = Runner;
99115
sourceTree = "<group>";
100116
};
117+
FC10BCD361E1260FACFC8EB6 /* Pods */ = {
118+
isa = PBXGroup;
119+
children = (
120+
8496F45FD128A345A9B47C31 /* Pods-Runner.debug.xcconfig */,
121+
19B8936E9568C90A4BB0F7ED /* Pods-Runner.release.xcconfig */,
122+
ACC6E5DC50CB3DDCB322EC02 /* Pods-Runner.profile.xcconfig */,
123+
);
124+
name = Pods;
125+
path = Pods;
126+
sourceTree = "<group>";
127+
};
101128
/* End PBXGroup section */
102129

103130
/* Begin PBXNativeTarget section */
104131
97C146ED1CF9000F007C117D /* Runner */ = {
105132
isa = PBXNativeTarget;
106133
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
107134
buildPhases = (
135+
28D2A7131FE2A2A5EFC2EDE4 /* [CP] Check Pods Manifest.lock */,
108136
9740EEB61CF901F6004384FC /* Run Script */,
109137
97C146EA1CF9000F007C117D /* Sources */,
110138
97C146EB1CF9000F007C117D /* Frameworks */,
111139
97C146EC1CF9000F007C117D /* Resources */,
112140
9705A1C41CF9048500538489 /* Embed Frameworks */,
113141
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
142+
15F9865B18BD4D3355BA0F74 /* [CP] Embed Pods Frameworks */,
114143
);
115144
buildRules = (
116145
);
@@ -169,6 +198,45 @@
169198
/* End PBXResourcesBuildPhase section */
170199

171200
/* Begin PBXShellScriptBuildPhase section */
201+
15F9865B18BD4D3355BA0F74 /* [CP] Embed Pods Frameworks */ = {
202+
isa = PBXShellScriptBuildPhase;
203+
buildActionMask = 2147483647;
204+
files = (
205+
);
206+
inputFileListPaths = (
207+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
208+
);
209+
name = "[CP] Embed Pods Frameworks";
210+
outputFileListPaths = (
211+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
212+
);
213+
runOnlyForDeploymentPostprocessing = 0;
214+
shellPath = /bin/sh;
215+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
216+
showEnvVarsInLog = 0;
217+
};
218+
28D2A7131FE2A2A5EFC2EDE4 /* [CP] Check Pods Manifest.lock */ = {
219+
isa = PBXShellScriptBuildPhase;
220+
buildActionMask = 2147483647;
221+
files = (
222+
);
223+
inputFileListPaths = (
224+
);
225+
inputPaths = (
226+
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
227+
"${PODS_ROOT}/Manifest.lock",
228+
);
229+
name = "[CP] Check Pods Manifest.lock";
230+
outputFileListPaths = (
231+
);
232+
outputPaths = (
233+
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
234+
);
235+
runOnlyForDeploymentPostprocessing = 0;
236+
shellPath = /bin/sh;
237+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
238+
showEnvVarsInLog = 0;
239+
};
172240
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
173241
isa = PBXShellScriptBuildPhase;
174242
buildActionMask = 2147483647;
@@ -290,8 +358,11 @@
290358
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
291359
ENABLE_BITCODE = NO;
292360
INFOPLIST_FILE = Runner/Info.plist;
293-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
294-
PRODUCT_BUNDLE_IDENTIFIER = com.example.devour;
361+
LD_RUNPATH_SEARCH_PATHS = (
362+
"$(inherited)",
363+
"@executable_path/Frameworks",
364+
);
365+
PRODUCT_BUNDLE_IDENTIFIER = dev.khramtsov.devour;
295366
PRODUCT_NAME = "$(TARGET_NAME)";
296367
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
297368
SWIFT_VERSION = 5.0;
@@ -399,7 +470,8 @@
399470
MTL_ENABLE_DEBUG_INFO = NO;
400471
SDKROOT = iphoneos;
401472
SUPPORTED_PLATFORMS = iphoneos;
402-
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
473+
SWIFT_COMPILATION_MODE = wholemodule;
474+
SWIFT_OPTIMIZATION_LEVEL = "-O";
403475
TARGETED_DEVICE_FAMILY = "1,2";
404476
VALIDATE_PRODUCT = YES;
405477
};
@@ -414,8 +486,11 @@
414486
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
415487
ENABLE_BITCODE = NO;
416488
INFOPLIST_FILE = Runner/Info.plist;
417-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
418-
PRODUCT_BUNDLE_IDENTIFIER = com.example.devour;
489+
LD_RUNPATH_SEARCH_PATHS = (
490+
"$(inherited)",
491+
"@executable_path/Frameworks",
492+
);
493+
PRODUCT_BUNDLE_IDENTIFIER = dev.khramtsov.devour;
419494
PRODUCT_NAME = "$(TARGET_NAME)";
420495
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
421496
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -433,8 +508,11 @@
433508
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
434509
ENABLE_BITCODE = NO;
435510
INFOPLIST_FILE = Runner/Info.plist;
436-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
437-
PRODUCT_BUNDLE_IDENTIFIER = com.example.devour;
511+
LD_RUNPATH_SEARCH_PATHS = (
512+
"$(inherited)",
513+
"@executable_path/Frameworks",
514+
);
515+
PRODUCT_BUNDLE_IDENTIFIER = dev.khramtsov.devour;
438516
PRODUCT_NAME = "$(TARGET_NAME)";
439517
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
440518
SWIFT_VERSION = 5.0;

ios/Runner.xcworkspace/contents.xcworkspacedata

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ios/Runner/Info.plist

+20
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,25 @@
4141
</array>
4242
<key>UIViewControllerBasedStatusBarAppearance</key>
4343
<false/>
44+
<key>FlutterDeepLinkingEnabled</key>
45+
<true/>
46+
<key>CFBundleURLTypes</key>
47+
<array>
48+
<dict>
49+
<key>CFBundleTypeRole</key>
50+
<string>Editor</string>
51+
<key>CFBundleURLName</key>
52+
<string>dev.khramtsov.devour</string>
53+
<key>CFBundleURLSchemes</key>
54+
<array>
55+
<string>devour</string>
56+
</array>
57+
</dict>
58+
</array>
59+
<key>LSApplicationQueriesSchemes</key>
60+
<array>
61+
<string>https</string>
62+
<string>http</string>
63+
</array>
4464
</dict>
4565
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import 'dart:async';
2+
3+
import 'package:bloc/bloc.dart';
4+
import 'package:devour/application/navigator/app_navigator.dart';
5+
import 'package:devour/application/navigator/routes.dart';
6+
import 'package:devour/domain/auth/oauth_account_model.dart';
7+
import 'package:devour/domain/auth/reddit_account.dart';
8+
import 'package:devour/infrastructure/api/reddit_api.dart';
9+
import 'package:devour/infrastructure/core/misc.dart';
10+
import 'package:devour/infrastructure/repositories/accounts_repository.dart';
11+
import 'package:fpdart/fpdart.dart';
12+
import 'package:freezed_annotation/freezed_annotation.dart';
13+
import 'package:injectable/injectable.dart';
14+
15+
part 'accounts_event.dart';
16+
part 'accounts_state.dart';
17+
part 'accounts_bloc.freezed.dart';
18+
19+
@injectable
20+
class AccountsBloc extends Bloc<AccountsEvent, AccountsState> {
21+
AccountsBloc(this._redditAPI, this._accountsRepository)
22+
: super(AccountsState.initial()) {
23+
this.add(AccountsEvent.Fetching());
24+
}
25+
26+
static String? _authRandomString;
27+
28+
final RedditAPI _redditAPI;
29+
final AccountsRepository _accountsRepository;
30+
31+
@override
32+
Stream<AccountsState> mapEventToState(
33+
AccountsEvent event,
34+
) async* {
35+
yield* event.map(
36+
Fetching: (_Fetching value) async* {
37+
yield state.copyWith(
38+
redditAccount: _accountsRepository.getAccount<RedditAccount>(),
39+
);
40+
},
41+
AuthorizeReddit: (e) async* {
42+
if (e.args.state == _authRandomString) {
43+
final response = await _redditAPI.getAccessToken(e.args.code);
44+
final account = RedditAccount.fromResponse(response);
45+
46+
_accountsRepository.setAccount(account);
47+
yield state.copyWith(
48+
redditAccount: Option.of(account),
49+
);
50+
}
51+
},
52+
AuthorizeVK: (e) async* {},
53+
RequestAuthorizationReddit: (e) async* {
54+
_authRandomString = getRandomString(15);
55+
final authorizationLink =
56+
await _redditAPI.getAuthorizationLink(_authRandomString!);
57+
58+
AppNavigator.openLink(authorizationLink);
59+
// yield state;
60+
},
61+
RequestAuthorizationVK: (e) async* {
62+
yield state;
63+
},
64+
);
65+
}
66+
}

0 commit comments

Comments
 (0)