Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tradingview chart #2463

Merged
merged 6 commits into from
May 9, 2024
Merged

Tradingview chart #2463

merged 6 commits into from
May 9, 2024

Conversation

Restioson
Copy link
Contributor

@Restioson Restioson commented Apr 23, 2024

Fixes #2123

I'm not sure that this will work well at all DPIs - I add a 3x scale, else it is too small

image

TODO:

  • Align background colours
  • Try remove grey border
  • Line instead of candlesticks (if we can)
  • Hide link back to tradingview
  • Change to BitMex
  • Try remove reset control
  • Timezone?

@Restioson Restioson self-assigned this Apr 23, 2024
@bonomat
Copy link
Contributor

bonomat commented Apr 24, 2024

Nice. Doesn't look too sexy though 😬 I tried it on an iOS simulator and it looks even worse :/

@bonomat
Copy link
Contributor

bonomat commented Apr 24, 2024

Beautiful ads :D

image

@holzeis
Copy link
Contributor

holzeis commented Apr 24, 2024

@Restioson can you configure the widget to open in the browser if the TradingView logo is tapped?

Copy link
Contributor

@holzeis holzeis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we could get rid of the in widget browser "feature" and instead open the browser on the phone it would be good to go.

Note, I haven't run it on my machine. We should check if it's properly rendered for iOS and Android.

Additionally it would be cool to recognise if the user is tilting their phone. If so we could show more details on the trading view. But that doesn't have to come with this PR.

@@ -204,7 +204,7 @@ wipe: wipe-docker wipe-coordinator wipe-maker wipe-app wipe-webapp
wipe-docker:
#!/usr/bin/env bash
set -euxo pipefail
docker-compose down -v
docker compose down -v
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fear this will break it for me since I did not install compose as plugin but as separate binary.

Copy link
Contributor Author

@Restioson Restioson May 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, on the other hand, I do not have compose and only have the plugin. According to the site the separate binary is not recommended:
image
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can drop this commit if we want but it'd be good to find a solution that works for both of us

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to change my setup if it's fine for everybody else @bonomat @luckysori

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no hard feelings, on my machine both seems to work :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with this change.

<script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-advanced-chart.js" async>
{
"autosize": true,
"symbol": "BITSTAMP:BTCUSD",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 can we change that to BitMEX?

mobile/lib/features/trade/tradingview_candlestick.dart Outdated Show resolved Hide resolved
<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container" style="height:100%;width:100%">
<div class="tradingview-widget-container__widget" style="height:calc(100% - 32px);width:100%"></div>
<div class="tradingview-widget-copyright"><a href="https://www.tradingview.com/" rel="noopener nofollow" target="_blank"><span class="blue-text">Track all markets on TradingView</span></a></div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 I guess we can remove that link.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but I'm not sure if we would be violating some usage policy by doing that

"allow_symbol_change": false,
"save_image": false,
"calendar": false,
"support_host": "https://www.tradingview.com"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ what is the support host?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was generated by the widget creator on their site

@Restioson
Copy link
Contributor Author

Nice. Doesn't look too sexy though 😬 I tried it on an iOS simulator and it looks even worse :/

I believe it's a scaling issue. The photo that I sent looks poor because it's a JPEG. It's perfectly crisp on my phone screen but the artifacts look really bad when cropped & zoomed like that. As we've discussed with iOS it seems like the scaling algorithm isn't great for the simulator and possibly real phone too. I'm not exactly sure how we should be scaling it. Maybe there's some viewport meta tags that can be provided to specify DPI? I will have to try these out.

@Restioson can you configure the widget to open in the browser if the TradingView logo is tapped?

I can give it a shot for sure!

If we could get rid of the in widget browser "feature" and instead open the browser on the phone it would be good to go.

How do you mean - get rid of it entirely and just show a link? If we will do this, we could also use the mini ticker view and have a tap for details feature. That way there is still something to show, especially just the price and recent movements, but it won't be scrollable.

Beautiful ads :D

Do we still want to go with TradingView if we will have ads like this? 😕

@holzeis
Copy link
Contributor

holzeis commented Apr 29, 2024

If we could get rid of the in widget browser "feature" and instead open the browser on the phone it would be good to go.

How do you mean - get rid of it entirely and just show a link? If we will do this, we could also use the mini ticker view and have a tap for details feature. That way there is still something to show, especially just the price and recent movements, but it won't be scrollable.

I meant If we can get rid of the widget opening another website internally, when clicking the TradingView logo. I think this will also fix the ad issue.

@Restioson
Copy link
Contributor Author

I meant If we can get rid of the widget opening another website internally, when clicking the TradingView logo. I think this will also fix the ad issue.

Do you know anything about how the ads are showing up? I haven't had it happen yet and was assuming that it just replaced the old view (i.e without having to navigate to a new site or anything)

@Restioson
Copy link
Contributor Author

I've added the functionality to only open links in a new tab in the latest commit

@holzeis
Copy link
Contributor

holzeis commented Apr 29, 2024

Do you know anything about how the ads are showing up? I haven't had it happen yet and was assuming that it just replaced the old view (i.e without having to navigate to a new site or anything)

My theory is that the widget simply shows the tradingview.com website and that the ad is simply coming from there.

@bonomat
Copy link
Contributor

bonomat commented Apr 30, 2024

Do you know anything about how the ads are showing up? I haven't had it happen yet and was assuming that it just replaced the old view (i.e without having to navigate to a new site or anything)

My theory is that the widget simply shows the tradingview.com website and that the ad is simply coming from there.

yea, I think the ad only came because I clicked on the trading view tab which opened trading view.

@Restioson
Copy link
Contributor Author

I'm not sure we can remove the grey border, as it's inside the iframe. Same goes for the reset control. We should be able to change it to a line graph and also could edit the timezone, though. Are these features desired?

@luckysori
Copy link
Contributor

I'm not sure we can remove the grey border, as it's inside the iframe. Same goes for the reset control. We should be able to change it to a line graph and also could edit the timezone, though. Are these features desired?

With regards to the grey border, it's not a big deal.

@bonomat
Copy link
Contributor

bonomat commented May 2, 2024

I've tested it on an iPhone simulator... unfortunately it doesn't work.
I get the error Failed to open link to TradingView.
When I remove this part it works again.

..setNavigationDelegate(NavigationDelegate(
          onNavigationRequest: (req) async {
           
            final uri = Uri.parse(req.url);
            if (await canLaunchUrl(uri)) {
              await launchUrl(uri, mode: LaunchMode.externalApplication);
            } else {
              showSnackBar(ScaffoldMessenger.of(rootNavigatorKey.currentContext!),
                  "Failed to open link to TradingView");
            }

            return NavigationDecision.prevent;
          },
        ))

it looks like the requested URL is "about:blank".

@Restioson
Copy link
Contributor Author

Restioson commented May 2, 2024

I've tested it on an iPhone simulator... unfortunately it doesn't work. I get the error Failed to open link to TradingView. When I remove this part it works again.
-- snip --
it looks like the requested URL is "about:blank".

When you say 'works', do you mean that it launches into a new browser app, or that it redirects the embedded page in the app?

Also, can you see the page fine? Is the external launching the only issue?

@bonomat
Copy link
Contributor

bonomat commented May 2, 2024

I've tested it on an iPhone simulator... unfortunately it doesn't work. I get the error Failed to open link to TradingView. When I remove this part it works again.
-- snip --
it looks like the requested URL is "about:blank".

When you say 'works', do you mean that it launches into a new browser app, or that it redirects the embedded page in the app?

Also, can you see the page fine? Is the external launching the only issue?

Sorry, what I meant is that I don't see a chart at all. Only if I remove said code part I see the chart.

image

@Restioson
Copy link
Contributor Author

Hmm, I see. I'll maybe add an exception for about scheme urls and we can see if that works? Are you happy to test this?

@bonomat bonomat self-assigned this May 8, 2024
@bonomat
Copy link
Contributor

bonomat commented May 9, 2024

Unfortunately it doesn't work on my simulator. When navigating to the trade screen it automatically opens the external browser and opens the tradingview. It only works if I remove the NavigationDelegate completely (I've tried NavigationDecision.revent and NavigateDecision.navigate. If it is on prevent the chart is not shown at all and on navigate it opens the external browser.

@bonomat
Copy link
Contributor

bonomat commented May 9, 2024

Made it work for you in 60f89ff (#2463) using the same plugin we use in DLC-Connect :) Tested on Android Simulator and iOS Simulator.

Android iOS
image image

Copy link
Contributor

@bonomat bonomat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally on Android and iOS simulator. I failed deploying it on the phone due to some local setting issue though, but I think we should give it a try.

@bonomat bonomat force-pushed the tradingview-chart branch from 60f89ff to 28833e7 Compare May 9, 2024 05:04
@bonomat bonomat force-pushed the tradingview-chart branch from 28833e7 to 2f8ca83 Compare May 9, 2024 05:06
@bonomat
Copy link
Contributor

bonomat commented May 9, 2024

@Restioson : I've rebased for you. Let's get this in.

@bonomat bonomat enabled auto-merge May 9, 2024 05:06
this is also needed so that our tests run, which run on native
@bonomat bonomat added this pull request to the merge queue May 9, 2024
Merged via the queue into main with commit d0df781 May 9, 2024
22 checks passed
@bonomat bonomat deleted the tradingview-chart branch May 9, 2024 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace candlestick chart
4 participants