This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AppKit | |
import RealityKit | |
class GameViewController: NSViewController { | |
@IBOutlet var arView: ARView! | |
override func awakeFromNib() { | |
// Generating the initial mesh (just so that we can extract its MeshResource.Model, which contains the actual mesh data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AudioPlayerWrapper._internal() { | |
_audioPlayer.onAudioPositionChanged.listen(_onAudioDurationChange); | |
} | |
_onAudioDurationChange(Duration duration) { | |
store.dispatch(AudioDurationChangedAction(duration)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
playTrack(String url) async { | |
var previewFilename = await _audioDownloader.downloadUrl(url); | |
await _audioPlayer.play(previewFilename, isLocal: true); | |
store.dispatch(PlayAudioUrlAction(url)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AudioDownloader { | |
static final AudioDownloader _singleton = new AudioDownloader._internal(); | |
factory AudioDownloader() { | |
return _singleton; | |
} | |
AudioDownloader._internal(); | |
Future<String> downloadUrl(String url) async { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ThunkAction<AppState> getSearchResult = (Store<AppState> store) async { | |
var response = await http.get(Uri.encodeFull('https://itunes.apple.com/search?term=' + store.state.searchText)); | |
store.dispatch(UpdateTrackItemsAction(_decodeTrackItems(_decodeResultItems(response.body)))); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _SearchResultListState extends State<SearchResultList> { | |
@override | |
Widget build(BuildContext context) { | |
return StoreConnector<AppState, List<TrackItem>>( | |
converter: (store) => store.state.trackItems, | |
builder: (_, trackItems) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
leading: ApptectsButton() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AppState reducer(AppState oldState, dynamic action) { | |
if(action is ChangeSearchTextAction) { | |
return oldState.copyWith(searchText: action.searchText); | |
} else if (action is UpdateTrackItemsAction) { | |
return oldState.copyWith(trackItems: action.trackItems); | |
} else if (action is PlayAudioUrlAction) { | |
return oldState.copyWith(activePlayingAudioUrl: action.audioUrl); | |
} else if (action is StopAudioAction) { | |
return oldState.copyWith(activePlayingAudioUrl: ''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Store<AppState> store; | |
void main() { | |
store = Store<AppState>( | |
reducer, | |
initialState: AppState.initial(), | |
middleware: [thunkMiddleware] | |
); | |
runApp(FlutteriTunesApp(store)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies: | |
flutter: | |
sdk: flutter | |
flutter_redux: ^0.5.3 |
NewerOlder